Skip to content

Commit 765d3fd

Browse files
fix(docs): fix minor inconsistencies in documentation (#25)
1 parent 7e1c171 commit 765d3fd

File tree

4 files changed

+46
-24
lines changed

4 files changed

+46
-24
lines changed

src/errors.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//! # ProofError: Error Types for Zero-Knowledge Proofs
1+
//! # Error: Error Types for Zero-Knowledge Proofs
22
//!
33
//! This module defines the [`Error`] enum, which encapsulates possible errors that may occur
44
//! during the execution of Sigma protocols or their non-interactive variants.

src/fiat_shamir.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -128,10 +128,10 @@ where
128128
///
129129
/// # Returns
130130
/// - `Ok(())` if the proof is valid.
131-
/// - `Err(ProofError::VerificationFailure)` if the challenge is invalid or the response fails to verify.
131+
/// - `Err(Error::VerificationFailure)` if the challenge is invalid or the response fails to verify.
132132
///
133133
/// # Errors
134-
/// - Returns `ProofError::VerificationFailure` if:
134+
/// - Returns `Error::VerificationFailure` if:
135135
/// - The challenge doesn't match the recomputed one from the commitment.
136136
/// - The response fails verification under the Sigma protocol.
137137
pub fn verify(
@@ -182,10 +182,10 @@ where
182182
///
183183
/// # Returns
184184
/// - `Ok(())` if the proof is valid.
185-
/// - `Err(ProofError)` if deserialization or verification fails.
185+
/// - `Err(Error)` if deserialization or verification fails.
186186
///
187187
/// # Errors
188-
/// - Returns `ProofError::VerificationFailure` if:
188+
/// - Returns `Error::VerificationFailure` if:
189189
/// - The challenge doesn't match the recomputed one from the commitment.
190190
/// - The response fails verification under the Sigma protocol.
191191
pub fn verify_batchable(&self, proof: &[u8]) -> Result<(), Error> {
@@ -241,10 +241,10 @@ where
241241
///
242242
/// # Returns
243243
/// - `Ok(())` if the proof is valid.
244-
/// - `Err(ProofError)` if deserialization or verification fails.
244+
/// - `Err(Error)` if deserialization or verification fails.
245245
///
246246
/// # Errors
247-
/// - Returns `ProofError::VerificationFailure` if:
247+
/// - Returns `Error::VerificationFailure` if:
248248
/// - Deserialization fails.
249249
/// - The recomputed commitment or response is invalid under the Sigma protocol.
250250
pub fn verify_compact(&self, proof: &[u8]) -> Result<(), Error> {

src/group_serialization.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ pub fn serialize_element<G: Group + GroupEncoding>(element: &G) -> Vec<u8> {
2626
///
2727
/// # Returns
2828
/// - `Ok(G)`: The deserialized group element if the input is valid.
29-
/// - `Err(ProofError::GroupSerializationFailure)`: If the byte slice length is incorrect or the data
29+
/// - `Err(Error::GroupSerializationFailure)`: If the byte slice length is incorrect or the data
3030
/// does not represent a valid group element.
3131
pub fn deserialize_element<G: Group + GroupEncoding>(data: &[u8]) -> Result<G, Error> {
3232
let element_len = G::Repr::default().as_ref().len();
@@ -64,7 +64,7 @@ pub fn serialize_scalar<G: Group>(scalar: &G::Scalar) -> Vec<u8> {
6464
///
6565
/// # Returns
6666
/// - `Ok(G::Scalar)`: The deserialized scalar if the input is valid.
67-
/// - `Err(ProofError::GroupSerializationFailure)`: If the byte slice length is incorrect or the data
67+
/// - `Err(Error::GroupSerializationFailure)`: If the byte slice length is incorrect or the data
6868
/// does not represent a valid scalar.
6969
pub fn deserialize_scalar<G: Group>(data: &[u8]) -> Result<G::Scalar, Error> {
7070
let scalar_len = <<G as Group>::Scalar as PrimeField>::Repr::default()

src/schnorr_protocol.rs

Lines changed: 37 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ where
6868
/// - The prover state (random nonces and witness) used to compute the response.
6969
///
7070
/// # Errors
71-
/// -`ProofError::ProofSizeMismatch` if the witness vector length is incorrect.
71+
/// -`Error::ProofSizeMismatch` if the witness vector length is incorrect.
7272
fn prover_commit(
7373
&self,
7474
witness: &Self::Witness,
@@ -96,7 +96,7 @@ where
9696
/// - A vector of scalars forming the prover's response.
9797
///
9898
/// # Errors
99-
/// - Returns `ProofError::ProofSizeMismatch` if the prover state vectors have incorrect lengths.
99+
/// - Returns `Error::ProofSizeMismatch` if the prover state vectors have incorrect lengths.
100100
fn prover_response(
101101
&self,
102102
state: Self::ProverState,
@@ -121,13 +121,13 @@ where
121121
///
122122
/// # Returns
123123
/// - `Ok(())` if the proof is valid.
124-
/// - `Err(ProofError::VerificationFailure)` if the proof is invalid.
125-
/// - `Err(ProofError::ProofSizeMismatch)` if the lengths of commitment or response do not match the expected counts.
124+
/// - `Err(Error::VerificationFailure)` if the proof is invalid.
125+
/// - `Err(Error::ProofSizeMismatch)` if the lengths of commitment or response do not match the expected counts.
126126
///
127127
/// # Errors
128-
/// -`Err(ProofError::VerificationFailure)` if the computed relation
128+
/// -`Err(Error::VerificationFailure)` if the computed relation
129129
/// does not hold for the provided challenge and response, indicating proof invalidity.
130-
/// -`Err(ProofError::ProofSizeMismatch)` if the commitment or response length is incorrect.
130+
/// -`Err(Error::ProofSizeMismatch)` if the commitment or response length is incorrect.
131131
fn verifier(
132132
&self,
133133
commitment: &Self::Commitment,
@@ -163,7 +163,7 @@ where
163163
/// - A byte vector representing the serialized batchable proof.
164164
///
165165
/// # Errors
166-
/// - `ProofError::ProofSizeMismatch` if the commitment or response length is incorrect.
166+
/// - `Error::ProofSizeMismatch` if the commitment or response length is incorrect.
167167
fn serialize_batchable(
168168
&self,
169169
commitment: &Self::Commitment,
@@ -196,13 +196,13 @@ where
196196
///
197197
/// # Returns
198198
/// - A tuple `(commitment, response)` where
199-
/// * `commitment` is a vector of group elements (one per statement), and
200-
/// * `response` is a vector of scalars (one per witness).
199+
/// * `commitment` is a vector of group elements, and
200+
/// * `response` is a vector of scalars.
201201
///
202202
/// # Errors
203-
/// - `ProofError::ProofSizeMismatch` if the input length is not the exact number of bytes
203+
/// - `Error::ProofSizeMismatch` if the input length is not the exact number of bytes
204204
/// expected for `commit_nb` commitments plus `response_nb` responses.
205-
/// - `ProofError::GroupSerializationFailure` if any group element or scalar fails to
205+
/// - `Error::GroupSerializationFailure` if any group element or scalar fails to
206206
/// deserialize (propagated from `deserialize_element` or `deserialize_scalar`).
207207
fn deserialize_batchable(
208208
&self,
@@ -260,7 +260,7 @@ where
260260
/// - A vector of group elements representing the recomputed commitment (one per linear constraint).
261261
///
262262
/// # Errors
263-
/// - `ProofError::ProofSizeMismatch` if the response length does not match the expected number of scalars.
263+
/// - `Error::ProofSizeMismatch` if the response length does not match the expected number of scalars.
264264
fn get_commitment(
265265
&self,
266266
challenge: &Self::Challenge,
@@ -280,6 +280,17 @@ where
280280
Ok(commitment)
281281
}
282282

283+
/// Serializes a compact transcript: challenge followed by responses.
284+
/// # Parameters
285+
/// - `_commitment`: Omitted in compact format (reconstructed during verification).
286+
/// - `challenge`: The challenge scalar.
287+
/// - `response`: The prover’s response.
288+
///
289+
/// # Returns
290+
/// - A byte vector representing the compact proof.
291+
///
292+
/// # Errors
293+
/// - `Error::ProofSizeMismatch` if the response length does not match the expected number of scalars.
283294
fn serialize_response(&self, response: &Self::Response) -> Result<Vec<u8>, Error> {
284295
let mut bytes = Vec::new();
285296
let response_nb = self.scalars_nb();
@@ -294,6 +305,17 @@ where
294305
Ok(bytes)
295306
}
296307

308+
/// Deserializes a compact proof into a challenge and response.
309+
///
310+
/// # Parameters
311+
/// - `data`: A byte slice encoding the compact proof.
312+
///
313+
/// # Returns
314+
/// - A tuple `(challenge, response)`.
315+
///
316+
/// # Errors
317+
/// - `Error::ProofSizeMismatch` if the input data length does not match the expected size.
318+
/// - `Error::GroupSerializationFailure` if scalar deserialization fails.
297319
fn deserialize_response(&self, data: &[u8]) -> Result<(Self::Response, usize), Error> {
298320
let response_nb = self.scalars_nb();
299321
let response_size = <<G as Group>::Scalar as PrimeField>::Repr::default()
@@ -326,7 +348,7 @@ where
326348
/// - A byte vector representing the compact proof.
327349
///
328350
/// # Errors
329-
/// - `ProofError::ProofSizeMismatch` if the response length does not match the expected number of scalars.
351+
/// - `Error::ProofSizeMismatch` if the response length does not match the expected number of scalars.
330352
fn serialize_compact(
331353
&self,
332354
_commitment: &Self::Commitment,
@@ -352,8 +374,8 @@ where
352374
/// - A tuple `(challenge, response)`.
353375
///
354376
/// # Errors
355-
/// - `ProofError::ProofSizeMismatch` if the input data length does not match the expected size.
356-
/// - `ProofError::GroupSerializationFailure` if scalar deserialization fails.
377+
/// - `Error::ProofSizeMismatch` if the input data length does not match the expected size.
378+
/// - `Error::GroupSerializationFailure` if scalar deserialization fails.
357379
fn deserialize_compact(&self, data: &[u8]) -> Result<(Self::Challenge, Self::Response), Error> {
358380
let scalar_size = <<G as Group>::Scalar as PrimeField>::Repr::default()
359381
.as_ref()

0 commit comments

Comments
 (0)