Skip to content

Commit 068d8ce

Browse files
committed
- Created a NISigmaProtocol from a GroupMorphismPreimage (see the non_interactive_protocol.rs test)
- Fixed the group_morphism file name - Rest: Fixed the SigmaProtocol implementation for SchnorrProof
1 parent 9a4e76b commit 068d8ce

File tree

4 files changed

+18
-5
lines changed

4 files changed

+18
-5
lines changed
File renamed without changes.

src/toolbox/sigma/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
pub mod r#trait;
22
pub mod proof_composition;
33
pub mod fiat_shamir;
4-
pub mod group_mophism;
4+
pub mod group_morphism;
55
pub mod schnorr_proof;
66
pub mod transcript;
77

88
pub use r#trait::SigmaProtocol;
99
pub use proof_composition::{AndProtocol, OrProtocol};
1010
pub use fiat_shamir::NISigmaProtocol;
1111
pub use schnorr_proof::SchnorrProof;
12-
pub use group_mophism::GroupMorphismPreimage;
12+
pub use group_morphism::GroupMorphismPreimage;

src/toolbox/sigma/schnorr_proof.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ where
3232
) -> (Self::Commitment, Self::ProverState) {
3333
let mut nonces: Vec<G::Scalar> = Vec::new();
3434
for _i in 0..self.morphismp.morphism.num_scalars {
35-
nonces.push(<G as Group>::Scalar::random(rng));
35+
nonces.push(<G as Group>::Scalar::random(&mut *rng));
3636
}
3737
let prover_state = (nonces.clone(), witness.clone());
3838
let commitment = self.morphismp.morphism.evaluate(&nonces);
@@ -103,7 +103,7 @@ where
103103
for i in 0..scalar_nb {
104104
let start = i * point_size;
105105
let end = start + point_size;
106-
let mut buf = [0u8; point_size];
106+
let mut buf = vec![0u8; point_size];
107107
buf.copy_from_slice(&data[start..end]);
108108
let elem_ct = G::from_bytes(&buf);
109109
if !bool::from(elem_ct.is_some()) {

tests/non_interactive_protocol.rs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1+
use group::Group;
12
use rand::rngs::OsRng;
23
use curve25519_dalek::ristretto::RistrettoPoint;
34
use curve25519_dalek::scalar::Scalar;
45

6+
use lox_zkp::toolbox::sigma::group_mophism::GroupMorphismPreimage;
57
use lox_zkp::toolbox::sigma::schnorr_proof::SchnorrProof;
68
use lox_zkp::toolbox::sigma::transcript::transcriptcodec::KeccakTranscript;
79
use lox_zkp::toolbox::sigma::fiat_shamir::NISigmaProtocol;
@@ -20,7 +22,18 @@ fn fiat_shamir_schnorr_proof_ristretto() {
2022
let w = Scalar::random(&mut rng);
2123
let H = G * w;
2224

23-
let protocol = SchnorrProof { generator: G, target: H };
25+
let morphismp: GroupMorphismPreimage<RistrettoPoint> = GroupMorphismPreimage::new();
26+
27+
// Scalars and Points bases settings
28+
morphismp.allocate_scalars(1);
29+
morphismp.allocate_elements(1);
30+
morphismp.set_elements(&[(0, G)]);
31+
32+
// The H = z * G equeation where z is the unique scalar variable
33+
morphismp.append_equation(H, &[(0, 0)]);
34+
35+
// The SigmaProtocol induced by morphismp
36+
let protocol = SchnorrProof { morphismp };
2437

2538
// Fiat-Shamir wrapper
2639
let mut nizk = NISigmaProtocol::<_, KeccakTranscript<G>, G>::new(domain_sep, protocol);

0 commit comments

Comments
 (0)