Skip to content

Commit f30375e

Browse files
authored
fix build (#68)
* fix build * address clippy, switch to stable * fix build
1 parent f25d18a commit f30375e

File tree

9 files changed

+26
-47
lines changed

9 files changed

+26
-47
lines changed

.github/workflows/rust.yml

+6-15
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@ on:
77
branches: [ master ]
88

99
jobs:
10-
build_nightly:
10+
build:
1111
runs-on: ubuntu-latest
1212
steps:
1313
- uses: actions/checkout@v2
1414
- name: Install
15-
run: rustup default nightly
15+
run: rustup default stable
1616
- name: Install rustfmt Components
1717
run: rustup component add rustfmt
1818
- name: Install clippy
@@ -28,13 +28,15 @@ jobs:
2828
- name: Check clippy warnings
2929
run: cargo clippy --all-targets --all-features -- -D warnings
3030

31-
build_nightly_wasm:
31+
32+
33+
build_wasm:
3234
runs-on: ubuntu-latest
3335
steps:
3436
- uses: actions/checkout@v2
3537

3638
- name: Install
37-
run: rustup default nightly
39+
run: rustup default stable
3840

3941
- name: Build without std
4042
run: cargo build --no-default-features --verbose
@@ -53,14 +55,3 @@ jobs:
5355

5456
- name: Build for target wasm-wasi
5557
run: RUSTFLAGS="" cargo build --target=wasm32-wasi --no-default-features --verbose
56-
57-
- name: Patch Cargo.toml for wasm-bindgen
58-
run: |
59-
echo "[dependencies.getrandom]" >> Cargo.toml
60-
echo "version = \"0.1\"" >> Cargo.toml
61-
echo "default-features = false" >> Cargo.toml
62-
echo "features = [\"wasm-bindgen\"]" >> Cargo.toml
63-
64-
- name: Build for target wasm32-unknown-unknown
65-
run: RUSTFLAGS="" cargo build --target=wasm32-unknown-unknown --no-default-features --verbose
66-

Cargo.toml

+3-3
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,18 @@ keywords = ["zkSNARKs", "cryptography", "proofs"]
1414
curve25519-dalek = { version = "4.1.1", features = [
1515
"serde",
1616
"alloc",
17+
"rand_core",
1718
], default-features = false }
1819
merlin = { version = "3.0.0", default-features = false }
19-
rand = { version = "0.7.3", features = ["getrandom"], default-features = false }
20+
rand = "0.8"
21+
rand_core = { version = "0.6", default-features = false, features = ["getrandom"] }
2022
digest = { version = "0.8.1", default-features = false }
2123
sha3 = { version = "0.8.2", default-features = false }
2224
byteorder = { version = "1.3.4", default-features = false }
2325
rayon = { version = "1.3.0", optional = true }
2426
serde = { version = "1.0.106", features = ["derive"], default-features = false }
2527
bincode = { version = "1.3.3", default-features = false }
2628
subtle = { version = "2.4", features = ["i128"], default-features = false }
27-
zeroize = { version = "1.5", default-features = false }
2829
itertools = { version = "0.10.0", default-features = false }
2930
colored = { version = "2.0.0", default-features = false, optional = true }
3031
flate2 = { version = "1.0.14" }
@@ -66,7 +67,6 @@ std = [
6667
"byteorder/std",
6768
"serde/std",
6869
"subtle/std",
69-
"zeroize/std",
7070
"itertools/use_std",
7171
"flate2/rust_backend",
7272
]

README.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ fn produce_tiny_r1cs() -> (
187187
// To construct these matrices, we will use `curve25519-dalek` but one can use any other method.
188188

189189
// a variable that holds a byte representation of 1
190-
let one = Scalar::one().to_bytes();
190+
let one = Scalar::ONE.to_bytes();
191191

192192
// R1CS is a set of three sparse matrices A B C, where is a row for every
193193
// constraint and a column for every entry in z = (vars, 1, inputs)
@@ -224,10 +224,10 @@ fn produce_tiny_r1cs() -> (
224224
let z1 = Scalar::random(&mut csprng);
225225
let z2 = (z0 + z1) * i0; // constraint 0
226226
let z3 = (z0 + i1) * z2; // constraint 1
227-
let z4 = Scalar::zero(); //constraint 2
227+
let z4 = Scalar::ZERO; //constraint 2
228228

229229
// create a VarsAssignment
230-
let mut vars = vec![Scalar::zero().to_bytes(); num_vars];
230+
let mut vars = vec![Scalar::ZERO.to_bytes(); num_vars];
231231
vars[0] = z0.to_bytes();
232232
vars[1] = z1.to_bytes();
233233
vars[2] = z2.to_bytes();
@@ -236,7 +236,7 @@ fn produce_tiny_r1cs() -> (
236236
let assignment_vars = VarsAssignment::new(&vars).unwrap();
237237

238238
// create an InputsAssignment
239-
let mut inputs = vec![Scalar::zero().to_bytes(); num_inputs];
239+
let mut inputs = vec![Scalar::ZERO.to_bytes(); num_inputs];
240240
inputs[0] = i0.to_bytes();
241241
inputs[1] = i1.to_bytes();
242242
let assignment_inputs = InputsAssignment::new(&inputs).unwrap();

examples/cubic.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ fn produce_r1cs() -> (
3636
let mut B: Vec<(usize, usize, [u8; 32])> = Vec::new();
3737
let mut C: Vec<(usize, usize, [u8; 32])> = Vec::new();
3838

39-
let one = Scalar::one().to_bytes();
39+
let one = Scalar::ONE.to_bytes();
4040

4141
// R1CS is a set of three sparse matrices A B C, where is a row for every
4242
// constraint and a column for every entry in z = (vars, 1, inputs)
@@ -80,15 +80,15 @@ fn produce_r1cs() -> (
8080
let i0 = z3 + Scalar::from(5u32); // constraint 3
8181

8282
// create a VarsAssignment
83-
let mut vars = vec![Scalar::zero().to_bytes(); num_vars];
83+
let mut vars = vec![Scalar::ZERO.to_bytes(); num_vars];
8484
vars[0] = z0.to_bytes();
8585
vars[1] = z1.to_bytes();
8686
vars[2] = z2.to_bytes();
8787
vars[3] = z3.to_bytes();
8888
let assignment_vars = VarsAssignment::new(&vars).unwrap();
8989

9090
// create an InputsAssignment
91-
let mut inputs = vec![Scalar::zero().to_bytes(); num_inputs];
91+
let mut inputs = vec![Scalar::ZERO.to_bytes(); num_inputs];
9292
inputs[0] = i0.to_bytes();
9393
let assignment_inputs = InputsAssignment::new(&inputs).unwrap();
9494

profiler/nizk.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ fn print(msg: &str) {
1717

1818
pub fn main() {
1919
// the list of number of variables (and constraints) in an R1CS instance
20-
let inst_sizes = vec![10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20];
20+
let inst_sizes = [10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20];
2121

2222
println!("Profiler:: NIZK");
2323
for &s in inst_sizes.iter() {

profiler/snark.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ fn print(msg: &str) {
1616

1717
pub fn main() {
1818
// the list of number of variables (and constraints) in an R1CS instance
19-
let inst_sizes = vec![10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20];
19+
let inst_sizes = [10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20];
2020

2121
println!("Profiler:: SNARK");
2222
for &s in inst_sizes.iter() {

src/product_tree.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -257,8 +257,8 @@ impl ProductCircuitEvalProof {
257257

258258
impl ProductCircuitEvalProofBatched {
259259
pub fn prove(
260-
prod_circuit_vec: &mut Vec<&mut ProductCircuit>,
261-
dotp_circuit_vec: &mut Vec<&mut DotProductCircuit>,
260+
prod_circuit_vec: &mut [&mut ProductCircuit],
261+
dotp_circuit_vec: &mut [&mut DotProductCircuit],
262262
transcript: &mut Transcript,
263263
) -> (Self, Vec<Scalar>) {
264264
assert!(!prod_circuit_vec.is_empty());

src/scalar/ristretto255.rs

+3-15
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ use core::ops::{Add, AddAssign, Mul, MulAssign, Neg, Sub, SubAssign};
1313
use rand::{CryptoRng, RngCore};
1414
use serde::{Deserialize, Serialize};
1515
use subtle::{Choice, ConditionallySelectable, ConstantTimeEq, CtOption};
16-
use zeroize::Zeroize;
1716

1817
// use crate::util::{adc, mac, sbb};
1918
/// Compute a + b + carry, returning the result and the new carry over.
@@ -359,12 +358,6 @@ where
359358
}
360359
}
361360

362-
impl Zeroize for Scalar {
363-
fn zeroize(&mut self) {
364-
self.0 = [0u64; 4];
365-
}
366-
}
367-
368361
impl Scalar {
369362
/// Returns zero, the additive identity.
370363
#[inline]
@@ -609,22 +602,17 @@ impl Scalar {
609602
// externally, but there's no corresponding distinction for
610603
// field elements.
611604

612-
use zeroize::Zeroizing;
613-
614605
let n = inputs.len();
615606
let one = Scalar::one();
616607

617-
// Place scratch storage in a Zeroizing wrapper to wipe it when
618-
// we pass out of scope.
619-
let scratch_vec = vec![one; n];
620-
let mut scratch = Zeroizing::new(scratch_vec);
608+
let mut scratch_vec = vec![one; n];
621609

622610
// Keep an accumulator of all of the previous products
623611
let mut acc = Scalar::one();
624612

625613
// Pass through the input vector, recording the previous
626614
// products in the scratch space
627-
for (input, scratch) in inputs.iter().zip(scratch.iter_mut()) {
615+
for (input, scratch) in inputs.iter().zip(scratch_vec.iter_mut()) {
628616
*scratch = acc;
629617

630618
acc = acc * input;
@@ -641,7 +629,7 @@ impl Scalar {
641629

642630
// Pass through the vector backwards to compute the inverses
643631
// in place
644-
for (input, scratch) in inputs.iter_mut().rev().zip(scratch.iter().rev()) {
632+
for (input, scratch) in inputs.iter_mut().rev().zip(scratch_vec.iter().rev()) {
645633
let tmp = &acc * input.clone();
646634
*input = &acc * scratch;
647635
acc = tmp;

src/sparse_mlpoly.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1154,7 +1154,7 @@ impl ProductLayerProof {
11541154
};
11551155

11561156
let (proof_ops, rand_ops) = ProductCircuitEvalProofBatched::prove(
1157-
&mut vec![
1157+
&mut [
11581158
&mut row_read_A[0],
11591159
&mut row_read_B[0],
11601160
&mut row_read_C[0],
@@ -1168,7 +1168,7 @@ impl ProductLayerProof {
11681168
&mut col_write_B[0],
11691169
&mut col_write_C[0],
11701170
],
1171-
&mut vec![
1171+
&mut [
11721172
&mut dotp_left_A[0],
11731173
&mut dotp_right_A[0],
11741174
&mut dotp_left_B[0],
@@ -1181,7 +1181,7 @@ impl ProductLayerProof {
11811181

11821182
// produce a batched proof of memory-related product circuits
11831183
let (proof_mem, rand_mem) = ProductCircuitEvalProofBatched::prove(
1184-
&mut vec![
1184+
&mut [
11851185
&mut row_prod_layer.init,
11861186
&mut row_prod_layer.audit,
11871187
&mut col_prod_layer.init,

0 commit comments

Comments
 (0)