From 1e6091847264ddd596f2930e736cb843b074a9e1 Mon Sep 17 00:00:00 2001 From: ashWhiteHat Date: Fri, 20 Sep 2024 03:19:57 +0900 Subject: [PATCH] close issue 70 and badge (#71) * chore: fix actions badge * test: fix assertion * chore: fix array method and fmt actions --- .github/workflows/rust.yml | 13 ++----------- README.md | 2 +- src/sparse_mlpoly.rs | 14 +++++--------- 3 files changed, 8 insertions(+), 21 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 1037e4a..e694aaa 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -12,7 +12,7 @@ jobs: steps: - uses: actions/checkout@v2 - name: Install - run: rustup default stable + run: rustup default stable - name: Install rustfmt Components run: rustup component add rustfmt - name: Install clippy @@ -28,30 +28,21 @@ jobs: - name: Check clippy warnings run: cargo clippy --all-targets --all-features -- -D warnings - - build_wasm: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - - name: Install - run: rustup default stable - + run: rustup default stable - name: Build without std run: cargo build --no-default-features --verbose - - name: Run tests without std run: cargo test --no-default-features --verbose - - name: Build examples without std run: cargo build --examples --no-default-features --verbose - - name: Install wasm32-wasi target run: rustup target add wasm32-wasi - - name: Install wasm32-unknown-unknown target run: rustup target add wasm32-unknown-unknown - - name: Build for target wasm-wasi run: RUSTFLAGS="" cargo build --target=wasm32-wasi --no-default-features --verbose diff --git a/README.md b/README.md index dc3281a..6a1cb60 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Spartan: High-speed zkSNARKs without trusted setup -![Rust](https://github.com/microsoft/Spartan/workflows/Rust/badge.svg) +![Rust](https://github.com/microsoft/Spartan/actions/workflows/rust.yml/badge.svg) [![](https://img.shields.io/crates/v/spartan.svg)](<(https://crates.io/crates/spartan)>) Spartan is a high-speed zero-knowledge proof system, a cryptographic primitive that enables a prover to prove a mathematical statement to a verifier without revealing anything besides the validity of the statement. This repository provides `libspartan,` a Rust library that implements a zero-knowledge succinct non-interactive argument of knowledge (zkSNARK), which is a type of zero-knowledge proof system with short proofs and fast verification times. The details of the Spartan proof system are described in our [paper](https://eprint.iacr.org/2019/550) published at [CRYPTO 2020](https://crypto.iacr.org/2020/). The security of the Spartan variant implemented in this library is based on the discrete logarithm problem in the random oracle model. diff --git a/src/sparse_mlpoly.rs b/src/sparse_mlpoly.rs index 14beaf5..83a51f5 100644 --- a/src/sparse_mlpoly.rs +++ b/src/sparse_mlpoly.rs @@ -1234,10 +1234,8 @@ impl ProductLayerProof { let (row_eval_init, row_eval_read, row_eval_write, row_eval_audit) = &self.eval_row; assert_eq!(row_eval_write.len(), num_instances); assert_eq!(row_eval_read.len(), num_instances); - let ws: Scalar = (0..row_eval_write.len()) - .map(|i| row_eval_write[i]) - .product(); - let rs: Scalar = (0..row_eval_read.len()).map(|i| row_eval_read[i]).product(); + let ws: Scalar = row_eval_write.iter().product(); + let rs: Scalar = row_eval_read.iter().product(); assert_eq!(row_eval_init * ws, rs * row_eval_audit); row_eval_init.append_to_transcript(b"claim_row_eval_init", transcript); @@ -1249,10 +1247,8 @@ impl ProductLayerProof { let (col_eval_init, col_eval_read, col_eval_write, col_eval_audit) = &self.eval_col; assert_eq!(col_eval_write.len(), num_instances); assert_eq!(col_eval_read.len(), num_instances); - let ws: Scalar = (0..col_eval_write.len()) - .map(|i| col_eval_write[i]) - .product(); - let rs: Scalar = (0..col_eval_read.len()).map(|i| col_eval_read[i]).product(); + let ws: Scalar = col_eval_write.iter().product(); + let rs: Scalar = col_eval_read.iter().product(); assert_eq!(col_eval_init * ws, rs * col_eval_audit); col_eval_init.append_to_transcript(b"claim_col_eval_init", transcript); @@ -1262,7 +1258,7 @@ impl ProductLayerProof { // verify the evaluation of the sparse polynomial let (eval_dotp_left, eval_dotp_right) = &self.eval_val; - assert_eq!(eval_dotp_left.len(), eval_dotp_left.len()); + assert_eq!(eval_dotp_left.len(), eval_dotp_right.len()); assert_eq!(eval_dotp_left.len(), num_instances); let mut claims_dotp_circuit: Vec = Vec::new(); for i in 0..num_instances {