Skip to content

Commit 18e8db6

Browse files
committed
Moving main code to main directory and restructuring
1 parent 297013d commit 18e8db6

33 files changed

+121
-100
lines changed

benches/dleq_benches.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ mod dleq_benches {
2323
use curve25519_dalek::constants as dalek_constants;
2424
use curve25519_dalek::ristretto::RistrettoPoint;
2525
use curve25519_dalek::scalar::Scalar;
26-
use sigma_rs::toolbox::{
26+
use sigma_rs::old::{
2727
batch_verifier::BatchVerifier, prover::Prover, verifier::Verifier, SchnorrCS,
2828
};
29-
use sigma_rs::Transcript;
29+
use sigma_rs::old::Transcript;
3030

3131
#[allow(non_snake_case)]
3232
fn dleq_statement<CS: SchnorrCS>(

src/toolbox/sigma/fiat_shamir.rs renamed to src/fiat_shamir.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,12 @@
1313
//! - `C`: the transcript codec (`TranscriptCodec` trait).
1414
//! - `G`: the group used for commitments and operations (`Group` trait).
1515
16-
use crate::toolbox::sigma::transcript::TranscriptCodec;
17-
use crate::toolbox::sigma::SigmaProtocol;
18-
use crate::ProofError;
16+
use crate::{
17+
transcript::TranscriptCodec,
18+
SigmaProtocol,
19+
ProofError
20+
};
21+
1922
use group::Group;
2023
use rand::{CryptoRng, RngCore};
2124

File renamed without changes.
File renamed without changes.

src/lib.rs

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,32 @@
11
// -*- coding: utf-8; mode: rust; -*-
22
//
3-
// To the extent possible under law, the authors have waived all
4-
// copyright and related or neighboring rights to zkp,
5-
// using the Creative Commons "CC0" public domain dedication. See
6-
// <http://creativecommons.org/publicdomain/zero/1.0/> for full
7-
// details.
8-
//
93
// Authors:
10-
// - Henry de Valence <[email protected]>
4+
// - Nugzari Uzoevi <[email protected]>
5+
// - Michele Orrù <[email protected]>
6+
// - Lénaïck Gouriou <[email protected]>
117

128
#![allow(non_snake_case)]
13-
#![doc(html_logo_url = "https://doc.dalek.rs/assets/dalek-logo-clear.png")]
9+
#![doc(html_logo_url = "https://mmaker.github.io/sigma-rs/")]
1410
//! ## Note
1511
//!
1612
1713
#![deny(unused_variables)]
1814
#![deny(unused_mut)]
1915

20-
pub use merlin::Transcript;
21-
22-
mod errors;
23-
mod proofs;
24-
mod util;
25-
26-
pub use crate::errors::*;
27-
pub use crate::proofs::*;
16+
pub mod errors;
17+
pub mod fiat_shamir;
18+
pub mod group_morphism;
19+
pub mod group_serialisation;
20+
pub mod proof_composition;
21+
pub mod schnorr_proof;
22+
pub mod r#trait;
2823

29-
pub mod toolbox;
24+
pub use errors::*;
25+
pub use fiat_shamir::*;
26+
pub use group_morphism::*;
27+
pub use proof_composition::*;
28+
pub use schnorr_proof::*;
29+
pub use r#trait::*;
3030

31-
#[macro_use]
32-
mod macros;
31+
pub mod transcript;
32+
pub mod old;

src/macros.rs renamed to src/old/macros.rs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -108,17 +108,18 @@ macro_rules! define_proof {
108108
use curve25519_dalek::ristretto::RistrettoPoint;
109109
use curve25519_dalek::ristretto::CompressedRistretto;
110110

111-
use $crate::toolbox::prover::Prover;
112-
use $crate::toolbox::verifier::Verifier;
111+
use $crate::old::toolbox::prover::Prover;
112+
use $crate::old::toolbox::verifier::Verifier;
113113

114114
pub use merlin::Transcript;
115-
pub use $crate::{CompactProof, BatchableProof, ProofError};
115+
pub use $crate::{ProofError, old::{CompactProof, BatchableProof}};
116116

117117
/// The generated [`internal`] module contains lower-level
118118
/// functions at the level of the Schnorr constraint
119119
/// system API.
120120
pub mod internal {
121-
use $crate::toolbox::SchnorrCS;
121+
use $crate::old::toolbox::SchnorrCS;
122+
use $crate::__compute_formula_constraint;
122123

123124
/// The proof label committed to the transcript as a domain separator.
124125
pub const PROOF_LABEL: &'static str = $proof_label_string;
@@ -208,7 +209,7 @@ macro_rules! define_proof {
208209
assignments: ProveAssignments,
209210
) -> (Prover<'a>, CompressedPoints) {
210211
use self::internal::*;
211-
use $crate::toolbox::prover::*;
212+
use $crate::old::toolbox::prover::*;
212213

213214
let mut prover = Prover::new(PROOF_LABEL.as_bytes(), transcript);
214215

@@ -282,7 +283,7 @@ macro_rules! define_proof {
282283
assignments: VerifyAssignments,
283284
) -> Result<Verifier<'a>, ProofError> {
284285
use self::internal::*;
285-
use $crate::toolbox::verifier::*;
286+
use $crate::old::toolbox::verifier::*;
286287

287288
let mut verifier = Verifier::new(PROOF_LABEL.as_bytes(), transcript);
288289

@@ -339,7 +340,7 @@ macro_rules! define_proof {
339340
assignments: BatchVerifyAssignments,
340341
) -> Result<(), ProofError> {
341342
use self::internal::*;
342-
use $crate::toolbox::batch_verifier::*;
343+
use $crate::old::toolbox::batch_verifier::*;
343344

344345
let batch_size = proofs.len();
345346

src/old/mod.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
pub mod toolbox;
2+
pub mod macros;
3+
pub mod proofs;
4+
pub mod util;
5+
6+
pub use toolbox::*;
7+
pub use proofs::*;
8+
pub use util::*;
9+
pub use merlin::Transcript;
File renamed without changes.

src/toolbox/batch_verifier.rs renamed to src/old/toolbox/batch_verifier.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@ use curve25519_dalek::ristretto::{CompressedRistretto, RistrettoPoint};
44
use curve25519_dalek::scalar::Scalar;
55
use curve25519_dalek::traits::{IsIdentity, VartimeMultiscalarMul};
66

7-
use crate::toolbox::{SchnorrCS, TranscriptProtocol};
8-
use crate::util::Matrix;
9-
use crate::{BatchableProof, ProofError, Transcript};
7+
use crate::old::toolbox::{SchnorrCS, TranscriptProtocol};
8+
use crate::old::Matrix;
9+
use crate::old::{BatchableProof, Transcript};
10+
use crate::ProofError;
1011

1112
/// Used to produce batch verification results.
1213
///

src/toolbox/constraints.rs renamed to src/old/toolbox/constraints.rs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ use curve25519_dalek::ristretto::{CompressedRistretto, RistrettoPoint};
22
use curve25519_dalek::scalar::Scalar;
33
use curve25519_dalek::traits::IsIdentity;
44

5-
use merlin::Transcript;
5+
use crate::old::Transcript;
66

7-
use errors::ProofError;
7+
use crate::ProofError;
88

99
pub trait SchnorrCS {
1010
type ScalarVar: Copy;
@@ -82,12 +82,12 @@ pub trait TranscriptProtocol {
8282

8383
impl TranscriptProtocol for Transcript {
8484
fn domain_sep(&mut self, label: &'static [u8]) {
85-
self.commit_bytes(b"dom-sep", b"schnorrzkp/1.0/ristretto255");
86-
self.commit_bytes(b"dom-sep", label);
85+
self.append_message(b"dom-sep", b"schnorrzkp/1.0/ristretto255");
86+
self.append_message(b"dom-sep", label);
8787
}
8888

8989
fn append_scalar_var(&mut self, label: &'static [u8]) {
90-
self.commit_bytes(b"scvar", label);
90+
self.append_message(b"scvar", label);
9191
}
9292

9393
fn append_point_var(
@@ -96,8 +96,8 @@ impl TranscriptProtocol for Transcript {
9696
point: &RistrettoPoint,
9797
) -> CompressedRistretto {
9898
let encoding = point.compress();
99-
self.commit_bytes(b"ptvar", label);
100-
self.commit_bytes(b"val", encoding.as_bytes());
99+
self.append_message(b"ptvar", label);
100+
self.append_message(b"val", encoding.as_bytes());
101101
encoding
102102
}
103103

@@ -109,8 +109,8 @@ impl TranscriptProtocol for Transcript {
109109
if point.is_identity() {
110110
return Err(ProofError::VerificationFailure);
111111
}
112-
self.commit_bytes(b"ptvar", label);
113-
self.commit_bytes(b"val", point.as_bytes());
112+
self.append_message(b"ptvar", label);
113+
self.append_message(b"val", point.as_bytes());
114114
Ok(())
115115
}
116116

@@ -120,8 +120,8 @@ impl TranscriptProtocol for Transcript {
120120
point: &RistrettoPoint,
121121
) -> CompressedRistretto {
122122
let encoding = point.compress();
123-
self.commit_bytes(b"blindcom", label);
124-
self.commit_bytes(b"val", encoding.as_bytes());
123+
self.append_message(b"blindcom", label);
124+
self.append_message(b"val", encoding.as_bytes());
125125
encoding
126126
}
127127

@@ -133,8 +133,8 @@ impl TranscriptProtocol for Transcript {
133133
if point.is_identity() {
134134
return Err(ProofError::VerificationFailure);
135135
}
136-
self.commit_bytes(b"blindcom", label);
137-
self.commit_bytes(b"val", point.as_bytes());
136+
self.append_message(b"blindcom", label);
137+
self.append_message(b"val", point.as_bytes());
138138
Ok(())
139139
}
140140

0 commit comments

Comments
 (0)