Skip to content

Commit

Permalink
Refactorings and changes to dkg
Browse files Browse the repository at this point in the history
Signed-off-by: lovesh <[email protected]>
  • Loading branch information
lovesh committed Jun 21, 2024
1 parent 9b5a68d commit b3d5405
Show file tree
Hide file tree
Showing 38 changed files with 1,249 additions and 176 deletions.
10 changes: 5 additions & 5 deletions bbs_plus/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "bbs_plus"
version = "0.20.0"
version = "0.21.0"
edition.workspace = true
authors.workspace = true
license.workspace = true
Expand All @@ -23,10 +23,10 @@ sha3 = { version = "0.10.6", default-features = false }
serde.workspace = true
serde_with.workspace = true
zeroize.workspace = true
schnorr_pok = { version = "0.18.0", default-features = false, path = "../schnorr_pok" }
dock_crypto_utils = { version = "0.18.0", default-features = false, path = "../utils" }
oblivious_transfer_protocols = { version = "0.7.0", default-features = false, path = "../oblivious_transfer" }
secret_sharing_and_dkg = { version = "0.11.0", default-features = false, path = "../secret_sharing_and_dkg" }
schnorr_pok = { version = "0.19.0", default-features = false, path = "../schnorr_pok" }
dock_crypto_utils = { version = "0.19.0", default-features = false, path = "../utils" }
oblivious_transfer_protocols = { version = "0.8.0", default-features = false, path = "../oblivious_transfer" }
secret_sharing_and_dkg = { version = "0.12.0", default-features = false, path = "../secret_sharing_and_dkg" }

[dev-dependencies]
blake2.workspace = true
Expand Down
3 changes: 2 additions & 1 deletion bbs_plus/src/setup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ use dock_crypto_utils::{
use itertools::process_results;

#[cfg(feature = "parallel")]
use rayon::iter::{IntoParallelRefIterator, ParallelIterator};
use rayon::prelude::*;

use serde::{Deserialize, Serialize};
use serde_with::serde_as;

Expand Down
4 changes: 2 additions & 2 deletions bulletproofs_plus_plus/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "bulletproofs_plus_plus"
version = "0.4.0"
version = "0.5.0"
edition.workspace = true
authors.workspace = true
license.workspace = true
Expand All @@ -18,7 +18,7 @@ serde.workspace = true
serde_with.workspace = true
zeroize.workspace = true
rayon = { workspace = true, optional = true }
dock_crypto_utils = { version = "0.18.0", default-features = false, path = "../utils" }
dock_crypto_utils = { version = "0.19.0", default-features = false, path = "../utils" }

[dev-dependencies]
blake2.workspace = true
Expand Down
8 changes: 4 additions & 4 deletions coconut/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "coconut-crypto"
version = "0.9.0"
version = "0.10.0"
edition.workspace = true
authors.workspace = true
license.workspace = true
Expand All @@ -22,9 +22,9 @@ itertools.workspace = true
zeroize.workspace = true
serde_with.workspace = true
rayon = { workspace = true, optional = true }
utils = { package = "dock_crypto_utils", version = "0.18.0", default-features = false, path = "../utils" }
schnorr_pok = { version = "0.18.0", default-features = false, path = "../schnorr_pok" }
secret_sharing_and_dkg = { version = "0.11.0", default-features = false, path = "../secret_sharing_and_dkg" }
utils = { package = "dock_crypto_utils", version = "0.19.0", default-features = false, path = "../utils" }
schnorr_pok = { version = "0.19.0", default-features = false, path = "../schnorr_pok" }
secret_sharing_and_dkg = { version = "0.12.0", default-features = false, path = "../secret_sharing_and_dkg" }

[dev-dependencies]
blake2.workspace = true
Expand Down
2 changes: 1 addition & 1 deletion compressed_sigma/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ ark-std.workspace = true
ark-poly.workspace = true
rayon = {workspace = true, optional = true}
digest.workspace = true
dock_crypto_utils = { version = "0.18.0", default-features = false, path = "../utils" }
dock_crypto_utils = { version = "0.19.0", default-features = false, path = "../utils" }

[dev-dependencies]
blake2.workspace = true
Expand Down
4 changes: 2 additions & 2 deletions delegatable_credentials/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ serde.workspace = true
serde_with.workspace = true
zeroize.workspace = true
num-bigint = { version = "0.4.0", default-features = false }
schnorr_pok = { version = "0.18.0", default-features = false, path = "../schnorr_pok" }
dock_crypto_utils = { version = "0.18.0", default-features = false, path = "../utils" }
schnorr_pok = { version = "0.19.0", default-features = false, path = "../schnorr_pok" }
dock_crypto_utils = { version = "0.19.0", default-features = false, path = "../utils" }

[dependencies.num-integer]
version = "0.1.42"
Expand Down
6 changes: 3 additions & 3 deletions kvac/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "kvac"
version = "0.3.0"
version = "0.4.0"
edition.workspace = true
authors.workspace = true
license.workspace = true
Expand All @@ -18,8 +18,8 @@ rayon = {workspace = true, optional = true}
serde.workspace = true
serde_with.workspace = true
itertools.workspace = true
dock_crypto_utils = { version = "0.18.0", default-features = false, path = "../utils" }
schnorr_pok = { version = "0.18.0", default-features = false, path = "../schnorr_pok" }
dock_crypto_utils = { version = "0.19.0", default-features = false, path = "../utils" }
schnorr_pok = { version = "0.19.0", default-features = false, path = "../schnorr_pok" }

[dev-dependencies]
blake2.workspace = true
Expand Down
25 changes: 16 additions & 9 deletions kvac/src/bddt_2016/mac.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,12 @@ impl<G: AffineRepr> MAC<G> {
rng: &mut R,
messages: &[G::ScalarField],
secret_key: &SecretKey<G::ScalarField>,
params: &MACParams<G>,
params: impl AsRef<MACParams<G>>,
) -> Result<Self, KVACError> {
if messages.is_empty() {
return Err(KVACError::NoMessageGiven);
}
let params = params.as_ref();
expect_equality!(
messages.len(),
params.supported_message_count(),
Expand Down Expand Up @@ -96,11 +97,12 @@ impl<G: AffineRepr> MAC<G> {
commitment: &G,
uncommitted_messages: BTreeMap<usize, &G::ScalarField>,
sk: &SecretKey<G::ScalarField>,
params: &MACParams<G>,
params: impl AsRef<MACParams<G>>,
) -> Result<Self, KVACError> {
if uncommitted_messages.is_empty() {
return Err(KVACError::NoMessageGiven);
}
let params = params.as_ref();
// `>` as commitment will have 0 or more messages. In practice, commitment should have
// at least 1 message
if uncommitted_messages.len() > params.supported_message_count() {
Expand Down Expand Up @@ -135,19 +137,22 @@ impl<G: AffineRepr> MAC<G> {
pub fn verify(
&self,
messages: &[G::ScalarField],
sk: &SecretKey<G::ScalarField>,
params: &MACParams<G>,
sk: impl AsRef<G::ScalarField>,
params: impl AsRef<MACParams<G>>,
) -> Result<(), KVACError> {
if messages.is_empty() {
return Err(KVACError::NoMessageGiven);
}
let params = params.as_ref();
expect_equality!(
messages.len(),
params.supported_message_count(),
KVACError::MessageCountIncompatibleWithMACParams
);
let b = params.b(messages.iter().enumerate(), &self.s)?;
let e_plus_x_inv = (self.e + sk.0).inverse().ok_or(KVACError::CannotInvert0)?;
let e_plus_x_inv = (self.e + sk.as_ref())
.inverse()
.ok_or(KVACError::CannotInvert0)?;
if (b * e_plus_x_inv).into_affine() != self.A {
return Err(KVACError::InvalidMAC);
}
Expand All @@ -171,11 +176,12 @@ impl<G: AffineRepr> ProofOfValidityOfMAC<G> {
mac: &MAC<G>,
secret_key: &SecretKey<G::ScalarField>,
public_key: &PublicKey<G>,
params: &MACParams<G>,
params: impl AsRef<MACParams<G>>,
) -> Self {
let witness = secret_key.0;
let blinding = G::ScalarField::rand(rng);
let B = (mac.A * witness).into_affine();
let params = params.as_ref();
let mut challenge_bytes = vec![];
// As witness has to be proven same in both protocols.
let p1 = PokDiscreteLogProtocol::init(witness, blinding, &mac.A);
Expand All @@ -196,11 +202,12 @@ impl<G: AffineRepr> ProofOfValidityOfMAC<G> {
mac: &MAC<G>,
messages: &[G::ScalarField],
public_key: &PublicKey<G>,
params: &MACParams<G>,
params: impl AsRef<MACParams<G>>,
) -> Result<(), KVACError> {
if self.sc_B.response != self.sc_pk.response {
return Err(KVACError::InvalidMACProof);
}
let params = params.as_ref();
// B = h + g * s + g_1 * m_1 + g_2 * m_2 + ... g_n * m_n
let B =
(params.b(messages.iter().enumerate(), &mac.s)? + mac.A * mac.e.neg()).into_affine();
Expand Down Expand Up @@ -246,7 +253,7 @@ mod tests {

let proof = ProofOfValidityOfMAC::new::<_, Blake2b512>(&mut rng, &mac, &sk, &pk, &params);
proof
.verify::<Blake2b512>(&mac, &messages, &pk, &params)
.verify::<Blake2b512>(&mac, &messages, &pk, params)
.unwrap();
}

Expand Down Expand Up @@ -297,6 +304,6 @@ mod tests {
assert!(blinded_mac.verify(&messages, &sk, &params).is_err());

let mac = blinded_mac.unblind(&blinding);
mac.verify(&messages, &sk, &params).unwrap();
mac.verify(&messages, sk, params).unwrap();
}
}
6 changes: 6 additions & 0 deletions kvac/src/bddt_2016/setup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,3 +178,9 @@ impl<G: AffineRepr> AsRef<G> for PublicKey<G> {
&self.0
}
}

impl<G: AffineRepr> AsRef<MACParams<G>> for MACParams<G> {
fn as_ref(&self) -> &MACParams<G> {
&self
}
}
4 changes: 2 additions & 2 deletions legogroth16/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "legogroth16"
version = "0.13.0"
version = "0.14.0"
authors = [ "arkworks contributors", "Dock.io" ]
description = "An implementation of the LegoGroth16, the Legosnark variant of Groth16 zkSNARK proof system"
repository.workspace = true
Expand Down Expand Up @@ -29,7 +29,7 @@ num-bigint = { version = "0.4", default-features = false, optional = true }
log = "0.4"
ark-groth16 = { workspace = true, optional = true }
ark-snark = { version = "^0.4.0", default-features = false, optional = true }
dock_crypto_utils = { version = "0.18.0", default-features = false, path = "../utils" }
dock_crypto_utils = { version = "0.19.0", default-features = false, path = "../utils" }

[dev-dependencies]
csv = { version = "1" }
Expand Down
6 changes: 3 additions & 3 deletions oblivious_transfer/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "oblivious_transfer_protocols"
version = "0.7.0"
version = "0.8.0"
edition.workspace = true
authors.workspace = true
license.workspace = true
Expand All @@ -23,8 +23,8 @@ sha3 = { version = "0.10.6", default-features = false }
aes = { version = "0.8.2", default-features = false }
itertools.workspace = true
byteorder = { version = "1.4", default-features = false }
dock_crypto_utils = { version = "0.18.0", default-features = false, path = "../utils" }
schnorr_pok = { version = "0.18.0", default-features = false, path = "../schnorr_pok" }
dock_crypto_utils = { version = "0.19.0", default-features = false, path = "../utils" }
schnorr_pok = { version = "0.19.0", default-features = false, path = "../schnorr_pok" }

[dev-dependencies]
blake2.workspace = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ pub struct BaseOTOutput {
Clone, Debug, PartialEq, CanonicalSerialize, CanonicalDeserialize, Serialize, Deserialize,
)]
#[serde(bound = "")]
pub struct SenderPubKeyAndProof<G: AffineRepr>(SenderPubKey<G>, PokDiscreteLog<G>);
pub struct SenderPubKeyAndProof<G: AffineRepr>(pub SenderPubKey<G>, PokDiscreteLog<G>);

impl<G: AffineRepr> Participant<G> {
pub fn init<R: RngCore, D: Digest>(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ pub struct Message1<F: PrimeField>(

/// Message sent from Party1 to Party2 of multiplication protocol. This message is created after Party1 processes `Message1`
#[derive(Clone, Debug, PartialEq, CanonicalSerialize, CanonicalDeserialize)]
pub struct Message2<F: PrimeField>(CorrelationTag<F>, RLC<F>, MaskedInputs<F>);
pub struct Message2<F: PrimeField>(pub CorrelationTag<F>, RLC<F>, MaskedInputs<F>);

/// A participant's output on completion of the multiplication protocol
#[derive(Clone, Debug, PartialEq, CanonicalSerialize, CanonicalDeserialize)]
Expand Down
24 changes: 12 additions & 12 deletions proof_system/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "proof_system"
version = "0.29.0"
version = "0.30.0"
edition.workspace = true
authors.workspace = true
license.workspace = true
Expand All @@ -27,18 +27,18 @@ zeroize.workspace = true
itertools.workspace = true
aead = {version = "0.5.2", default-features = false, features = [ "alloc" ]}
chacha20poly1305 = {version = "0.10.1", default-features = false}
bbs_plus = { version = "0.20.0", default-features = false, path = "../bbs_plus" }
schnorr_pok = { version = "0.18.0", default-features = false, path = "../schnorr_pok" }
vb_accumulator = { version = "0.24.0", default-features = false, path = "../vb_accumulator" }
dock_crypto_utils = { version = "0.18.0", default-features = false, path = "../utils" }
saver = { version = "0.16.0", default-features = false, path = "../saver" }
coconut-crypto = { version = "0.9.0", default-features = false, path = "../coconut" }
bbs_plus = { version = "0.21.0", default-features = false, path = "../bbs_plus" }
schnorr_pok = { version = "0.19.0", default-features = false, path = "../schnorr_pok" }
vb_accumulator = { version = "0.25.0", default-features = false, path = "../vb_accumulator" }
dock_crypto_utils = { version = "0.19.0", default-features = false, path = "../utils" }
saver = { version = "0.17.0", default-features = false, path = "../saver" }
coconut-crypto = { version = "0.10.0", default-features = false, path = "../coconut" }
merlin = { package = "dock_merlin", version = "3.0.0", default-features = false, path = "../merlin" }
legogroth16 = { version = "0.13.0", default-features = false, features = ["circom", "aggregation"], path = "../legogroth16" }
bulletproofs_plus_plus = { version = "0.4.0", default-features = false, path = "../bulletproofs_plus_plus" }
smc_range_proof = { version = "0.4.0", default-features = false, path = "../smc_range_proof" }
short_group_sig = { version = "0.2.0", default-features = false, path = "../short_group_sig" }
kvac = { version = "0.3.0", default-features = false, path = "../kvac" }
legogroth16 = { version = "0.14.0", default-features = false, features = ["circom", "aggregation"], path = "../legogroth16" }
bulletproofs_plus_plus = { version = "0.5.0", default-features = false, path = "../bulletproofs_plus_plus" }
smc_range_proof = { version = "0.5.0", default-features = false, path = "../smc_range_proof" }
short_group_sig = { version = "0.3.0", default-features = false, path = "../short_group_sig" }
kvac = { version = "0.4.0", default-features = false, path = "../kvac" }

[dev-dependencies]
ark-bls12-381.workspace = true
Expand Down
6 changes: 3 additions & 3 deletions saver/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "saver"
version = "0.16.0"
version = "0.17.0"
edition.workspace = true
authors.workspace = true
license.workspace = true
Expand All @@ -20,8 +20,8 @@ rayon = {workspace = true, optional = true}
serde.workspace = true
serde_with.workspace = true
zeroize.workspace = true
dock_crypto_utils = { version = "0.18.0", default-features = false, path = "../utils" }
legogroth16 = { version = "0.13.0", default-features = false, features = ["aggregation"], path = "../legogroth16" }
dock_crypto_utils = { version = "0.19.0", default-features = false, path = "../utils" }
legogroth16 = { version = "0.14.0", default-features = false, features = ["aggregation"], path = "../legogroth16" }
merlin = { package = "dock_merlin", version = "3.0.0", default-features = false, path = "../merlin" }

[dev-dependencies]
Expand Down
4 changes: 2 additions & 2 deletions schnorr_pok/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "schnorr_pok"
version = "0.18.0"
version = "0.19.0"
edition.workspace = true
authors.workspace = true
license.workspace = true
Expand All @@ -19,7 +19,7 @@ ark-ec.workspace = true
ark-std.workspace = true
rayon = {workspace = true, optional = true}
digest.workspace = true
dock_crypto_utils = { version = "0.18.0", default-features = false, path = "../utils" }
dock_crypto_utils = { version = "0.19.0", default-features = false, path = "../utils" }
serde.workspace = true
serde_with.workspace = true
zeroize.workspace = true
Expand Down
8 changes: 4 additions & 4 deletions secret_sharing_and_dkg/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
[package]
name = "secret_sharing_and_dkg"
version = "0.11.0"
version = "0.12.0"
edition.workspace = true
authors.workspace = true
license.workspace = true
repository.workspace = true
description = "Secret sharing schemes like Shamir's, Feldman's, Pedersen's and Publicly Verifiable Secret Sharing scheme and DKGs like FROST"
description = "Secret sharing schemes like Shamir's, Feldman's, Pedersen's and Publicly Verifiable Secret Sharing scheme and DKGs like Gennaro's and FROST's"
keywords = ["secret-sharing", "VSS", "PVSS", "DKG", "Shamir"]

[dependencies]
Expand All @@ -19,8 +19,8 @@ rayon = { workspace = true, optional = true }
serde.workspace = true
serde_with.workspace = true
zeroize.workspace = true
dock_crypto_utils = { version = "0.18.0", default-features = false, path = "../utils" }
schnorr_pok = { version = "0.18.0", default-features = false, path = "../schnorr_pok" }
dock_crypto_utils = { version = "0.19.0", default-features = false, path = "../utils" }
schnorr_pok = { version = "0.19.0", default-features = false, path = "../schnorr_pok" }

[dev-dependencies]
blake2.workspace = true
Expand Down
2 changes: 1 addition & 1 deletion secret_sharing_and_dkg/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Key Generation (DKG) and Publicly Verifiable Secret Sharing (PVSS) algorithms. D
1. [Pedersen Distributed Verifiable Secret Sharing](./src/pedersen_dvss.rs)
1. [Feldman Verifiable Secret Sharing](./src/feldman_vss.rs)
1. [Feldman Distributed Verifiable Secret Sharing](./src/feldman_dvss_dkg.rs)
1. [Secure Distributed Key Generation for Discrete-Log Based Cryptosystems](./src/gennaro_dkg.rs)
1. [Gennaro DKG from the paper Secure Distributed Key Generation for Discrete-Log Based Cryptosystems](./src/gennaro_dkg.rs)
1. [Distributed Key Generation from FROST](./src/frost_dkg.rs)
1. [Distributed discrete log (DLOG) check](./src/distributed_dlog_check)
1. [Publicly Verifiable Secret Sharing](./src/baghery_pvss)
Loading

0 comments on commit b3d5405

Please sign in to comment.