Skip to content

Commit 7e8cc9f

Browse files
authored
Introduce typo checking to CI (#84)
* introduce spell check in CI * fix typos automatically * rename * rename * small fixes * small fixes * fix CI * fix CI * fix CI * fix CI
1 parent 2b791bd commit 7e8cc9f

File tree

8 files changed

+132
-52
lines changed

8 files changed

+132
-52
lines changed

.github/workflows/rust.yml

+113-36
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
name: Build and Test Spartan
22

3+
permissions:
4+
contents: read
5+
pull-requests: write
6+
37
on:
48
push:
59
branches: [ master ]
@@ -10,39 +14,112 @@ jobs:
1014
build:
1115
runs-on: ubuntu-latest
1216
steps:
13-
- uses: actions/checkout@v2
14-
- name: Install
15-
run: rustup default stable
16-
- name: Install rustfmt Components
17-
run: rustup component add rustfmt
18-
- name: Install clippy
19-
run: rustup component add clippy
20-
- name: Build
21-
run: cargo build --verbose
22-
- name: Run tests
23-
run: cargo test --verbose
24-
- name: Build examples
25-
run: cargo build --examples --verbose
26-
- name: Check Rustfmt Code Style
27-
run: cargo fmt --all -- --check
28-
- name: Check clippy warnings
29-
run: cargo clippy --all-targets --all-features -- -D warnings
30-
31-
build_wasm:
32-
runs-on: ubuntu-latest
33-
steps:
34-
- uses: actions/checkout@v2
35-
- name: Install
36-
run: rustup default stable
37-
- name: Build without std
38-
run: cargo build --no-default-features --verbose
39-
- name: Run tests without std
40-
run: cargo test --no-default-features --verbose
41-
- name: Build examples without std
42-
run: cargo build --examples --no-default-features --verbose
43-
- name: Install wasm32-wasi target
44-
run: rustup target add wasm32-wasi
45-
- name: Install wasm32-unknown-unknown target
46-
run: rustup target add wasm32-unknown-unknown
47-
- name: Build for target wasm-wasi
48-
run: RUSTFLAGS="" cargo build --target=wasm32-wasi --no-default-features --verbose
17+
- uses: actions/checkout@v2
18+
- name: Build
19+
uses: actions-rs/toolchain@v1
20+
with:
21+
toolchain: stable
22+
- uses: actions-rs/cargo@v1
23+
with:
24+
command: build
25+
args: --examples --benches --verbose
26+
27+
build-no-default-features:
28+
runs-on: ubuntu-latest
29+
steps:
30+
- uses: actions/checkout@v2
31+
- name: Build
32+
uses: actions-rs/toolchain@v1
33+
with:
34+
toolchain: stable
35+
- uses: actions-rs/cargo@v1
36+
with:
37+
command: build
38+
args: --no-default-features --examples --benches --verbose
39+
40+
build-wasm:
41+
runs-on: ubuntu-latest
42+
steps:
43+
- uses: actions/checkout@v2
44+
- name: Wasm build
45+
uses: actions-rs/toolchain@v1
46+
with:
47+
toolchain: stable
48+
target: wasm32-unknown-unknown
49+
- uses: actions-rs/cargo@v1
50+
with:
51+
command: build
52+
args: --no-default-features --target wasm32-unknown-unknown
53+
54+
build-wasi:
55+
runs-on: ubuntu-latest
56+
steps:
57+
- uses: actions/checkout@v2
58+
- name: Install wasm32-wasip1 target
59+
run: rustup target add wasm32-wasip1
60+
- uses: actions-rs/cargo@v1
61+
with:
62+
command: build
63+
args: --no-default-features --target wasm32-wasip1
64+
65+
test:
66+
runs-on: ubuntu-latest
67+
steps:
68+
- uses: actions/checkout@v2
69+
- name: Run tests
70+
uses: actions-rs/toolchain@v1
71+
with:
72+
toolchain: stable
73+
- uses: actions-rs/cargo@v1
74+
with:
75+
command: test
76+
args: --release --verbose
77+
78+
test-no-default-features:
79+
runs-on: ubuntu-latest
80+
steps:
81+
- uses: actions/checkout@v2
82+
- name: Run tests
83+
uses: actions-rs/toolchain@v1
84+
with:
85+
toolchain: stable
86+
- uses: actions-rs/cargo@v1
87+
with:
88+
command: test
89+
args: --no-default-features --release --verbose
90+
91+
fmt:
92+
runs-on: ubuntu-latest
93+
steps:
94+
- uses: actions/checkout@v2
95+
- name: Check Rustfmt Code Style
96+
uses: actions-rs/toolchain@v1
97+
with:
98+
toolchain: stable
99+
components: rustfmt
100+
- uses: actions-rs/cargo@v1
101+
with:
102+
command: fmt
103+
args: --all -- --check
104+
105+
clippy:
106+
runs-on: ubuntu-latest
107+
steps:
108+
- uses: actions/checkout@v2
109+
- name: Check clippy warnings
110+
uses: actions-rs/toolchain@v1
111+
with:
112+
toolchain: stable
113+
components: clippy
114+
- uses: actions-rs/cargo@v1
115+
with:
116+
command: clippy
117+
args: --all-targets -- -D warnings
118+
119+
spelling:
120+
runs-on: ubuntu-latest
121+
steps:
122+
- name: Checkout Actions Repository
123+
uses: actions/checkout@v3
124+
- name: Spell Check Repo
125+
uses: crate-ci/typos@685eb3d55be2f85191e8c84acb9f44d7756f84ab

Cargo.toml

+6-2
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ curve25519-dalek = { version = "4.1.1", features = [
1717
"rand_core",
1818
], default-features = false }
1919
merlin = { version = "3.0.0", default-features = false }
20-
rand = "0.8"
21-
rand_core = { version = "0.6", default-features = false, features = ["getrandom"] }
20+
rand = "0.8.5"
21+
rand_core = { version = "0.6", default-features = false }
2222
digest = { version = "0.8.1", default-features = false }
2323
sha3 = { version = "0.8.2", default-features = false }
2424
byteorder = { version = "1.3.4", default-features = false }
@@ -30,8 +30,12 @@ itertools = { version = "0.10.0", default-features = false }
3030
colored = { version = "2.0.0", default-features = false, optional = true }
3131
flate2 = { version = "1.0.14" }
3232

33+
[target.'cfg(target_arch = "wasm32")'.dependencies]
34+
getrandom = { version = "0.2.15", default-features = false, features = ["js"] }
35+
3336
[dev-dependencies]
3437
criterion = "0.3.1"
38+
typos = "0.10.33"
3539

3640
[lib]
3741
name = "libspartan"

src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ extern crate core;
88
extern crate curve25519_dalek;
99
extern crate digest;
1010
extern crate merlin;
11-
extern crate rand;
1211
extern crate sha3;
1312

1413
#[cfg(feature = "multicore")]

src/product_tree.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ impl ProductCircuitEvalProofBatched {
272272
.collect::<Vec<Scalar>>();
273273
let mut rand = Vec::new();
274274
for layer_id in (0..num_layers).rev() {
275-
// prepare paralell instance that share poly_C first
275+
// prepare parallel instance that share poly_C first
276276
let len = prod_circuit_vec[0].left_vec[layer_id].len()
277277
+ prod_circuit_vec[0].right_vec[layer_id].len();
278278

src/r1csproof.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -263,9 +263,9 @@ impl R1CSProof {
263263

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

@@ -418,9 +418,9 @@ impl R1CSProof {
418418
)?;
419419

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

425425
// r_A * comm_Az_claim + r_B * comm_Bz_claim + r_C * comm_Cz_claim;
426426
let comm_claim_phase2 = GroupElement::vartime_multiscalar_mul(

src/scalar/ristretto255.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -454,7 +454,7 @@ impl Scalar {
454454
//
455455
// and computing their sum in the field. It remains to see that arbitrary 256-bit
456456
// numbers can be placed into Montgomery form safely using the reduction. The
457-
// reduction works so long as the product is less than R=2^256 multipled by
457+
// reduction works so long as the product is less than R=2^256 multiplied by
458458
// the modulus. This holds because for any `c` smaller than the modulus, we have
459459
// that (2^256 - 1)*c is an acceptable product for the reduction. Therefore, the
460460
// reduction always works so long as `c` is in the field; in this case it is either the

src/sparse_mlpoly.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ impl DerefsEvalProof {
122122
proof_derefs
123123
}
124124

125-
// evalues both polynomials at r and produces a joint proof of opening
125+
// evaluates both polynomials at r and produces a joint proof of opening
126126
pub fn prove(
127127
derefs: &Derefs,
128128
eval_row_ops_val_vec: &[Scalar],

src/sumcheck.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ impl SumcheckInstanceProof {
236236
//derive the verifier's challenge for the next round
237237
let r_j = transcript.challenge_scalar(b"challenge_nextround");
238238
r.push(r_j);
239-
// bound all tables to the verifier's challenege
239+
// bound all tables to the verifier's challenge
240240
poly_A.bound_poly_var_top(&r_j);
241241
poly_B.bound_poly_var_top(&r_j);
242242
poly_C.bound_poly_var_top(&r_j);
@@ -375,7 +375,7 @@ impl SumcheckInstanceProof {
375375
let r_j = transcript.challenge_scalar(b"challenge_nextround");
376376
r.push(r_j);
377377

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

484-
// bound all tables to the verifier's challenege
484+
// bound all tables to the verifier's challenge
485485
poly_A.bound_poly_var_top(&r_j);
486486
poly_B.bound_poly_var_top(&r_j);
487487

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

672-
// bound all tables to the verifier's challenege
672+
// bound all tables to the verifier's challenge
673673
poly_A.bound_poly_var_top(&r_j);
674674
poly_B.bound_poly_var_top(&r_j);
675675
poly_C.bound_poly_var_top(&r_j);

0 commit comments

Comments
 (0)