Skip to content

Commit 426ead0

Browse files
committed
feat: CanonicalLinearRelation, and renaming NI into Nizk
2 parents 761d7d3 + a0c6a95 commit 426ead0

File tree

9 files changed

+283
-205
lines changed

9 files changed

+283
-205
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ This library provides a flexible framework for creating zero-knowledge proofs fo
99
## Quick Example
1010

1111
```rust
12-
use sigma_rs::{LinearRelation, Protocol, ProtocolWitness, NISigmaProtocol};
12+
use sigma_rs::{LinearRelation, Protocol, ProtocolWitness, Nizk};
1313
use sigma_rs::codec::ShakeCodec;
1414
use curve25519_dalek::RistrettoPoint as G;
1515

examples/simple_composition.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use sigma_rs::{
88
codec::ShakeCodec,
99
composition::{Protocol, ProtocolWitness},
1010
errors::Error,
11-
LinearRelation, NISigmaProtocol,
11+
LinearRelation, Nizk,
1212
};
1313

1414
type G = RistrettoPoint;
@@ -56,7 +56,7 @@ fn prove(P1: G, x2: Scalar, H: G) -> ProofResult<Vec<u8>> {
5656

5757
let protocol = create_relation(P1, P2, Q, H);
5858
let witness = ProtocolWitness::Or(1, vec![ProtocolWitness::Simple(vec![x2])]);
59-
let nizk = NISigmaProtocol::<_, ShakeCodec<G>>::new(b"or_proof_example", protocol);
59+
let nizk = Nizk::<_, ShakeCodec<G>>::new(b"or_proof_example", protocol);
6060

6161
nizk.prove_batchable(&witness, &mut rng)
6262
}
@@ -65,7 +65,7 @@ fn prove(P1: G, x2: Scalar, H: G) -> ProofResult<Vec<u8>> {
6565
#[allow(non_snake_case)]
6666
fn verify(P1: G, P2: G, Q: G, H: G, proof: &[u8]) -> ProofResult<()> {
6767
let protocol = create_relation(P1, P2, Q, H);
68-
let nizk = NISigmaProtocol::<_, ShakeCodec<G>>::new(b"or_proof_example", protocol);
68+
let nizk = Nizk::<_, ShakeCodec<G>>::new(b"or_proof_example", protocol);
6969

7070
nizk.verify_batchable(proof)
7171
}

src/fiat_shamir.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//! Fiat-Shamir transformation for [`SigmaProtocol`]s.
22
//!
3-
//! This module defines [`NISigmaProtocol`], a generic non-interactive Sigma protocol wrapper,
3+
//! This module defines [`Nizk`], a generic non-interactive Sigma protocol wrapper,
44
//! based on applying the Fiat-Shamir heuristic using a codec.
55
//!
66
//! It transforms an interactive [`SigmaProtocol`] into a non-interactive one,
@@ -26,7 +26,7 @@ type Transcript<P> = (
2626

2727
/// A Fiat-Shamir transformation of a [`SigmaProtocol`] into a non-interactive proof.
2828
///
29-
/// [`NISigmaProtocol`] wraps an interactive Sigma protocol `P`
29+
/// [`Nizk`] wraps an interactive Sigma protocol `P`
3030
/// and a hash-based codec `C`, to produce non-interactive proofs.
3131
///
3232
/// It manages the domain separation, codec reset,
@@ -36,7 +36,7 @@ type Transcript<P> = (
3636
/// - `P`: the Sigma protocol implementation.
3737
/// - `C`: the codec used for Fiat-Shamir.
3838
#[derive(Debug)]
39-
pub struct NISigmaProtocol<P, C>
39+
pub struct Nizk<P, C>
4040
where
4141
P: SigmaProtocol,
4242
P::Challenge: PartialEq,
@@ -48,20 +48,20 @@ where
4848
pub interactive_proof: P,
4949
}
5050

51-
impl<P, C> NISigmaProtocol<P, C>
51+
impl<P, C> Nizk<P, C>
5252
where
5353
P: SigmaProtocol,
5454
P::Challenge: PartialEq,
5555
C: Codec<Challenge = P::Challenge> + Clone,
5656
{
57-
/// Constructs a new [`NISigmaProtocol`] instance.
57+
/// Constructs a new [`Nizk`] instance.
5858
///
5959
/// # Parameters
6060
/// - `iv`: Domain separation tag for the hash function (e.g., protocol name or context).
6161
/// - `instance`: An instance of the interactive Sigma protocol.
6262
///
6363
/// # Returns
64-
/// A new [`NISigmaProtocol`] that can generate and verify non-interactive proofs.
64+
/// A new [`Nizk`] that can generate and verify non-interactive proofs.
6565
pub fn new(session_identifier: &[u8], interactive_proof: P) -> Self {
6666
let hash_state = C::new(
6767
interactive_proof.protocol_identifier().as_ref(),
@@ -233,7 +233,7 @@ where
233233
}
234234
}
235235

236-
impl<P, C> NISigmaProtocol<P, C>
236+
impl<P, C> Nizk<P, C>
237237
where
238238
P: SigmaProtocol + SigmaProtocolSimulator,
239239
P::Challenge: PartialEq,

src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
//!
2929
//! 1. Define your mathematical relation using [`LinearRelation`]
3030
//! 2. Create a Sigma protocol with [`schnorr_protocol::SchnorrProof`]
31-
//! 3. Convert to non-interactive using [`fiat_shamir::NISigmaProtocol`]
31+
//! 3. Convert to non-interactive using [`fiat_shamir::Nizk`]
3232
//! 4. Generate and verify proofs using the protocol interface
3333
//!
3434
//! ---
@@ -37,7 +37,7 @@
3737
//!
3838
//! - **[`traits::SigmaProtocol`]**: The fundamental three-move protocol interface
3939
//! - **[`linear_relation::LinearRelation`]**: Express mathematical relations over groups
40-
//! - **[`fiat_shamir::NISigmaProtocol`]**: Convert interactive proofs to standalone proofs
40+
//! - **[`fiat_shamir::Nizk`]**: Convert interactive proofs to standalone proofs
4141
//! - **[`composition::Protocol`]**: Combine multiple proofs together
4242
//! - **[`codec`]**: Hash function backends for proof generation
4343
//!
@@ -64,5 +64,5 @@ pub mod duplex_sponge;
6464
#[cfg(test)]
6565
pub mod tests;
6666

67-
pub use fiat_shamir::NISigmaProtocol;
67+
pub use fiat_shamir::Nizk;
6868
pub use linear_relation::LinearRelation;

0 commit comments

Comments
 (0)