Skip to content

Commit 6d7d834

Browse files
committed
test(composition): implement serialization tests for AND/OR proofs
- test: add serialization and deserialization tests for AND/OR composition proofs using SchnorrProtocol - refactor: reorganize Sage test vectors into a consistent list for improved automated verification
1 parent 1adde78 commit 6d7d834

File tree

5 files changed

+128
-211
lines changed

5 files changed

+128
-211
lines changed

src/proof_composition.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ pub enum OrEnum<L, R> {
176176
Right(R),
177177
}
178178

179-
/// Internal state for a simulated transcription in an OR proof.
179+
/// Internal state for a simulated transcript in an OR proof.
180180
pub struct OrState<P: SigmaProtocol>(P::Challenge, P::Response);
181181

182182
/// Enum to describe which side (left or right) is simulated in an OR proof.
@@ -202,7 +202,7 @@ where
202202
usize,
203203
OrEnum<P::ProverState, Q::ProverState>,
204204
OrTranscription<P, Q>,
205-
); // ProverState = (real index, real prover state = (r, &real witness), fake transcription)
205+
); // ProverState = (real index, real prover state = (r, &real witness), fake transcript)
206206
type Response = (P::Challenge, P::Response, Q::Response);
207207
type Witness = (usize, OrEnum<P::Witness, Q::Witness>); // Index of the real witness, and Enum to wrap the real witness
208208
type Challenge = P::Challenge;
@@ -216,7 +216,7 @@ where
216216
let (r_index, r_witness_w) = witness;
217217
match r_witness_w {
218218
OrEnum::Left(ref r_witness) => {
219-
let f_trnsc = self.protocol1.simulate_transcription(rng);
219+
let f_trnsc = self.protocol1.simulate_transcript(rng);
220220
let ST = OrState(f_trnsc.1, f_trnsc.2);
221221
let (commit, r_pr_st) = self.protocol0.prover_commit(r_witness, rng);
222222
(
@@ -225,7 +225,7 @@ where
225225
)
226226
}
227227
OrEnum::Right(ref r_witness) => {
228-
let f_trnsc = self.protocol0.simulate_transcription(rng);
228+
let f_trnsc = self.protocol0.simulate_transcript(rng);
229229
let ST = OrState(f_trnsc.1, f_trnsc.2);
230230
let (commit, r_pr_st) = self.protocol1.prover_commit(r_witness, rng);
231231
(
@@ -241,7 +241,7 @@ where
241241
state: Self::ProverState,
242242
challenge: &Self::Challenge,
243243
) -> Self::Response {
244-
// let state = (real index, real prover state, fakee transcription)
244+
// let state = (real index, real prover state, fake transcript)
245245
let (_, r_pr_st, f_trnsc) = state;
246246

247247
// Compute the real challenge
@@ -259,7 +259,7 @@ where
259259
let r_response = self.protocol1.prover_response(r_prover_state, &r_challenge);
260260
(f_ch, f_response.clone(), r_response)
261261
}
262-
_ => panic!("Incoherence between real prover state and fake transcription"),
262+
_ => panic!("Incoherence between real prover state and fake transcript"),
263263
}
264264
}
265265

src/schnorr_protocol.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ where
237237
(commitment, response)
238238
}
239239

240-
fn simulate_transcription(
240+
fn simulate_transcript(
241241
&self,
242242
rng: &mut (impl RngCore + CryptoRng),
243243
) -> (Self::Commitment, Self::Challenge, Self::Response) {

src/trait.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ pub trait SigmaProtocol {
4848
challenge: &Self::Challenge,
4949
) -> Self::Response;
5050

51-
/// Verifies a Sigma protocol transcription.
51+
/// Verifies a Sigma protocol transcript.
5252
///
5353
/// Returns:
5454
/// - `Ok(())` if the verification succeeds.
@@ -60,7 +60,7 @@ pub trait SigmaProtocol {
6060
response: &Self::Response,
6161
) -> Result<(), ProofError>;
6262

63-
/// Serializes a proof transcription (commitment, challenge, response) to bytes batchable proof.
63+
/// Serializes a proof transcript (commitment, challenge, response) to bytes batchable proof.
6464
fn serialize_batchable(
6565
&self,
6666
_commitment: &Self::Commitment,
@@ -94,7 +94,7 @@ pub trait SigmaProtocol {
9494
/// Types implementing `CompactProtocol` must define:
9595
/// - `get_commitment`
9696
pub trait CompactProtocol: SigmaProtocol {
97-
/// Returns the commitment for which ('commitment', 'challenge', 'response') is a valid transcription
97+
/// Returns the commitment for which ('commitment', 'challenge', 'response') is a valid transcript
9898
///
9999
/// This function allows to omit commitment in compact proofs of the type ('challenge', 'response')
100100
fn get_commitment(
@@ -103,7 +103,7 @@ pub trait CompactProtocol: SigmaProtocol {
103103
response: &Self::Response,
104104
) -> Self::Commitment;
105105

106-
/// Serializes a proof transcription (commitment, challenge, response) to bytes compact proof.
106+
/// Serializes a proof transcript (commitment, challenge, response) to bytes compact proof.
107107
fn serialize_compact(
108108
&self,
109109
_commitment: &Self::Commitment,
@@ -128,17 +128,17 @@ pub trait CompactProtocol: SigmaProtocol {
128128
}
129129
}
130130

131-
/// A trait defining the behavior of a Sigma protocol for which simulation of transcriptions is necessary.
131+
/// A trait defining the behavior of a Sigma protocol for which simulation of transcripts is necessary.
132132
///
133-
/// All Sigma protocols can technically simulate a valid transcription, but this mostly serve to prove the security of the protocol and is not used in the real protocol execution.
133+
/// All Sigma protocols can technically simulate a valid transcript, but this mostly serve to prove the security of the protocol and is not used in the real protocol execution.
134134
/// However, some protocols (like OR protocols that prove the truth of one-out-of-two statements) require them during for the real execution.
135135
///
136136
/// ## Minimal Implementation
137137
/// Types implementing `SigmaProtocolSimulator` must define:
138138
/// - `simulate_proof`
139-
/// - `simulate_transcription`
139+
/// - `simulate_transcript`
140140
pub trait SigmaProtocolSimulator: SigmaProtocol {
141-
/// Simulates a protocol transcription given a challenge.
141+
/// Simulates a protocol transcript given a challenge.
142142
///
143143
/// This serves to create zero-knowledge simulations without access to a witness.
144144
fn simulate_proof(
@@ -147,8 +147,8 @@ pub trait SigmaProtocolSimulator: SigmaProtocol {
147147
rng: &mut (impl Rng + CryptoRng),
148148
) -> (Self::Commitment, Self::Response);
149149

150-
/// Simulates an entire protocol transcription.
151-
fn simulate_transcription(
150+
/// Simulates an entire protocol transcript.
151+
fn simulate_transcript(
152152
&self,
153153
rng: &mut (impl Rng + CryptoRng),
154154
) -> (Self::Commitment, Self::Challenge, Self::Response);

0 commit comments

Comments
 (0)