Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 7 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,19 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
generic-ec = { git = "ssh://git@github.com/dfns-labs/generic-ec", branch = "d" }
generic-ec-core = { git = "ssh://git@github.com/dfns-labs/generic-ec", branch = "d" }
generic-ec = { git = "https://github.com/dfns-labs/generic-ec", branch = "d" }
generic-ec-core = { git = "https://github.com/dfns-labs/generic-ec", branch = "d" }
rand_core = { version = "0.6", default-features = false }
rand_chacha = { version = "0.3", default-features = false }
libpaillier = { version = "0.5", features = ["rust"], default-features = false }
libpaillier = { version = "0.5", default-features = false }
sha2 = { version = "0.10", default-features = false }

subtle = { version = "2.4", default-features = false }
zeroize = { version = "1.5", default-features = false }

[dev-dependencies]
rand_core = { version = "0.6", default-features = false, features = ["getrandom"] }
generic-ec-curves = { git = "ssh://git@github.com/dfns-labs/generic-ec", branch = "d", features = ["secp256r1"] }
generic-ec-curves = { git = "https://github.com/dfns-labs/generic-ec", branch = "d", features = ["secp256r1"] }

[features]
default = ["libpaillier/rust"]
6 changes: 6 additions & 0 deletions src/group_element_vs_paillier_encryption_in_range.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,15 @@ use crate::unknown_order::BigNumber;
use generic_ec::{Curve, Point};
use libpaillier::{Ciphertext, EncryptionKey, Nonce};

#[derive(Debug, Clone)]
pub struct SecurityParams {
/// l in paper, bit size of plaintext
pub l: usize,
/// Epsilon in paper, range extension and security parameter for x
pub epsilon: usize,
}

#[derive(Debug, Clone)]
pub struct Data<C: Curve> {
pub key0: EncryptionKey,
pub c: Ciphertext,
Expand All @@ -101,18 +103,21 @@ pub struct Data<C: Curve> {
pub g: Point<C>,
}

#[derive(Clone)]
Comment thread
maurges marked this conversation as resolved.
pub struct PrivateData {
pub x: BigNumber,
pub nonce: Nonce,
}

#[derive(Debug, Clone)]
pub struct Commitment<C: Curve> {
pub s: BigNumber,
pub a: Ciphertext,
pub y: Point<C>,
pub d: BigNumber,
}

#[derive(Clone)]
pub struct PrivateCommitment {
pub alpha: BigNumber,
pub mu: BigNumber,
Expand All @@ -122,6 +127,7 @@ pub struct PrivateCommitment {

pub type Challenge = BigNumber;

#[derive(Debug, Clone)]
pub struct Proof {
pub z1: BigNumber,
pub z2: BigNumber,
Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ pub use libpaillier;
/// the correct version of the library
pub use libpaillier::unknown_order;

pub use common::convert_scalar;
pub use common::{convert_scalar, InvalidProof, ProtocolError};
6 changes: 6 additions & 0 deletions src/paillier_affine_operation_in_range.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ use libpaillier::{Ciphertext, EncryptionKey, Nonce};

pub use crate::common::InvalidProof;

#[derive(Debug, Clone)]
pub struct SecurityParams {
/// l in paper, bit size of x
pub l_x: usize,
Expand All @@ -149,6 +150,7 @@ pub struct SecurityParams {
}

/// Public data that both parties know
#[derive(Debug, Clone)]
pub struct Data<C: Curve> {
/// N0 in paper, public key that C was encrypted on
pub key0: EncryptionKey,
Expand All @@ -165,6 +167,7 @@ pub struct Data<C: Curve> {
}

/// Private data of prover
#[derive(Clone)]
pub struct PrivateData {
/// x or epsilon in paper, preimage of X
pub x: BigNumber,
Expand All @@ -178,6 +181,7 @@ pub struct PrivateData {

// As described in cggmp21 at page 35
/// Prover's first message, obtained by `commit`
#[derive(Debug, Clone)]
pub struct Commitment<C: Curve> {
pub a: BigNumber,
pub b_x: Point<C>,
Expand All @@ -190,6 +194,7 @@ pub struct Commitment<C: Curve> {

/// Prover's data accompanying the commitment. Kept as state between rounds in
/// the interactive protocol.
#[derive(Clone)]
pub struct PrivateCommitment {
pub alpha: BigNumber,
pub beta: BigNumber,
Expand All @@ -206,6 +211,7 @@ pub struct PrivateCommitment {
pub type Challenge = BigNumber;

/// The ZK proof. Computed by `prove`
#[derive(Debug, Clone)]
pub struct Proof {
pub z1: BigNumber,
pub z2: BigNumber,
Expand Down
7 changes: 6 additions & 1 deletion src/paillier_blum_modulus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,17 +73,20 @@ pub enum InvalidProof {
}

/// Public data that both parties know: the Paillier-Blum modulus
#[derive(Debug, Clone)]
pub struct Data {
pub n: BigNumber,
}

/// Private data of prover
#[derive(Clone)]
pub struct PrivateData {
pub p: BigNumber,
pub q: BigNumber,
}

/// Prover's first message, obtained by `commit`
#[derive(Debug, Clone)]
pub struct Commitment {
pub w: BigNumber,
}
Expand All @@ -92,11 +95,12 @@ pub struct Commitment {
/// `challenge`
///
/// Consists of `M` singular challenges
#[derive(Debug, PartialEq, Eq)]
#[derive(Debug, PartialEq, Eq, Clone)]
pub struct Challenge<const M: usize> {
pub ys: [BigNumber; M],
}

#[derive(Debug, Clone)]
pub struct ProofPoint {
pub x: BigNumber,
pub a: bool,
Expand All @@ -105,6 +109,7 @@ pub struct ProofPoint {
}

/// The ZK proof. Computed by `prove`. Consists of M proofs for each challenge
#[derive(Debug, Clone)]
pub struct Proof<const M: usize> {
pub points: [ProofPoint; M],
}
Expand Down
6 changes: 6 additions & 0 deletions src/paillier_decryption_modulo_q.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ use libpaillier::{Ciphertext, EncryptionKey, Nonce};

pub use crate::common::InvalidProof;

#[derive(Debug, Clone)]
pub struct SecurityParams {
/// l in paper, bit size of plaintext
pub l: usize,
Expand All @@ -83,6 +84,7 @@ pub struct SecurityParams {
}

/// Public data that both parties know
#[derive(Debug, Clone)]
pub struct Data {
/// q in paper, modulo value such that `x = y mod q`
pub q: BigNumber,
Expand All @@ -95,13 +97,15 @@ pub struct Data {
}

/// Private data of prover
#[derive(Clone)]
pub struct PrivateData {
/// y in paper, plaintext value of C
pub y: BigNumber,
/// rho in paper, nonce of encryption y -> C
pub nonce: Nonce,
}

#[derive(Debug, Clone)]
/// Prover's first message, obtained by `commit`
pub struct Commitment {
pub s: BigNumber,
Expand All @@ -112,6 +116,7 @@ pub struct Commitment {

/// Prover's data accompanying the commitment. Kept as state between rounds in
/// the interactive protocol.
#[derive(Clone)]
pub struct PrivateCommitment {
pub alpha: BigNumber,
pub mu: BigNumber,
Expand All @@ -124,6 +129,7 @@ pub struct PrivateCommitment {
pub type Challenge = BigNumber;

/// The ZK proof. Computed by `prove`
#[derive(Debug, Clone)]
pub struct Proof {
pub z1: BigNumber,
pub z2: BigNumber,
Expand Down
6 changes: 6 additions & 0 deletions src/paillier_encryption_in_range.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ use libpaillier::{Ciphertext, EncryptionKey, Nonce};

pub use crate::common::InvalidProof;

#[derive(Debug, Clone)]
pub struct SecurityParams {
/// l in paper, bit size of plaintext
pub l: usize,
Expand All @@ -86,6 +87,7 @@ pub struct SecurityParams {
}

/// Public data that both parties know
#[derive(Debug, Clone)]
pub struct Data {
/// N0 in paper, public key that k -> K was encrypted on
pub key: EncryptionKey,
Expand All @@ -94,6 +96,7 @@ pub struct Data {
}

/// Private data of prover
#[derive(Clone)]
pub struct PrivateData {
/// k in paper, plaintext of K
pub plaintext: BigNumber,
Expand All @@ -103,6 +106,7 @@ pub struct PrivateData {

// As described in cggmp21 at page 33
/// Prover's first message, obtained by `commit`
#[derive(Debug, Clone)]
pub struct Commitment {
pub s: BigNumber,
pub a: BigNumber,
Expand All @@ -111,6 +115,7 @@ pub struct Commitment {

/// Prover's data accompanying the commitment. Kept as state between rounds in
/// the interactive protocol.
#[derive(Clone)]
pub struct PrivateCommitment {
pub alpha: BigNumber,
pub mu: BigNumber,
Expand All @@ -124,6 +129,7 @@ pub type Challenge = BigNumber;

// As described in cggmp21 at page 33
/// The ZK proof. Computed by `prove`
#[derive(Debug, Clone)]
pub struct Proof {
pub z1: BigNumber,
pub z2: BigNumber,
Expand Down