Skip to content

Commit 0be6685

Browse files
committed
Fix non_interactive_protocol.rs test (Rest: correctness)
1 parent 389bfb3 commit 0be6685

File tree

3 files changed

+13
-7
lines changed

3 files changed

+13
-7
lines changed

src/toolbox/sigma/fiat_shamir.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use group::Group;
77
pub struct NISigmaProtocol<P, C, G>
88
where
99
G: Group,
10-
P: SigmaProtocol<Commitment = G, Challenge = <G as Group>::Scalar>,
10+
P: SigmaProtocol<Commitment = Vec<G>, Challenge = <G as Group>::Scalar>,
1111
C: TranscriptCodec<G>,
1212
{
1313
domain_sep: Vec<u8>,
@@ -19,7 +19,7 @@ where
1919
impl<P, C, G> NISigmaProtocol<P, C, G>
2020
where
2121
G: Group,
22-
P: SigmaProtocol<Commitment = G, Challenge = <G as Group>::Scalar>,
22+
P: SigmaProtocol<Commitment = Vec<G>, Challenge = <G as Group>::Scalar>,
2323
C: TranscriptCodec<G>,
2424
{
2525
// Create new NIZK transformator.
@@ -41,8 +41,9 @@ where
4141
// Fiat Shamir challenge
4242
let challenge = self
4343
.hash_state
44-
.prover_message(&[commitment])
44+
.prover_message(&commitment)
4545
.verifier_challenge();
46+
println!("Prover's challenge : {:?}", challenge);
4647
// Prouver's response
4748
let response = self.sigmap.prover_response(&prover_state, &challenge);
4849
// Local verification of the proof
@@ -58,8 +59,9 @@ where
5859
// Recompute the challenge
5960
let challenge = self
6061
.hash_state
61-
.prover_message(&[commitment])
62+
.prover_message(&commitment)
6263
.verifier_challenge();
64+
println!("Verifier's challenge : {:?}", challenge);
6365
// Verification of the proof
6466
self.sigmap.verifier(&commitment, &challenge, &response)
6567

src/toolbox/sigma/schnorr_proof.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ where
7373
) -> Vec<u8> {
7474
let mut bytes = Vec::new();
7575
let scalar_nb = self.morphismp.morphism.num_scalars.clone();
76-
// Serialize commitmens
76+
// Serialize commitments
7777
for i in 0..scalar_nb {
7878
bytes.extend_from_slice(commitment[i].to_bytes().as_ref());
7979
}

tests/non_interactive_protocol.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,17 @@ fn fiat_shamir_schnorr_proof_ristretto() {
2121
let w = Scalar::random(&mut rng);
2222
let H = G * w;
2323

24-
let morphismp: GroupMorphismPreimage<RistrettoPoint> = GroupMorphismPreimage::new();
24+
let mut morphismp: GroupMorphismPreimage<RistrettoPoint> = GroupMorphismPreimage::new();
2525

2626
// Scalars and Points bases settings
2727
morphismp.allocate_scalars(1);
2828
morphismp.allocate_elements(1);
2929
morphismp.set_elements(&[(0, G)]);
3030

31+
// Set the witness Vec
32+
let mut witness = Vec::new();
33+
witness.push(w.clone());
34+
3135
// The H = z * G equeation where z is the unique scalar variable
3236
morphismp.append_equation(H, &[(0, 0)]);
3337

@@ -38,7 +42,7 @@ fn fiat_shamir_schnorr_proof_ristretto() {
3842
let mut nizk = NISigmaProtocol::<SchnorrProof<G>, KeccakTranscript<G>, G>::new(domain_sep, protocol);
3943

4044
// Prove
41-
let proof_bytes = nizk.prove(&w, &mut rng);
45+
let proof_bytes = nizk.prove(&witness, &mut rng);
4246

4347
// Verify
4448
let verified = nizk.verify(&proof_bytes);

0 commit comments

Comments
 (0)