fix build (#68)
* fix build * address clippy, switch to stable * fix build
This commit is contained in:
Родитель
f25d18a6d0
Коммит
f30375e498
|
@ -7,12 +7,12 @@ on:
|
|||
branches: [ master ]
|
||||
|
||||
jobs:
|
||||
build_nightly:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Install
|
||||
run: rustup default nightly
|
||||
run: rustup default stable
|
||||
- name: Install rustfmt Components
|
||||
run: rustup component add rustfmt
|
||||
- name: Install clippy
|
||||
|
@ -28,13 +28,15 @@ jobs:
|
|||
- name: Check clippy warnings
|
||||
run: cargo clippy --all-targets --all-features -- -D warnings
|
||||
|
||||
build_nightly_wasm:
|
||||
|
||||
|
||||
build_wasm:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- name: Install
|
||||
run: rustup default nightly
|
||||
run: rustup default stable
|
||||
|
||||
- name: Build without std
|
||||
run: cargo build --no-default-features --verbose
|
||||
|
@ -53,14 +55,3 @@ jobs:
|
|||
|
||||
- name: Build for target wasm-wasi
|
||||
run: RUSTFLAGS="" cargo build --target=wasm32-wasi --no-default-features --verbose
|
||||
|
||||
- name: Patch Cargo.toml for wasm-bindgen
|
||||
run: |
|
||||
echo "[dependencies.getrandom]" >> Cargo.toml
|
||||
echo "version = \"0.1\"" >> Cargo.toml
|
||||
echo "default-features = false" >> Cargo.toml
|
||||
echo "features = [\"wasm-bindgen\"]" >> Cargo.toml
|
||||
|
||||
- name: Build for target wasm32-unknown-unknown
|
||||
run: RUSTFLAGS="" cargo build --target=wasm32-unknown-unknown --no-default-features --verbose
|
||||
|
||||
|
|
|
@ -14,9 +14,11 @@ keywords = ["zkSNARKs", "cryptography", "proofs"]
|
|||
curve25519-dalek = { version = "4.1.1", features = [
|
||||
"serde",
|
||||
"alloc",
|
||||
"rand_core",
|
||||
], default-features = false }
|
||||
merlin = { version = "3.0.0", default-features = false }
|
||||
rand = { version = "0.7.3", features = ["getrandom"], default-features = false }
|
||||
rand = "0.8"
|
||||
rand_core = { version = "0.6", default-features = false, features = ["getrandom"] }
|
||||
digest = { version = "0.8.1", default-features = false }
|
||||
sha3 = { version = "0.8.2", default-features = false }
|
||||
byteorder = { version = "1.3.4", default-features = false }
|
||||
|
@ -24,7 +26,6 @@ rayon = { version = "1.3.0", optional = true }
|
|||
serde = { version = "1.0.106", features = ["derive"], default-features = false }
|
||||
bincode = { version = "1.3.3", default-features = false }
|
||||
subtle = { version = "2.4", features = ["i128"], default-features = false }
|
||||
zeroize = { version = "1.5", default-features = false }
|
||||
itertools = { version = "0.10.0", default-features = false }
|
||||
colored = { version = "2.0.0", default-features = false, optional = true }
|
||||
flate2 = { version = "1.0.14" }
|
||||
|
@ -66,7 +67,6 @@ std = [
|
|||
"byteorder/std",
|
||||
"serde/std",
|
||||
"subtle/std",
|
||||
"zeroize/std",
|
||||
"itertools/use_std",
|
||||
"flate2/rust_backend",
|
||||
]
|
||||
|
|
|
@ -187,7 +187,7 @@ fn produce_tiny_r1cs() -> (
|
|||
// To construct these matrices, we will use `curve25519-dalek` but one can use any other method.
|
||||
|
||||
// a variable that holds a byte representation of 1
|
||||
let one = Scalar::one().to_bytes();
|
||||
let one = Scalar::ONE.to_bytes();
|
||||
|
||||
// R1CS is a set of three sparse matrices A B C, where is a row for every
|
||||
// constraint and a column for every entry in z = (vars, 1, inputs)
|
||||
|
@ -224,10 +224,10 @@ fn produce_tiny_r1cs() -> (
|
|||
let z1 = Scalar::random(&mut csprng);
|
||||
let z2 = (z0 + z1) * i0; // constraint 0
|
||||
let z3 = (z0 + i1) * z2; // constraint 1
|
||||
let z4 = Scalar::zero(); //constraint 2
|
||||
let z4 = Scalar::ZERO; //constraint 2
|
||||
|
||||
// create a VarsAssignment
|
||||
let mut vars = vec![Scalar::zero().to_bytes(); num_vars];
|
||||
let mut vars = vec![Scalar::ZERO.to_bytes(); num_vars];
|
||||
vars[0] = z0.to_bytes();
|
||||
vars[1] = z1.to_bytes();
|
||||
vars[2] = z2.to_bytes();
|
||||
|
@ -236,7 +236,7 @@ fn produce_tiny_r1cs() -> (
|
|||
let assignment_vars = VarsAssignment::new(&vars).unwrap();
|
||||
|
||||
// create an InputsAssignment
|
||||
let mut inputs = vec![Scalar::zero().to_bytes(); num_inputs];
|
||||
let mut inputs = vec![Scalar::ZERO.to_bytes(); num_inputs];
|
||||
inputs[0] = i0.to_bytes();
|
||||
inputs[1] = i1.to_bytes();
|
||||
let assignment_inputs = InputsAssignment::new(&inputs).unwrap();
|
||||
|
|
|
@ -36,7 +36,7 @@ fn produce_r1cs() -> (
|
|||
let mut B: Vec<(usize, usize, [u8; 32])> = Vec::new();
|
||||
let mut C: Vec<(usize, usize, [u8; 32])> = Vec::new();
|
||||
|
||||
let one = Scalar::one().to_bytes();
|
||||
let one = Scalar::ONE.to_bytes();
|
||||
|
||||
// R1CS is a set of three sparse matrices A B C, where is a row for every
|
||||
// constraint and a column for every entry in z = (vars, 1, inputs)
|
||||
|
@ -80,7 +80,7 @@ fn produce_r1cs() -> (
|
|||
let i0 = z3 + Scalar::from(5u32); // constraint 3
|
||||
|
||||
// create a VarsAssignment
|
||||
let mut vars = vec![Scalar::zero().to_bytes(); num_vars];
|
||||
let mut vars = vec![Scalar::ZERO.to_bytes(); num_vars];
|
||||
vars[0] = z0.to_bytes();
|
||||
vars[1] = z1.to_bytes();
|
||||
vars[2] = z2.to_bytes();
|
||||
|
@ -88,7 +88,7 @@ fn produce_r1cs() -> (
|
|||
let assignment_vars = VarsAssignment::new(&vars).unwrap();
|
||||
|
||||
// create an InputsAssignment
|
||||
let mut inputs = vec![Scalar::zero().to_bytes(); num_inputs];
|
||||
let mut inputs = vec![Scalar::ZERO.to_bytes(); num_inputs];
|
||||
inputs[0] = i0.to_bytes();
|
||||
let assignment_inputs = InputsAssignment::new(&inputs).unwrap();
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ fn print(msg: &str) {
|
|||
|
||||
pub fn main() {
|
||||
// the list of number of variables (and constraints) in an R1CS instance
|
||||
let inst_sizes = vec![10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20];
|
||||
let inst_sizes = [10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20];
|
||||
|
||||
println!("Profiler:: NIZK");
|
||||
for &s in inst_sizes.iter() {
|
||||
|
|
|
@ -16,7 +16,7 @@ fn print(msg: &str) {
|
|||
|
||||
pub fn main() {
|
||||
// the list of number of variables (and constraints) in an R1CS instance
|
||||
let inst_sizes = vec![10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20];
|
||||
let inst_sizes = [10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20];
|
||||
|
||||
println!("Profiler:: SNARK");
|
||||
for &s in inst_sizes.iter() {
|
||||
|
|
|
@ -257,8 +257,8 @@ impl ProductCircuitEvalProof {
|
|||
|
||||
impl ProductCircuitEvalProofBatched {
|
||||
pub fn prove(
|
||||
prod_circuit_vec: &mut Vec<&mut ProductCircuit>,
|
||||
dotp_circuit_vec: &mut Vec<&mut DotProductCircuit>,
|
||||
prod_circuit_vec: &mut [&mut ProductCircuit],
|
||||
dotp_circuit_vec: &mut [&mut DotProductCircuit],
|
||||
transcript: &mut Transcript,
|
||||
) -> (Self, Vec<Scalar>) {
|
||||
assert!(!prod_circuit_vec.is_empty());
|
||||
|
|
|
@ -13,7 +13,6 @@ use core::ops::{Add, AddAssign, Mul, MulAssign, Neg, Sub, SubAssign};
|
|||
use rand::{CryptoRng, RngCore};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use subtle::{Choice, ConditionallySelectable, ConstantTimeEq, CtOption};
|
||||
use zeroize::Zeroize;
|
||||
|
||||
// use crate::util::{adc, mac, sbb};
|
||||
/// Compute a + b + carry, returning the result and the new carry over.
|
||||
|
@ -359,12 +358,6 @@ where
|
|||
}
|
||||
}
|
||||
|
||||
impl Zeroize for Scalar {
|
||||
fn zeroize(&mut self) {
|
||||
self.0 = [0u64; 4];
|
||||
}
|
||||
}
|
||||
|
||||
impl Scalar {
|
||||
/// Returns zero, the additive identity.
|
||||
#[inline]
|
||||
|
@ -609,22 +602,17 @@ impl Scalar {
|
|||
// externally, but there's no corresponding distinction for
|
||||
// field elements.
|
||||
|
||||
use zeroize::Zeroizing;
|
||||
|
||||
let n = inputs.len();
|
||||
let one = Scalar::one();
|
||||
|
||||
// Place scratch storage in a Zeroizing wrapper to wipe it when
|
||||
// we pass out of scope.
|
||||
let scratch_vec = vec![one; n];
|
||||
let mut scratch = Zeroizing::new(scratch_vec);
|
||||
let mut scratch_vec = vec![one; n];
|
||||
|
||||
// Keep an accumulator of all of the previous products
|
||||
let mut acc = Scalar::one();
|
||||
|
||||
// Pass through the input vector, recording the previous
|
||||
// products in the scratch space
|
||||
for (input, scratch) in inputs.iter().zip(scratch.iter_mut()) {
|
||||
for (input, scratch) in inputs.iter().zip(scratch_vec.iter_mut()) {
|
||||
*scratch = acc;
|
||||
|
||||
acc = acc * input;
|
||||
|
@ -641,7 +629,7 @@ impl Scalar {
|
|||
|
||||
// Pass through the vector backwards to compute the inverses
|
||||
// in place
|
||||
for (input, scratch) in inputs.iter_mut().rev().zip(scratch.iter().rev()) {
|
||||
for (input, scratch) in inputs.iter_mut().rev().zip(scratch_vec.iter().rev()) {
|
||||
let tmp = &acc * input.clone();
|
||||
*input = &acc * scratch;
|
||||
acc = tmp;
|
||||
|
|
|
@ -1154,7 +1154,7 @@ impl ProductLayerProof {
|
|||
};
|
||||
|
||||
let (proof_ops, rand_ops) = ProductCircuitEvalProofBatched::prove(
|
||||
&mut vec![
|
||||
&mut [
|
||||
&mut row_read_A[0],
|
||||
&mut row_read_B[0],
|
||||
&mut row_read_C[0],
|
||||
|
@ -1168,7 +1168,7 @@ impl ProductLayerProof {
|
|||
&mut col_write_B[0],
|
||||
&mut col_write_C[0],
|
||||
],
|
||||
&mut vec![
|
||||
&mut [
|
||||
&mut dotp_left_A[0],
|
||||
&mut dotp_right_A[0],
|
||||
&mut dotp_left_B[0],
|
||||
|
@ -1181,7 +1181,7 @@ impl ProductLayerProof {
|
|||
|
||||
// produce a batched proof of memory-related product circuits
|
||||
let (proof_mem, rand_mem) = ProductCircuitEvalProofBatched::prove(
|
||||
&mut vec![
|
||||
&mut [
|
||||
&mut row_prod_layer.init,
|
||||
&mut row_prod_layer.audit,
|
||||
&mut col_prod_layer.init,
|
||||
|
|
Загрузка…
Ссылка в новой задаче