Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
149 changes: 113 additions & 36 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
name: Build and Test Spartan

permissions:
contents: read
pull-requests: write

on:
push:
branches: [ master ]
Expand All @@ -10,39 +14,112 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install
run: rustup default stable
- name: Install rustfmt Components
run: rustup component add rustfmt
- name: Install clippy
run: rustup component add clippy
- name: Build
run: cargo build --verbose
- name: Run tests
run: cargo test --verbose
- name: Build examples
run: cargo build --examples --verbose
- name: Check Rustfmt Code Style
run: cargo fmt --all -- --check
- 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
- 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
- uses: actions/checkout@v2
- name: Build
uses: actions-rs/toolchain@v1
with:
toolchain: stable
- uses: actions-rs/cargo@v1
with:
command: build
args: --examples --benches --verbose

build-no-default-features:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Build
uses: actions-rs/toolchain@v1
with:
toolchain: stable
- uses: actions-rs/cargo@v1
with:
command: build
args: --no-default-features --examples --benches --verbose

build-wasm:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Wasm build
uses: actions-rs/toolchain@v1
with:
toolchain: stable
target: wasm32-unknown-unknown
- uses: actions-rs/cargo@v1
with:
command: build
args: --no-default-features --target wasm32-unknown-unknown

build-wasi:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install wasm32-wasip1 target
run: rustup target add wasm32-wasip1
- uses: actions-rs/cargo@v1
with:
command: build
args: --no-default-features --target wasm32-wasip1

test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Run tests
uses: actions-rs/toolchain@v1
with:
toolchain: stable
- uses: actions-rs/cargo@v1
with:
command: test
args: --release --verbose

test-no-default-features:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Run tests
uses: actions-rs/toolchain@v1
with:
toolchain: stable
- uses: actions-rs/cargo@v1
with:
command: test
args: --no-default-features --release --verbose

fmt:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Check Rustfmt Code Style
uses: actions-rs/toolchain@v1
with:
toolchain: stable
components: rustfmt
- uses: actions-rs/cargo@v1
with:
command: fmt
args: --all -- --check

clippy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Check clippy warnings
uses: actions-rs/toolchain@v1
with:
toolchain: stable
components: clippy
- uses: actions-rs/cargo@v1
with:
command: clippy
args: --all-targets -- -D warnings

spelling:
runs-on: ubuntu-latest
steps:
- name: Checkout Actions Repository
uses: actions/checkout@v3
- name: Spell Check Repo
uses: crate-ci/typos@685eb3d55be2f85191e8c84acb9f44d7756f84ab
8 changes: 6 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ curve25519-dalek = { version = "4.1.1", features = [
"rand_core",
], default-features = false }
merlin = { version = "3.0.0", default-features = false }
rand = "0.8"
rand_core = { version = "0.6", default-features = false, features = ["getrandom"] }
rand = "0.8.5"
rand_core = { version = "0.6", default-features = false }
digest = { version = "0.8.1", default-features = false }
sha3 = { version = "0.8.2", default-features = false }
byteorder = { version = "1.3.4", default-features = false }
Expand All @@ -30,8 +30,12 @@ itertools = { version = "0.10.0", default-features = false }
colored = { version = "2.0.0", default-features = false, optional = true }
flate2 = { version = "1.0.14" }

[target.'cfg(target_arch = "wasm32")'.dependencies]
getrandom = { version = "0.2.15", default-features = false, features = ["js"] }

[dev-dependencies]
criterion = "0.3.1"
typos = "0.10.33"

[lib]
name = "libspartan"
Expand Down
1 change: 0 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ extern crate core;
extern crate curve25519_dalek;
extern crate digest;
extern crate merlin;
extern crate rand;
extern crate sha3;

#[cfg(feature = "multicore")]
Expand Down
2 changes: 1 addition & 1 deletion src/product_tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ impl ProductCircuitEvalProofBatched {
.collect::<Vec<Scalar>>();
let mut rand = Vec::new();
for layer_id in (0..num_layers).rev() {
// prepare paralell instance that share poly_C first
// prepare parallel instance that share poly_C first
let len = prod_circuit_vec[0].left_vec[layer_id].len()
+ prod_circuit_vec[0].right_vec[layer_id].len();

Expand Down
12 changes: 6 additions & 6 deletions src/r1csproof.rs
Original file line number Diff line number Diff line change
Expand Up @@ -263,9 +263,9 @@ impl R1CSProof {

let timer_sc_proof_phase2 = Timer::new("prove_sc_phase_two");
// combine the three claims into a single claim
let r_A = transcript.challenge_scalar(b"challenege_Az");
let r_B = transcript.challenge_scalar(b"challenege_Bz");
let r_C = transcript.challenge_scalar(b"challenege_Cz");
let r_A = transcript.challenge_scalar(b"challenge_Az");
let r_B = transcript.challenge_scalar(b"challenge_Bz");
let r_C = transcript.challenge_scalar(b"challenge_Cz");
let claim_phase2 = r_A * Az_claim + r_B * Bz_claim + r_C * Cz_claim;
let blind_claim_phase2 = r_A * Az_blind + r_B * Bz_blind + r_C * Cz_blind;

Expand Down Expand Up @@ -418,9 +418,9 @@ impl R1CSProof {
)?;

// derive three public challenges and then derive a joint claim
let r_A = transcript.challenge_scalar(b"challenege_Az");
let r_B = transcript.challenge_scalar(b"challenege_Bz");
let r_C = transcript.challenge_scalar(b"challenege_Cz");
let r_A = transcript.challenge_scalar(b"challenge_Az");
let r_B = transcript.challenge_scalar(b"challenge_Bz");
let r_C = transcript.challenge_scalar(b"challenge_Cz");

// r_A * comm_Az_claim + r_B * comm_Bz_claim + r_C * comm_Cz_claim;
let comm_claim_phase2 = GroupElement::vartime_multiscalar_mul(
Expand Down
2 changes: 1 addition & 1 deletion src/scalar/ristretto255.rs
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,7 @@ impl Scalar {
//
// and computing their sum in the field. It remains to see that arbitrary 256-bit
// numbers can be placed into Montgomery form safely using the reduction. The
// reduction works so long as the product is less than R=2^256 multipled by
// reduction works so long as the product is less than R=2^256 multiplied by
// the modulus. This holds because for any `c` smaller than the modulus, we have
// that (2^256 - 1)*c is an acceptable product for the reduction. Therefore, the
// reduction always works so long as `c` is in the field; in this case it is either the
Expand Down
2 changes: 1 addition & 1 deletion src/sparse_mlpoly.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ impl DerefsEvalProof {
proof_derefs
}

// evalues both polynomials at r and produces a joint proof of opening
// evaluates both polynomials at r and produces a joint proof of opening
pub fn prove(
derefs: &Derefs,
eval_row_ops_val_vec: &[Scalar],
Expand Down
8 changes: 4 additions & 4 deletions src/sumcheck.rs
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ impl SumcheckInstanceProof {
//derive the verifier's challenge for the next round
let r_j = transcript.challenge_scalar(b"challenge_nextround");
r.push(r_j);
// bound all tables to the verifier's challenege
// bound all tables to the verifier's challenge
poly_A.bound_poly_var_top(&r_j);
poly_B.bound_poly_var_top(&r_j);
poly_C.bound_poly_var_top(&r_j);
Expand Down Expand Up @@ -375,7 +375,7 @@ impl SumcheckInstanceProof {
let r_j = transcript.challenge_scalar(b"challenge_nextround");
r.push(r_j);

// bound all tables to the verifier's challenege
// bound all tables to the verifier's challenge
for (poly_A, poly_B) in poly_A_vec_par.iter_mut().zip(poly_B_vec_par.iter_mut()) {
poly_A.bound_poly_var_top(&r_j);
poly_B.bound_poly_var_top(&r_j);
Expand Down Expand Up @@ -481,7 +481,7 @@ impl ZKSumcheckInstanceProof {
//derive the verifier's challenge for the next round
let r_j = transcript.challenge_scalar(b"challenge_nextround");

// bound all tables to the verifier's challenege
// bound all tables to the verifier's challenge
poly_A.bound_poly_var_top(&r_j);
poly_B.bound_poly_var_top(&r_j);

Expand Down Expand Up @@ -669,7 +669,7 @@ impl ZKSumcheckInstanceProof {
//derive the verifier's challenge for the next round
let r_j = transcript.challenge_scalar(b"challenge_nextround");

// bound all tables to the verifier's challenege
// bound all tables to the verifier's challenge
poly_A.bound_poly_var_top(&r_j);
poly_B.bound_poly_var_top(&r_j);
poly_C.bound_poly_var_top(&r_j);
Expand Down
Loading