Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
fcf0395
init
leontiadZen Sep 15, 2023
6f4c3c5
trait requirements
leontiadZen Sep 15, 2023
948544c
trait requirements
leontiadZen Sep 15, 2023
56b889d
trait requirements
leontiadZen Sep 15, 2023
4b54588
trait requirements
leontiadZen Sep 15, 2023
f57d942
merge with kms
leontiadZen Sep 15, 2023
a37de6b
remove engine dep
leontiadZen Sep 15, 2023
7bfab03
trait requirements
leontiadZen Sep 15, 2023
de176db
downcast Value trait
leontiadZen Sep 15, 2023
7d926ee
downcast Value trait
leontiadZen Sep 15, 2023
3827222
deserialize value for db.get in rocksdb
leontiadZen Sep 15, 2023
282f440
remove des
leontiadZen Sep 15, 2023
555d10d
debug
leontiadZen Sep 15, 2023
d688f8b
debug
leontiadZen Sep 15, 2023
f6d5045
formatter
leontiadZen Sep 16, 2023
f3524a2
debug
leontiadZen Sep 16, 2023
21d1312
typetag to ser/de trait objects
leontiadZen Sep 18, 2023
823b781
deprive serde_derive to serde
leontiadZen Sep 19, 2023
7aabb0e
ser/de Value
leontiadZen Sep 19, 2023
6dda261
remove ser/de
leontiadZen Sep 19, 2023
87557f7
downcasting
leontiadZen Sep 19, 2023
67e6da1
cloned
leontiadZen Sep 19, 2023
b6c2a01
pass ref
leontiadZen Sep 19, 2023
32b9841
ser
leontiadZen Sep 19, 2023
e1f7599
ser
leontiadZen Sep 19, 2023
79523f0
ser
leontiadZen Sep 19, 2023
9b619d7
third round
leontiadZen Sep 19, 2023
7131563
third round
leontiadZen Sep 19, 2023
b9a7b35
third round
leontiadZen Sep 19, 2023
2a59616
clone pdlDecommit
leontiadZen Sep 20, 2023
d3034f4
clean
leontiadZen Sep 20, 2023
e1d3f0d
clean
leontiadZen Sep 20, 2023
256f8ff
pdlcommit
leontiadZen Sep 22, 2023
ee4d93f
pdlcommit
leontiadZen Sep 22, 2023
cdb8d24
pdlcommit
leontiadZen Sep 22, 2023
71556a0
pdlcommit
leontiadZen Sep 22, 2023
e7eb7c0
rename
leontiadZen Sep 22, 2023
cff8d17
chaincode
leontiadZen Sep 22, 2023
2b56276
chaincode
leontiadZen Sep 22, 2023
ac61c09
chaincode
leontiadZen Sep 22, 2023
12d73c7
chaincode
leontiadZen Sep 22, 2023
443c733
chaincode
leontiadZen Sep 22, 2023
e0621ee
sign first
leontiadZen Sep 22, 2023
84e12a1
sign first
leontiadZen Sep 22, 2023
e6ba423
sign
leontiadZen Sep 22, 2023
621b571
init
Dec 13, 2023
ea39420
rangeproof not stable for rotation
Dec 14, 2023
b61cb57
rotate
leontiadZen Dec 28, 2023
ac2cd34
put all rounds in rotation
leontiadZen Jan 25, 2024
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
5 changes: 3 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@ sha3 = "0.10"
sha2 = "0.10"
hmac = "0.12"
rayon = "1"
serde = "1"
serde_derive = "1.0"
serde = { version = "1.0.147", features = ["derive"] }
#serde_derive = "1.0"
itertools = "0.10"
bit-vec = "0.6"
typetag = "0.2.3"

[dependencies.rust-gmp]
version = "0.5.0"
Expand Down
1 change: 1 addition & 0 deletions src/bulletproofs/proofs/inner_product.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ use crate::curv::cryptographic_primitives::hashing::traits::*;
use crate::curv::elliptic::curves::traits::*;
use crate::curv::BigInt;
use crate::curv::{FE, GE};
use serde::{Serialize,Deserialize};

use crate::bulletproofs::Errors::{self, InnerProductError};

Expand Down
2 changes: 2 additions & 0 deletions src/bulletproofs/proofs/range_proof.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ use crate::curv::BigInt;
use crate::curv::{FE, GE};
use itertools::iterate;
use std::ops::{Shl, Shr};
use serde::{Serialize,Deserialize};


#[derive(Debug, Serialize, Deserialize)]
pub struct RangeProof {
Expand Down
1 change: 1 addition & 0 deletions src/centipede/juggling/proof_system.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ use crate::curv::arithmetic::traits::Converter;
use crate::bulletproofs::proofs::range_proof::{RangeProof,generate_random_point};
use super::segmentation::Msegmentation;
use crate::centipede::Errors::{self, ErrorProving};
use serde::{Serialize,Deserialize};

#[derive(Serialize, Deserialize)]
pub struct Helgamal {
Expand Down
1 change: 0 additions & 1 deletion src/curv/arithmetic/big_gmp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ use super::traits::{
};
use gmp::mpz::Mpz;
use rand::RngCore;

use std::borrow::Borrow;

pub type BigInt = Mpz;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ use crate::curv::elliptic::curves::traits::*;
use crate::curv::FE;
use crate::curv::GE;
use zeroize::Zeroize;
use serde::{Serialize,Deserialize};

/// This is a proof of knowledge that a pair of group elements {D, E}
/// form a valid homomorphic ElGamal encryption (”in the exponent”) using public key Y .
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ use crate::curv::elliptic::curves::traits::*;
use crate::curv::FE;
use crate::curv::GE;
use zeroize::Zeroize;
use serde::{Serialize,Deserialize};

/// This is a proof of knowledge that a pair of group elements {D, E}
/// form a valid homomorphic ElGamal encryption (”in the exponent”) using public key Y .
Expand Down
17 changes: 17 additions & 0 deletions src/curv/cryptographic_primitives/proofs/sigma_dlog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
License MIT: https://github.com/KZen-networks/curv/blob/master/LICENSE
*/

use std::any::Any;
use std::fmt::{Display, Formatter};
use super::ProofError;
use crate::curv::FE;
use crate::curv::GE;
Expand All @@ -14,6 +16,8 @@ use crate::curv::elliptic::curves::traits::*;
use crate::curv::cryptographic_primitives::hashing::hash_sha256::HSha256;
use crate::curv::cryptographic_primitives::hashing::traits::Hash;
use zeroize::Zeroize;
use crate::party_one::{Value};
use serde::{Serialize,Deserialize};

/// This is implementation of Schnorr's identification protocol for elliptic curve groups or a
/// sigma protocol for Proof of knowledge of the discrete log of an Elliptic-curve point:
Expand All @@ -31,6 +35,19 @@ pub struct DLogProof {
pub pk_t_rand_commitment: GE,
pub challenge_response: FE,
}
#[typetag::serde]
impl Value for DLogProof {
fn as_any(&self) -> &dyn Any {
self
}
}

impl Display for DLogProof {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
write!(f, "{:?}", self)
}
}


pub trait ProveDLog {
fn prove(sk: &FE) -> DLogProof;
Expand Down
1 change: 1 addition & 0 deletions src/curv/cryptographic_primitives/proofs/sigma_ec_ddh.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use crate::curv::cryptographic_primitives::hashing::traits::Hash;
use crate::curv::elliptic::curves::traits::*;
use crate::curv::{FE, GE};
use zeroize::Zeroize;
use serde::{Serialize,Deserialize};

/// This protocol is the elliptic curve form of the protocol from :
/// D. Chaum, T. P. Pedersen. Transferred cash grows in size. In Advances in Cryptology, EUROCRYPT , volume 658 of Lecture Notes in Computer Science, pages 390 - 407, 1993.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ use crate::curv::cryptographic_primitives::hashing::traits::Hash;
use crate::curv::elliptic::curves::traits::*;
use crate::curv::{FE, GE};
use zeroize::Zeroize;
use serde::{Serialize,Deserialize};

/// protocol for proving that Pedersen commitment c was constructed correctly which is the same as
/// proof of knowledge of (m,r) such that c = mG + rH.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ use crate::curv::elliptic::curves::traits::*;

use crate::curv::{FE, GE};
use zeroize::Zeroize;
use serde::{Serialize,Deserialize};

/// protocol for proving that Pedersen commitment c was constructed correctly which is the same as
/// proof of knowledge of (r) such that c = mG + rH.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use crate::curv::cryptographic_primitives::proofs::sigma_valid_pedersen_blind::P
use crate::curv::cryptographic_primitives::proofs::sigma_valid_pedersen_blind::ProvePederesenBlind;
use crate::curv::elliptic::curves::traits::*;
use crate::curv::{FE, GE};
use serde::{Serialize,Deserialize};

/// based on How To Simulate It – A Tutorial on the Simulation
/// Proof Technique. protocol 7.3: Multiple coin tossing. which provide simulatble constant round
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use crate::curv::elliptic::curves::traits::*;
use crate::curv::FE;
use crate::curv::GE;
use serde::{Serialize,Deserialize};

#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct EcKeyPair {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
License MIT: <https://github.com/KZen-networks/curv/blob/master/LICENSE>
*/

use std::any::Any;
use std::fmt::{Display, Formatter};
/// in ECDH Alice chooses at random a secret "a" and sends Bob public key A = aG
/// Bob chooses at random a secret "b" and sends to Alice B = bG.
/// Both parties can compute a joint secret: C =aB = bA = abG which cannot be computed by
Expand All @@ -22,22 +24,66 @@ use crate::curv::elliptic::curves::traits::*;
use crate::curv::BigInt;
use crate::curv::FE;
use crate::curv::GE;
use serde::{Serialize,Deserialize};
use crate::party_one::Value;
use crate::party_two::PDLFirstMessage;

const SECURITY_BITS: usize = 256;


#[typetag::serde]
impl Value for EcKeyPairDHPoK {
fn as_any(&self) -> &dyn Any {
self
}
}

impl Display for EcKeyPairDHPoK {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
write!(f, "{:?}", self)
}
}

#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct EcKeyPair {
pub struct EcKeyPairDHPoK {
pub public_share: GE,
secret_share: FE,
}

#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct CommWitness {
pub struct CommWitnessDHPoK {
pub pk_commitment_blind_factor: BigInt,
pub zk_pok_blind_factor: BigInt,
pub public_share: GE,
pub d_log_proof: DLogProof,
}

#[typetag::serde]
impl Value for CommWitnessDHPoK {
fn as_any(&self) -> &dyn Any {
self
}
}

impl Display for CommWitnessDHPoK {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
write!(f, "{:?}", self)
}
}

#[typetag::serde]
impl Value for Party1FirstMessage {
fn as_any(&self) -> &dyn Any {
self
}
}

impl Display for Party1FirstMessage {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
write!(f, "{:?}", self)
}
}

#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct Party1FirstMessage {
pub pk_commitment: BigInt,
Expand All @@ -51,14 +97,14 @@ pub struct Party2FirstMessage {

#[derive(Debug, Serialize, Deserialize)]
pub struct Party1SecondMessage {
pub comm_witness: CommWitness,
pub comm_witness: CommWitnessDHPoK,
}

#[derive(Debug, Serialize, Deserialize)]
pub struct Party2SecondMessage {}

impl Party1FirstMessage {
pub fn create_commitments() -> (Party1FirstMessage, CommWitness, EcKeyPair) {
pub fn create_commitments() -> (Party1FirstMessage, CommWitnessDHPoK, EcKeyPairDHPoK) {
let base: GE = ECPoint::generator();

let secret_share: FE = ECScalar::new_random();
Expand All @@ -80,7 +126,7 @@ impl Party1FirstMessage {
.bytes_compressed_to_big_int(),
&zk_pok_blind_factor,
);
let ec_key_pair = EcKeyPair {
let ec_key_pair = EcKeyPairDHPoK {
public_share,
secret_share,
};
Expand All @@ -89,7 +135,7 @@ impl Party1FirstMessage {
pk_commitment,
zk_pok_commitment,
},
CommWitness {
CommWitnessDHPoK {
pk_commitment_blind_factor,
zk_pok_blind_factor,
public_share: ec_key_pair.public_share,
Expand All @@ -101,7 +147,7 @@ impl Party1FirstMessage {

pub fn create_commitments_with_fixed_secret_share(
secret_share: FE,
) -> (Party1FirstMessage, CommWitness, EcKeyPair) {
) -> (Party1FirstMessage, CommWitnessDHPoK, EcKeyPairDHPoK) {
let base: GE = ECPoint::generator();
let public_share = base * secret_share;

Expand All @@ -121,7 +167,7 @@ impl Party1FirstMessage {
&zk_pok_blind_factor,
);

let ec_key_pair = EcKeyPair {
let ec_key_pair = EcKeyPairDHPoK {
public_share,
secret_share,
};
Expand All @@ -130,7 +176,7 @@ impl Party1FirstMessage {
pk_commitment,
zk_pok_commitment,
},
CommWitness {
CommWitnessDHPoK {
pk_commitment_blind_factor,
zk_pok_blind_factor,
public_share: ec_key_pair.public_share,
Expand All @@ -143,20 +189,20 @@ impl Party1FirstMessage {

impl Party1SecondMessage {
pub fn verify_and_decommit(
comm_witness: CommWitness,
comm_witness: CommWitnessDHPoK,
proof: &DLogProof,
) -> Result<Party1SecondMessage, ProofError> {
DLogProof::verify(proof)?;
Ok(Party1SecondMessage { comm_witness })
}
}
impl Party2FirstMessage {
pub fn create() -> (Party2FirstMessage, EcKeyPair) {
pub fn create() -> (Party2FirstMessage, EcKeyPairDHPoK) {
let base: GE = ECPoint::generator();
let secret_share: FE = ECScalar::new_random();
let public_share = base * secret_share;
let d_log_proof = DLogProof::prove(&secret_share);
let ec_key_pair = EcKeyPair {
let ec_key_pair = EcKeyPairDHPoK {
public_share,
secret_share,
};
Expand All @@ -169,11 +215,11 @@ impl Party2FirstMessage {
)
}

pub fn create_with_fixed_secret_share(secret_share: FE) -> (Party2FirstMessage, EcKeyPair) {
pub fn create_with_fixed_secret_share(secret_share: FE) -> (Party2FirstMessage, EcKeyPairDHPoK) {
let base: GE = ECPoint::generator();
let public_share = base * secret_share;
let d_log_proof = DLogProof::prove(&secret_share);
let ec_key_pair = EcKeyPair {
let ec_key_pair = EcKeyPairDHPoK {
public_share,
secret_share,
};
Expand Down Expand Up @@ -228,7 +274,7 @@ impl Party2SecondMessage {
Ok(Party2SecondMessage {})
}
}
pub fn compute_pubkey(local_share: &EcKeyPair, other_share_public_share: &GE) -> GE {
pub fn compute_pubkey(local_share: &EcKeyPairDHPoK, other_share_public_share: &GE) -> GE {
other_share_public_share * &local_share.secret_share
}

Expand Down
Loading