Skip to content

Commit 1ec99c0

Browse files
committed
Chore: stricter rules in compilation.
Deny warnings on unused variables and mut's.
1 parent 9a0c01d commit 1ec99c0

File tree

7 files changed

+21
-32
lines changed

7 files changed

+21
-32
lines changed

src/lib.rs

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,9 @@
1414
//! ## Note
1515
//!
1616
17-
extern crate serde;
17+
#![deny(unused_variables)]
18+
#![deny(unused_mut)]
1819

19-
#[doc(hidden)]
20-
#[macro_use]
21-
pub extern crate serde_derive;
22-
#[doc(hidden)]
23-
pub extern crate curve25519_dalek;
24-
#[doc(hidden)]
25-
pub extern crate merlin;
26-
#[doc(hidden)]
27-
pub extern crate rand;
2820

2921
pub use merlin::Transcript;
3022

src/macros.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,14 +104,14 @@ macro_rules! define_proof {
104104
/// statements from different proofs.
105105
#[allow(non_snake_case)]
106106
pub mod $proof_module_name {
107-
use $crate::curve25519_dalek::scalar::Scalar;
108-
use $crate::curve25519_dalek::ristretto::RistrettoPoint;
109-
use $crate::curve25519_dalek::ristretto::CompressedRistretto;
107+
use curve25519_dalek::scalar::Scalar;
108+
use curve25519_dalek::ristretto::RistrettoPoint;
109+
use curve25519_dalek::ristretto::CompressedRistretto;
110110

111111
use $crate::toolbox::prover::Prover;
112112
use $crate::toolbox::verifier::Verifier;
113113

114-
pub use $crate::merlin::Transcript;
114+
pub use merlin::Transcript;
115115
pub use $crate::{CompactProof, BatchableProof, ProofError};
116116

117117
/// The generated [`internal`] module contains lower-level

src/proofs.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use curve25519_dalek::ristretto::CompressedRistretto;
22
use curve25519_dalek::scalar::Scalar;
3+
use serde::{Deserialize, Serialize};
34

45
/// A Schnorr proof in compact format.
56
///

src/toolbox/sigma/transcript/keccak_transcript.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ where
165165
H: DuplexSpongeInterface
166166
{
167167
fn new(domain_sep: &[u8]) -> Self {
168-
let mut hasher = H::new(domain_sep);
168+
let hasher = H::new(domain_sep);
169169
let order = G::Scalar::cardinal();
170170
Self { order, hasher, _marker: Default::default() }
171171
}

tests/sage_test_vectors.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use bls12_381::G1Projective;
22
use rand::{Rng, CryptoRng};
3-
use group::{Group, GroupEncoding, ff::Field};
3+
use group::{Group, GroupEncoding};
44
use sigma_rs::toolbox::sigma::sage_test::{SRandom, TestDRNG};
55
use sigma_rs::toolbox::sigma::sage_test::custom_schnorr_proof::SchnorrProofCustom;
66

@@ -67,7 +67,7 @@ fn dleq<G: Group + GroupEncoding + SRandom>(
6767
morphismp.append_equation(var_X, &[(var_x, var_G)]);
6868
morphismp.append_equation(var_Y, &[(var_x, var_H)]);
6969

70-
assert!(vec![X, Y] == morphismp.morphism.evaluate(&[x]));
70+
assert!(vec![X, Y] == morphismp.morphism.evaluate(&[x]));
7171
(morphismp, vec![x])
7272
}
7373

@@ -91,7 +91,7 @@ fn pedersen_commitment<G: Group + GroupEncoding + SRandom>(
9191
morphismp.allocate_scalars(2);
9292
morphismp.allocate_elements(3);
9393
morphismp.set_elements(&[(var_H, H), (var_G, G), (var_C, C)]);
94-
morphismp.append_equation(var_C, &[(var_x, var_G), (var_r, var_H)]);
94+
morphismp.append_equation(var_C, &[(var_x, var_G), (var_r, var_H)]);
9595

9696
assert!(vec![C] == morphismp.morphism.evaluate(&witness));
9797
(morphismp, witness)
@@ -147,7 +147,7 @@ fn bbs_blind_commitment_computation<G: Group + GroupEncoding + SRandom>(
147147
let (Q_2, J_1, J_2, J_3) = (G::random(&mut *rng), G::random(&mut *rng), G::random(&mut *rng), G::random(&mut *rng));
148148
// BBS.messages_to_scalars(committed_messages, api_id)
149149
let (msg_1, msg_2, msg_3) = (G::srandom(&mut *rng), G::srandom(&mut *rng), G::srandom(&mut *rng));
150-
150+
151151
// these are computed before the proof in the specification
152152
let secret_prover_blind = G::srandom(&mut *rng);
153153
let C = Q_2*secret_prover_blind + J_1*msg_1 + J_2*msg_2 + J_3*msg_3;
@@ -156,22 +156,22 @@ fn bbs_blind_commitment_computation<G: Group + GroupEncoding + SRandom>(
156156
let (var_secret_prover_blind, var_msg_1, var_msg_2, var_msg_3) = (0, 1, 2, 3);
157157
let (var_Q_2, var_J_1, var_J_2, var_J_3) = (0, 1, 2, 3);
158158
let var_C = M+1;
159-
159+
160160
morphismp.allocate_scalars(M+1);
161161
morphismp.allocate_elements(M+1);
162162
morphismp.allocate_elements(1);
163163
morphismp.set_elements(&[(var_Q_2, Q_2), (var_J_1, J_1), (var_J_2, J_2), (var_J_3, J_3), (var_C, C)]);
164164

165165
morphismp.append_equation(var_C, &[(var_secret_prover_blind, var_Q_2), (var_msg_1, var_J_1), (var_msg_2, var_J_2), (var_msg_3, var_J_3)]);
166-
166+
167167
let witness = vec![secret_prover_blind, msg_1, msg_2, msg_3];
168168

169169
assert!(vec![C] == morphismp.morphism.evaluate(&witness));
170170
(morphismp, witness)
171171
}
172172

173173

174-
/// This part tests the implementation of the SigmaProtocol trait for the
174+
/// This part tests the implementation of the SigmaProtocol trait for the
175175
/// SchnorrProof structure as well as the Fiat-Shamir NISigmaProtocol transform
176176
#[allow(non_snake_case)]
177177
#[test]
@@ -184,7 +184,7 @@ fn NI_discrete_logarithm() {
184184
let protocol = SchnorrProofCustom { morphismp };
185185
let domain_sep: Vec<u8> = b"yellow submarineyellow submarine".to_vec();
186186
let mut nizk = NISigmaProtocol::<SigmaP, Codec, Gp>::new(&domain_sep, protocol);
187-
187+
188188
let proof_bytes = nizk.prove(&witness, &mut rng);
189189
let verified = nizk.verify(&proof_bytes).is_ok();
190190
assert!(verified, "Fiat-Shamir Schnorr proof verification failed");
@@ -202,7 +202,7 @@ fn NI_dleq() {
202202
let protocol = SchnorrProofCustom { morphismp };
203203
let domain_sep: Vec<u8> = b"yellow submarineyellow submarine".to_vec();
204204
let mut nizk = NISigmaProtocol::<SigmaP, Codec, Gp>::new(&domain_sep, protocol);
205-
205+
206206
let proof_bytes = nizk.prove(&witness, &mut rng);
207207
let verified = nizk.verify(&proof_bytes).is_ok();
208208
assert!(verified, "Fiat-Shamir Schnorr proof verification failed");
@@ -220,7 +220,7 @@ fn NI_pedersen_commitment() {
220220
let protocol = SchnorrProofCustom { morphismp };
221221
let domain_sep: Vec<u8> = b"yellow submarineyellow submarine".to_vec();
222222
let mut nizk = NISigmaProtocol::<SigmaP, Codec, Gp>::new(&domain_sep, protocol);
223-
223+
224224
let proof_bytes = nizk.prove(&witness, &mut rng);
225225
let verified = nizk.verify(&proof_bytes).is_ok();
226226
assert!(verified, "Fiat-Shamir Schnorr proof verification failed");
@@ -238,7 +238,7 @@ fn NI_pedersen_commitment_dleq() {
238238
let protocol = SchnorrProofCustom { morphismp };
239239
let domain_sep: Vec<u8> = b"yellow submarineyellow submarine".to_vec();
240240
let mut nizk = NISigmaProtocol::<SigmaP, Codec, Gp>::new(&domain_sep, protocol);
241-
241+
242242
let proof_bytes = nizk.prove(&witness, &mut rng);
243243
let verified = nizk.verify(&proof_bytes).is_ok();
244244
assert!(verified, "Fiat-Shamir Schnorr proof verification failed");
@@ -256,7 +256,7 @@ fn NI_bbs_blind_commitment_computation() {
256256
let protocol = SchnorrProofCustom { morphismp };
257257
let domain_sep: Vec<u8> = b"yellow submarineyellow submarine".to_vec();
258258
let mut nizk = NISigmaProtocol::<SigmaP, Codec, Gp>::new(&domain_sep, protocol);
259-
259+
260260
let proof_bytes = nizk.prove(&witness, &mut rng);
261261
let verified = nizk.verify(&proof_bytes).is_ok();
262262
assert!(verified, "Fiat-Shamir Schnorr proof verification failed");

tests/test_sponge.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
11
use num_bigint::BigUint;
22
use rand::RngCore;
3-
use bls12_381::{G1Projective, G1Affine};
43

54

65

76
use sigma_rs::toolbox::sigma::sage_test::TestDRNG;
87

9-
type Gp = G1Projective;
10-
type Ga = G1Affine;
11-
128
#[allow(non_snake_case)]
139
#[test]
1410
fn DRNG_testing() {

tests/testos.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ fn DRNG_testing() {
2929
#[allow(non_snake_case)]
3030
#[test]
3131
fn Scalar_test() {
32-
let mut rng = TestDRNG::new(b"hello world");
32+
let rng = TestDRNG::new(b"hello world");
3333
let y = <Gp as Group>::Scalar::random(rng);
3434
let ZERO = <Gp as Group>::Scalar::ZERO;
3535
let ONE = y * y.invert().unwrap();

0 commit comments

Comments
 (0)