Skip to content

Commit b059d04

Browse files
committed
fix: trait methods, remove underscore prefix from arguments.
Remove useless trait implementation and underscore prefix from arguments that are not used.
1 parent a47ba99 commit b059d04

File tree

3 files changed

+26
-30
lines changed

3 files changed

+26
-30
lines changed

src/proof_composition.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -118,24 +118,24 @@ where
118118
out
119119
}
120120

121-
fn deserialize_batchable(&self, data: &[u8]) -> Option<(Self::Commitment, Self::Response)> {
121+
fn deserialize_batchable(&self, data: &[u8]) -> Option<(Self::Commitment, Self::Response)> {
122122
if data.len() < 4 {
123123
return None; // not enough bytes to contain the length suffix
124124
}
125-
125+
126126
// Split off the last 4 bytes as the trailer
127127
let (proof_data, len_bytes) = data.split_at(data.len() - 4);
128128
let len0 = u32::from_le_bytes(len_bytes.try_into().ok()?) as usize;
129-
129+
130130
if proof_data.len() < len0 {
131131
return None; // length hint exceeds available bytes
132132
}
133-
133+
134134
let (ser0, ser1) = proof_data.split_at(len0);
135-
135+
136136
let (commitment0, response0) = self.protocol0.deserialize_batchable(ser0)?;
137137
let (commitment1, response1) = self.protocol1.deserialize_batchable(ser1)?;
138-
138+
139139
Some(((commitment0, commitment1), (response0, response1)))
140140
}
141141
}
@@ -213,7 +213,7 @@ where
213213
let (r_index, r_witness_w) = witness;
214214
match r_witness_w {
215215
OrEnum::Left(ref r_witness) => {
216-
let f_trnsc = self.protocol1.simulate_transcription(rng);
216+
let f_trnsc = self.protocol1.simulate_transcript(rng);
217217
let ST = OrState(f_trnsc.1, f_trnsc.2);
218218
let (commit, r_pr_st) = self.protocol0.prover_commit(r_witness, rng);
219219
(
@@ -222,7 +222,7 @@ where
222222
)
223223
}
224224
OrEnum::Right(ref r_witness) => {
225-
let f_trnsc = self.protocol0.simulate_transcription(rng);
225+
let f_trnsc = self.protocol0.simulate_transcript(rng);
226226
let ST = OrState(f_trnsc.1, f_trnsc.2);
227227
let (commit, r_pr_st) = self.protocol1.prover_commit(r_witness, rng);
228228
(

src/trait.rs

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -89,19 +89,15 @@ pub trait CompactProtocol: SigmaProtocol {
8989

9090
fn serialize_compact(
9191
&self,
92-
_commitment: &Self::Commitment,
93-
_challenge: &Self::Challenge,
94-
_response: &Self::Response,
95-
) -> Vec<u8> {
96-
panic!("serialize_compact not implemented for this protocol")
97-
}
92+
commitment: &Self::Commitment,
93+
challenge: &Self::Challenge,
94+
response: &Self::Response,
95+
) -> Vec<u8>;
9896

9997
fn deserialize_compact(
10098
&self,
101-
_data: &[u8]
102-
) -> Option<(Self::Challenge, Self::Response)> {
103-
panic!("deserialize_compact not implemented for this protocol")
104-
}
99+
data: &[u8]
100+
) -> Option<(Self::Challenge, Self::Response)>;
105101
}
106102

107103
/// A trait defining the behavior of a Sigma protocol for which simulation of transcripts is necessary.
@@ -122,16 +118,16 @@ pub trait SigmaProtocolSimulator: SigmaProtocol {
122118
/// Panics if simulation is not implemented for this protocol.
123119
fn simulate_proof(
124120
&self,
125-
_challenge: &Self::Challenge,
126-
_rng: &mut (impl Rng + CryptoRng),
121+
challenge: &Self::Challenge,
122+
rng: &mut (impl Rng + CryptoRng),
127123
) -> (Self::Commitment, Self::Response);
128124

129-
/// Simulates an entire protocol transcript including a random challenge.
125+
/// Simulates an entire protocol transcript.
130126
///
131127
/// # Panics
132128
/// Panics if simulation is not implemented for this protocol.
133-
fn simulate_transcription(
129+
fn simulate_transcript(
134130
&self,
135-
_rng: &mut (impl Rng + CryptoRng),
131+
rng: &mut (impl Rng + CryptoRng),
136132
) -> (Self::Commitment, Self::Challenge, Self::Response);
137133
}

tests/proof_composition_test.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ use curve25519_dalek::{ristretto::RistrettoPoint, scalar::Scalar};
22
use rand::{rngs::OsRng, CryptoRng, Rng};
33

44
use sigma_rs::{
5-
OrEnum,
6-
AndProtocol,
7-
OrProtocol,
8-
SigmaProtocol,
5+
OrEnum,
6+
AndProtocol,
7+
OrProtocol,
8+
SigmaProtocol,
99
SigmaProtocolSimulator,
1010
ProofError,
1111
};
@@ -53,7 +53,7 @@ impl SigmaProtocol for SchnorrZkp {
5353
false => Err(ProofError::VerificationFailure),
5454
}
5555
}
56-
56+
5757
fn serialize_batchable(
5858
&self,
5959
_commitment: &Self::Commitment,
@@ -62,7 +62,7 @@ impl SigmaProtocol for SchnorrZkp {
6262
) -> Vec<u8> {
6363
todo!()
6464
}
65-
65+
6666
fn deserialize_batchable(&self, _data: &[u8]) -> Option<(Self::Commitment, Self::Response)> {
6767
todo!()
6868
}
@@ -80,7 +80,7 @@ impl SigmaProtocolSimulator for SchnorrZkp {
8080
(R, z)
8181
}
8282

83-
fn simulate_transcription(
83+
fn simulate_transcript(
8484
&self,
8585
rng: &mut (impl Rng + CryptoRng),
8686
) -> (Self::Commitment, Self::Challenge, Self::Response) {

0 commit comments

Comments
 (0)