Skip to content

Commit 6d48643

Browse files
committed
refactor(naming): rename SchnorrProof to SchnorrProtocol
- refactor: change structure name from 'SchnorrProof' to 'SchnorrProtocol' to better reflect its actual function and purpose
1 parent be99bf3 commit 6d48643

File tree

5 files changed

+32
-32
lines changed

5 files changed

+32
-32
lines changed

src/proof_builder.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
//! This module defines the [`ProofBuilder`] struct, a high-level utility that simplifies
44
//! the construction and interaction with zero-knowledge proofs based on Sigma protocols.
55
//!
6-
//! It abstracts over the underlying Schnorr proof, Fiat-Shamir transformation,
6+
//! It abstracts over the underlying Schnorr protocol, Fiat-Shamir transformation,
77
//! and serialization concerns, making it easier to create proofs from linear
88
//! relations over cryptographic groups.
99
//!
@@ -18,12 +18,12 @@ use rand::{CryptoRng, RngCore};
1818

1919
use crate::{
2020
codec::ShakeCodec, serialisation::GroupSerialisation, GroupMorphismPreimage, NISigmaProtocol,
21-
PointVar, ProofError, ScalarVar, SchnorrProof,
21+
PointVar, ProofError, ScalarVar, SchnorrProtocol,
2222
};
2323

2424
/// A builder that helps construct Sigma proofs for linear group relations.
2525
///
26-
/// This struct wraps a [`SchnorrProof`] over a [`GroupMorphismPreimage`] and applies
26+
/// This struct wraps a [`SchnorrProtocol`] over a [`GroupMorphismPreimage`] and applies
2727
/// the Fiat-Shamir transform via [`NISigmaProtocol`]. It provides a user-friendly API
2828
/// for allocating variables, defining statements, and generating proofs.
2929
///
@@ -34,7 +34,7 @@ where
3434
G: Group + GroupSerialisation,
3535
{
3636
/// The underlying Sigma protocol instance with Fiat-Shamir transformation applied.
37-
pub protocol: NISigmaProtocol<SchnorrProof<G>, ShakeCodec<G>, G>,
37+
pub protocol: NISigmaProtocol<SchnorrProtocol<G>, ShakeCodec<G>, G>,
3838
}
3939

4040
impl<G> ProofBuilder<G>
@@ -44,9 +44,9 @@ where
4444
{
4545
/// Creates a new proof builder with a Schnorr protocol instance using the given domain separator.
4646
pub fn new(domain_sep: &[u8]) -> Self {
47-
let schnorr_proof = SchnorrProof(GroupMorphismPreimage::<G>::new());
47+
let schnorr_proof = SchnorrProtocol(GroupMorphismPreimage::<G>::new());
4848
let protocol =
49-
NISigmaProtocol::<SchnorrProof<G>, ShakeCodec<G>, G>::new(domain_sep, schnorr_proof);
49+
NISigmaProtocol::<SchnorrProtocol<G>, ShakeCodec<G>, G>::new(domain_sep, schnorr_proof);
5050
Self { protocol }
5151
}
5252

src/schnorr_proof.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//! Implementation of the generic Schnorr Sigma Protocol over a group `G`.
22
//!
3-
//! This module defines the [`SchnorrProof`] structure, which implements
3+
//! This module defines the [`SchnorrProtocol`] structure, which implements
44
//! a Sigma protocol proving different types of discrete logarithm relations (eg. Schnorr, Pedersen's commitments)
55
//! through a group morphism abstraction (see Maurer09).
66
@@ -16,11 +16,11 @@ use rand::{CryptoRng, Rng};
1616
/// A Schnorr protocol proving knowledge some discrete logarithm relation.
1717
///
1818
/// The specific proof instance is defined by a [`GroupMorphismPreimage`] over a group `G`.
19-
pub struct SchnorrProof<G: Group + GroupEncoding + GroupSerialisation>(
19+
pub struct SchnorrProtocol<G: Group + GroupEncoding + GroupSerialisation>(
2020
pub GroupMorphismPreimage<G>,
2121
);
2222

23-
impl<G> SigmaProtocol for SchnorrProof<G>
23+
impl<G> SigmaProtocol for SchnorrProtocol<G>
2424
where
2525
G: Group + GroupEncoding + GroupSerialisation,
2626
{
@@ -147,7 +147,7 @@ where
147147
}
148148
}
149149

150-
impl<G> CompactProtocol for SchnorrProof<G>
150+
impl<G> CompactProtocol for SchnorrProtocol<G>
151151
where
152152
G: Group + GroupEncoding + GroupSerialisation,
153153
{

tests/morphism_test.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use rand::{
66
};
77

88
use sigma_rs::{
9-
codec::ShakeCodec, group_morphism::msm_pr, GroupMorphismPreimage, NISigmaProtocol, SchnorrProof,
9+
codec::ShakeCodec, group_morphism::msm_pr, GroupMorphismPreimage, NISigmaProtocol, SchnorrProtocol,
1010
};
1111

1212
type G = G1Projective;
@@ -222,18 +222,18 @@ fn test_bbs_blind_commitment_computation() {
222222
}
223223

224224
/// This part tests the implementation of the SigmaProtocol trait for the
225-
/// SchnorrProof structure as well as the Fiat-Shamir NISigmaProtocol transform
225+
/// SchnorrProtocol structure as well as the Fiat-Shamir NISigmaProtocol transform
226226
#[allow(non_snake_case)]
227227
#[test]
228228
fn NI_discrete_logarithm() {
229229
let mut rng = OsRng;
230230
let (morphismp, witness) = discrete_logarithm::<G>(&mut rng);
231231

232232
// The SigmaProtocol induced by morphismp
233-
let protocol = SchnorrProof(morphismp);
233+
let protocol = SchnorrProtocol(morphismp);
234234
// Fiat-Shamir wrapper
235235
let domain_sep = b"test-fiat-shamir-schnorr";
236-
let mut nizk = NISigmaProtocol::<SchnorrProof<G>, ShakeCodec<G>, G>::new(domain_sep, protocol);
236+
let mut nizk = NISigmaProtocol::<SchnorrProtocol<G>, ShakeCodec<G>, G>::new(domain_sep, protocol);
237237

238238
// Batchable and compact proofs
239239
let proof_batchable_bytes = nizk.prove_batchable(&witness, &mut rng);
@@ -258,10 +258,10 @@ fn NI_dleq() {
258258
let (morphismp, witness) = dleq::<G>(&mut rng);
259259

260260
// The SigmaProtocol induced by morphismp
261-
let protocol = SchnorrProof(morphismp);
261+
let protocol = SchnorrProtocol(morphismp);
262262
// Fiat-Shamir wrapper
263263
let domain_sep = b"test-fiat-shamir-DLEQ";
264-
let mut nizk = NISigmaProtocol::<SchnorrProof<G>, ShakeCodec<G>, G>::new(domain_sep, protocol);
264+
let mut nizk = NISigmaProtocol::<SchnorrProtocol<G>, ShakeCodec<G>, G>::new(domain_sep, protocol);
265265

266266
// Batchable and compact proofs
267267
let proof_batchable_bytes = nizk.prove_batchable(&witness, &mut rng);
@@ -286,10 +286,10 @@ fn NI_pedersen_commitment() {
286286
let (morphismp, witness) = pedersen_commitment::<G>(&mut rng);
287287

288288
// The SigmaProtocol induced by morphismp
289-
let protocol = SchnorrProof(morphismp);
289+
let protocol = SchnorrProtocol(morphismp);
290290
// Fiat-Shamir wrapper
291291
let domain_sep = b"test-fiat-shamir-pedersen-commitment";
292-
let mut nizk = NISigmaProtocol::<SchnorrProof<G>, ShakeCodec<G>, G>::new(domain_sep, protocol);
292+
let mut nizk = NISigmaProtocol::<SchnorrProtocol<G>, ShakeCodec<G>, G>::new(domain_sep, protocol);
293293

294294
// Batchable and compact proofs
295295
let proof_batchable_bytes = nizk.prove_batchable(&witness, &mut rng);
@@ -314,10 +314,10 @@ fn NI_pedersen_commitment_dleq() {
314314
let (morphismp, witness) = pedersen_commitment_dleq::<G>(&mut rng);
315315

316316
// The SigmaProtocol induced by morphismp
317-
let protocol = SchnorrProof(morphismp);
317+
let protocol = SchnorrProtocol(morphismp);
318318
// Fiat-Shamir wrapper
319319
let domain_sep = b"test-fiat-shamir-pedersen-commitment-DLEQ";
320-
let mut nizk = NISigmaProtocol::<SchnorrProof<G>, ShakeCodec<G>, G>::new(domain_sep, protocol);
320+
let mut nizk = NISigmaProtocol::<SchnorrProtocol<G>, ShakeCodec<G>, G>::new(domain_sep, protocol);
321321

322322
// Batchable and compact proofs
323323
let proof_batchable_bytes = nizk.prove_batchable(&witness, &mut rng);
@@ -342,10 +342,10 @@ fn NI_bbs_blind_commitment_computation() {
342342
let (morphismp, witness) = bbs_blind_commitment_computation::<G>(&mut rng);
343343

344344
// The SigmaProtocol induced by morphismp
345-
let protocol = SchnorrProof(morphismp);
345+
let protocol = SchnorrProtocol(morphismp);
346346
// Fiat-Shamir wrapper
347347
let domain_sep = b"test-fiat-shamir-bbs-blind-commitment-computation";
348-
let mut nizk = NISigmaProtocol::<SchnorrProof<G>, ShakeCodec<G>, G>::new(domain_sep, protocol);
348+
let mut nizk = NISigmaProtocol::<SchnorrProtocol<G>, ShakeCodec<G>, G>::new(domain_sep, protocol);
349349

350350
// Batchable and compact proofs
351351
let proof_batchable_bytes = nizk.prove_batchable(&witness, &mut rng);

tests/spec/custom_schnorr_proof.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@ use sigma_rs::{
88

99
use crate::random::SRandom;
1010

11-
pub struct SchnorrProofCustom<G>
11+
pub struct SchnorrProtocolCustom<G>
1212
where
1313
G: SRandom + GroupEncoding + GroupSerialisation,
1414
{
1515
pub morphismp: GroupMorphismPreimage<G>,
1616
}
1717

18-
impl<G> SigmaProtocol for SchnorrProofCustom<G>
18+
impl<G> SigmaProtocol for SchnorrProtocolCustom<G>
1919
where
2020
G: SRandom + GroupEncoding + GroupSerialisation,
2121
{

tests/spec/sage_test_vectors.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@ use sigma_rs::{
99
GroupMorphismPreimage, NISigmaProtocol,
1010
};
1111

12-
use crate::{custom_schnorr_proof::SchnorrProofCustom, random::SRandom, test_drng::TestDRNG};
12+
use crate::{custom_schnorr_proof::SchnorrProtocolCustom, random::SRandom, test_drng::TestDRNG};
1313

1414
type Preimage<G> = GroupMorphismPreimage<G>;
1515

1616
type Gp = G1Projective;
1717
type Codec = ByteSchnorrCodec<Gp, KeccakDuplexSponge>;
18-
type SigmaP = SchnorrProofCustom<Gp>;
18+
type SigmaP = SchnorrProtocolCustom<Gp>;
1919
type NISigmaP = NISigmaProtocol<SigmaP, Codec, Gp>;
2020

2121
#[allow(non_snake_case)]
@@ -192,13 +192,13 @@ fn bbs_blind_commitment_computation<G: Group + GroupEncoding + SRandom>(
192192
}
193193

194194
/// This part tests the implementation of the SigmaProtocol trait for the
195-
/// SchnorrProof structure as well as the Fiat-Shamir NISigmaProtocol transform
195+
/// SchnorrProtocol structure as well as the Fiat-Shamir NISigmaProtocol transform
196196
#[allow(non_snake_case)]
197197
fn NI_discrete_logarithm(seed: &[u8], context: &[u8]) -> (Vec<Scalar>, Vec<u8>) {
198198
let mut rng = TestDRNG::new(seed);
199199
let (morphismp, witness) = discrete_logarithm::<Gp>(&mut rng);
200200

201-
let protocol = SchnorrProofCustom { morphismp };
201+
let protocol = SchnorrProtocolCustom { morphismp };
202202
let domain_sep: Vec<u8> = context.to_vec();
203203
let mut nizk = NISigmaP::new(&domain_sep, protocol);
204204

@@ -213,7 +213,7 @@ fn NI_dleq(seed: &[u8], context: &[u8]) -> (Vec<Scalar>, Vec<u8>) {
213213
let mut rng = TestDRNG::new(seed);
214214
let (morphismp, witness) = dleq::<Gp>(&mut rng);
215215

216-
let protocol = SchnorrProofCustom { morphismp };
216+
let protocol = SchnorrProtocolCustom { morphismp };
217217
let domain_sep: Vec<u8> = context.to_vec();
218218
let mut nizk = NISigmaP::new(&domain_sep, protocol);
219219

@@ -228,7 +228,7 @@ fn NI_pedersen_commitment(seed: &[u8], context: &[u8]) -> (Vec<Scalar>, Vec<u8>)
228228
let mut rng = TestDRNG::new(seed);
229229
let (morphismp, witness) = pedersen_commitment::<Gp>(&mut rng);
230230

231-
let protocol = SchnorrProofCustom { morphismp };
231+
let protocol = SchnorrProtocolCustom { morphismp };
232232
let domain_sep: Vec<u8> = context.to_vec();
233233
let mut nizk = NISigmaP::new(&domain_sep, protocol);
234234

@@ -243,7 +243,7 @@ fn NI_pedersen_commitment_dleq(seed: &[u8], context: &[u8]) -> (Vec<Scalar>, Vec
243243
let mut rng = TestDRNG::new(seed);
244244
let (morphismp, witness) = pedersen_commitment_dleq::<Gp>(&mut rng);
245245

246-
let protocol = SchnorrProofCustom { morphismp };
246+
let protocol = SchnorrProtocolCustom { morphismp };
247247
let domain_sep: Vec<u8> = context.to_vec();
248248
let mut nizk = NISigmaP::new(&domain_sep, protocol);
249249

@@ -258,7 +258,7 @@ fn NI_bbs_blind_commitment_computation(seed: &[u8], context: &[u8]) -> (Vec<Scal
258258
let mut rng = TestDRNG::new(seed);
259259
let (morphismp, witness) = bbs_blind_commitment_computation::<Gp>(&mut rng);
260260

261-
let protocol = SchnorrProofCustom { morphismp };
261+
let protocol = SchnorrProtocolCustom { morphismp };
262262
let domain_sep: Vec<u8> = context.to_vec();
263263
let mut nizk = NISigmaP::new(&domain_sep, protocol);
264264

0 commit comments

Comments
 (0)