Skip to content

Commit 64fdba8

Browse files
authored
refactor(modules): avoid public re-exports of all data. (#11)
1 parent dff031c commit 64fdba8

13 files changed

+38
-36
lines changed

src/codec/keccak_codec.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//! # Keccak-based Fiat-Shamir Codec for vector tests
22
//!
3-
//! This module implements a **Fiat-Shamir codec** using the Keccak-f[1600] permutation
3+
//! This module implements a **Fiat-Shamir codec** using the Keccak-f\[1600\] permutation
44
//! in a duplex sponge construction
55
//!
66
//! It includes:
@@ -17,7 +17,7 @@
1717
//! - The `verifier_challenge` logic performs SHAKE-style domain separation and modulus reduction via `num-bigint`.
1818
//!
1919
//! ## Components
20-
//! - `KeccakPermutationState`: Low-level Keccak-f[1600] state representation
20+
//! - `KeccakPermutationState`: Low-level Keccak-f\[1600\] state representation
2121
//! - `KeccakDuplexSponge`: Duplex sponge over 200-byte state buffer
2222
//! - `ByteSchnorrCodec`: Fiat-Shamir codec compatible with Sage Schnorr proofs
2323
use crate::codec::r#trait::{Codec, DuplexSpongeInterface};

src/fiat_shamir.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@
1313
//! - `C`: the codec ([`Codec`] trait).
1414
//! - `G`: the group used for commitments and operations ([`Group`] trait).
1515
16-
use crate::{codec::Codec, CompactProtocol, ProofError, SigmaProtocol};
16+
use crate::codec::Codec;
17+
use crate::errors::ProofError;
18+
use crate::traits::{CompactProtocol, SigmaProtocol};
1719

1820
use group::{Group, GroupEncoding};
1921
use rand::{CryptoRng, RngCore};

src/group_serialization.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
use ff::PrimeField;
77
use group::{Group, GroupEncoding};
88

9-
use crate::ProofError;
9+
use crate::errors::ProofError;
1010

1111
/// Serialize a group element into a byte vector.
1212
///

src/lib.rs

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,6 @@ pub mod group_serialization;
2020
pub mod proof_builder;
2121
pub mod proof_composition;
2222
pub mod schnorr_protocol;
23-
pub mod r#trait;
24-
25-
pub use errors::*;
26-
pub use fiat_shamir::*;
27-
pub use group_morphism::*;
28-
pub use group_serialization::*;
29-
pub use proof_builder::*;
30-
pub use proof_composition::*;
31-
pub use r#trait::*;
32-
pub use schnorr_protocol::*;
23+
pub mod traits;
3324

3425
pub mod codec;

src/proof_builder.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,11 @@
1616
use group::{Group, GroupEncoding};
1717
use rand::{CryptoRng, RngCore};
1818

19-
use crate::{codec::ShakeCodec, NISigmaProtocol, PointVar, ProofError, ScalarVar, SchnorrProtocol};
19+
use crate::codec::ShakeCodec;
20+
use crate::errors::ProofError;
21+
use crate::fiat_shamir::NISigmaProtocol;
22+
use crate::group_morphism::{PointVar, ScalarVar};
23+
use crate::schnorr_protocol::SchnorrProtocol;
2024

2125
/// A builder that helps construct Sigma proofs for linear group relations.
2226
///

src/proof_composition.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
use ff::{Field, PrimeField};
22
use group::{Group, GroupEncoding};
33

4-
use crate::{
5-
deserialize_scalar, serialize_scalar, CompactProtocol, ProofError, SchnorrProtocol,
6-
SigmaProtocol, SigmaProtocolSimulator,
7-
};
4+
use crate::errors::ProofError;
5+
use crate::group_serialization::{deserialize_scalar, serialize_scalar};
6+
use crate::schnorr_protocol::SchnorrProtocol;
7+
use crate::traits::{CompactProtocol, SigmaProtocol, SigmaProtocolSimulator};
88

99
#[derive(Default)]
1010
pub struct AndProtocol<G: Group + GroupEncoding>(pub Vec<SchnorrProtocol<G>>);

src/schnorr_protocol.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@
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
7+
use crate::errors::ProofError;
8+
use crate::group_morphism::{GroupMorphismPreimage, PointVar, ScalarVar};
79
use crate::{
8-
group_serialization::*, CompactProtocol, GroupMorphismPreimage, PointVar, ProofError,
9-
ScalarVar, SigmaProtocol, SigmaProtocolSimulator,
10+
group_serialization::*,
11+
traits::{CompactProtocol, SigmaProtocol, SigmaProtocolSimulator},
1012
};
1113

1214
use ff::{Field, PrimeField};
@@ -211,8 +213,8 @@ where
211213
/// - `data`: A byte slice containing the serialized proof.
212214
///
213215
/// # Returns
214-
/// - A tuple `(commitment, response)` where
215-
/// * `commitment` is a vector of group elements (one per statement), and
216+
/// - A tuple `(commitment, response)` where
217+
/// * `commitment` is a vector of group elements (one per statement), and
216218
/// * `response` is a vector of scalars (one per witness).
217219
///
218220
/// # Errors

src/trait.rs renamed to src/traits.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//!
33
//! This module defines the [`SigmaProtocol`] trait, a generic interface for 3-message Sigma protocols.
44
5-
use crate::ProofError;
5+
use crate::errors::ProofError;
66
use rand::{CryptoRng, Rng};
77

88
/// A trait defining the behavior of a generic Sigma protocol.

tests/morphism_preimage.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,9 @@ use rand::{
55
{CryptoRng, Rng},
66
};
77

8-
use sigma_rs::{
9-
codec::ShakeCodec, group_morphism::msm_pr, GroupMorphismPreimage, NISigmaProtocol,
10-
SchnorrProtocol,
11-
};
8+
use sigma_rs::fiat_shamir::NISigmaProtocol;
9+
use sigma_rs::group_morphism::{msm_pr, GroupMorphismPreimage};
10+
use sigma_rs::{codec::ShakeCodec, schnorr_protocol::SchnorrProtocol};
1211

1312
type G = G1Projective;
1413

tests/proof_builder.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use bls12_381::{G1Projective, Scalar};
22
use group::ff::Field;
33

44
use rand::rngs::OsRng;
5-
use sigma_rs::ProofBuilder;
5+
use sigma_rs::proof_builder::ProofBuilder;
66

77
type G = G1Projective;
88

0 commit comments

Comments
 (0)