From 52efe010264bdd5978111e148190359b9383d53e Mon Sep 17 00:00:00 2001
From: Piotr Roslaniec
Date: Tue, 31 Oct 2023 14:11:41 +0100
Subject: [PATCH 01/12] feat(ferveo): derive eq in DkgPublicKey
---
ferveo-common/src/keypair.rs | 12 ++----------
ferveo/src/api.rs | 2 +-
ferveo/src/dkg.rs | 2 +-
ferveo/src/validator.rs | 2 +-
4 files changed, 5 insertions(+), 13 deletions(-)
diff --git a/ferveo-common/src/keypair.rs b/ferveo-common/src/keypair.rs
index 485241b3..9b251125 100644
--- a/ferveo-common/src/keypair.rs
+++ b/ferveo-common/src/keypair.rs
@@ -61,15 +61,7 @@ impl PublicKey {
impl PartialOrd for PublicKey {
fn partial_cmp(&self, other: &Self) -> Option {
- if self.encryption_key.x() == other.encryption_key.x() {
- return self
- .encryption_key
- .y()
- .partial_cmp(&other.encryption_key.y());
- }
- self.encryption_key
- .x()
- .partial_cmp(&other.encryption_key.x())
+ Some(self.cmp(other))
}
}
@@ -102,7 +94,7 @@ pub struct Keypair {
impl PartialOrd for Keypair {
fn partial_cmp(&self, other: &Self) -> Option {
- self.decryption_key.partial_cmp(&other.decryption_key)
+ Some(self.cmp(other))
}
}
diff --git a/ferveo/src/api.rs b/ferveo/src/api.rs
index b2179ee6..3c354bcb 100644
--- a/ferveo/src/api.rs
+++ b/ferveo/src/api.rs
@@ -139,7 +139,7 @@ impl From for FerveoVariant {
}
#[serde_as]
-#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize)]
+#[derive(Copy, Clone, Debug, Eq, PartialEq, Serialize, Deserialize)]
pub struct DkgPublicKey(
#[serde_as(as = "serialization::SerdeAs")] pub(crate) G1Affine,
);
diff --git a/ferveo/src/dkg.rs b/ferveo/src/dkg.rs
index 9c95d96a..3c9bdf83 100644
--- a/ferveo/src/dkg.rs
+++ b/ferveo/src/dkg.rs
@@ -28,7 +28,7 @@ pub struct DkgValidator {
impl PartialOrd for DkgValidator {
fn partial_cmp(&self, other: &Self) -> Option {
- self.share_index.partial_cmp(&other.share_index)
+ Some(self.cmp(other))
}
}
diff --git a/ferveo/src/validator.rs b/ferveo/src/validator.rs
index fba25f5c..7b014266 100644
--- a/ferveo/src/validator.rs
+++ b/ferveo/src/validator.rs
@@ -49,7 +49,7 @@ pub struct Validator {
impl PartialOrd for Validator {
fn partial_cmp(&self, other: &Self) -> Option {
- self.address.partial_cmp(&other.address)
+ Some(self.cmp(other))
}
}
From 40cf1c380f682fd99ebeafae8ae296befb3fb81e Mon Sep 17 00:00:00 2001
From: Piotr Roslaniec
Date: Tue, 31 Oct 2023 15:09:46 +0100
Subject: [PATCH 02/12] feat: rename group_threshold_cryptography_pre_release
crate to ferveo_tpke
---
Cargo.lock | 58 +++++++++++++++---------------
ferveo/Cargo.toml | 2 +-
ferveo/src/api.rs | 27 +++++++-------
ferveo/src/bindings_wasm.rs | 8 ++---
ferveo/src/lib.rs | 71 ++++++++++++++++++++++---------------
ferveo/src/pvss.rs | 9 +++--
ferveo/src/refresh.rs | 5 ++-
tpke/Cargo.toml | 2 +-
tpke/benches/tpke.rs | 2 +-
9 files changed, 98 insertions(+), 86 deletions(-)
diff --git a/Cargo.lock b/Cargo.lock
index 604d7deb..f8a43ed7 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -771,9 +771,9 @@ dependencies = [
"derive_more",
"digest",
"ferveo-common-pre-release",
+ "ferveo-tpke",
"generic-array",
"getrandom 0.2.9",
- "group-threshold-cryptography-pre-release",
"hex",
"itertools",
"js-sys",
@@ -801,6 +801,34 @@ dependencies = [
"pyo3-build-config",
]
+[[package]]
+name = "ferveo-tpke"
+version = "0.2.0"
+dependencies = [
+ "ark-bls12-381",
+ "ark-ec",
+ "ark-ff",
+ "ark-poly",
+ "ark-serialize",
+ "ark-std",
+ "bincode",
+ "chacha20poly1305",
+ "criterion 0.4.0",
+ "ferveo-common-pre-release",
+ "hex",
+ "itertools",
+ "miracl_core",
+ "rand 0.8.5",
+ "rand_core 0.6.4",
+ "serde",
+ "serde_bytes",
+ "serde_with",
+ "sha2",
+ "subproductdomain-pre-release",
+ "thiserror",
+ "zeroize",
+]
+
[[package]]
name = "ferveo-wasm"
version = "0.1.0"
@@ -879,34 +907,6 @@ version = "0.27.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ad0a93d233ebf96623465aad4046a8d3aa4da22d4f4beba5388838c8a434bbb4"
-[[package]]
-name = "group-threshold-cryptography-pre-release"
-version = "0.2.0"
-dependencies = [
- "ark-bls12-381",
- "ark-ec",
- "ark-ff",
- "ark-poly",
- "ark-serialize",
- "ark-std",
- "bincode",
- "chacha20poly1305",
- "criterion 0.4.0",
- "ferveo-common-pre-release",
- "hex",
- "itertools",
- "miracl_core",
- "rand 0.8.5",
- "rand_core 0.6.4",
- "serde",
- "serde_bytes",
- "serde_with",
- "sha2",
- "subproductdomain-pre-release",
- "thiserror",
- "zeroize",
-]
-
[[package]]
name = "half"
version = "1.8.2"
diff --git a/ferveo/Cargo.toml b/ferveo/Cargo.toml
index bf31f363..6503ff5c 100644
--- a/ferveo/Cargo.toml
+++ b/ferveo/Cargo.toml
@@ -22,7 +22,7 @@ ark-serialize = "0.4"
ark-std = "0.4"
bincode = "1.3"
ferveo-common = { package = "ferveo-common-pre-release", path = "../ferveo-common", version = "^0.1.1" }
-group-threshold-cryptography = { package = "group-threshold-cryptography-pre-release", path = "../tpke", features = ["api", "test-common"], version = "^0.2.0" }
+ferveo-tpke = { package = "ferveo-tpke", path = "../tpke", features = ["api", "test-common"], version = "^0.2.0" }
hex = "0.4.3"
itertools = "0.10.5"
measure_time = "0.8"
diff --git a/ferveo/src/api.rs b/ferveo/src/api.rs
index 3c354bcb..9f83eca0 100644
--- a/ferveo/src/api.rs
+++ b/ferveo/src/api.rs
@@ -5,15 +5,14 @@ use ark_serialize::{CanonicalDeserialize, CanonicalSerialize};
use ark_std::UniformRand;
use bincode;
use ferveo_common::serialization;
+pub use ferveo_tpke::api::{
+ prepare_combine_simple, share_combine_precomputed, share_combine_simple,
+ Fr, G1Affine, G1Prepared, G2Affine, SecretBox, E,
+};
use generic_array::{typenum::U48, GenericArray};
-use group_threshold_cryptography as tpke;
use rand::RngCore;
use serde::{Deserialize, Serialize};
use serde_with::serde_as;
-pub use tpke::api::{
- prepare_combine_simple, share_combine_precomputed, share_combine_simple,
- Fr, G1Affine, G1Prepared, G2Affine, SecretBox, E,
-};
pub type PublicKey = ferveo_common::PublicKey;
pub type Keypair = ferveo_common::Keypair;
@@ -31,7 +30,8 @@ use crate::{
PubliclyVerifiableSS, Result,
};
-pub type DecryptionSharePrecomputed = tpke::api::DecryptionSharePrecomputed;
+pub type DecryptionSharePrecomputed =
+ ferveo_tpke::api::DecryptionSharePrecomputed;
// Normally, we would use a custom trait for this, but we can't because
// the arkworks will not let us create a blanket implementation for G1Affine
@@ -54,7 +54,8 @@ pub fn encrypt(
pubkey: &DkgPublicKey,
) -> Result {
let mut rng = rand::thread_rng();
- let ciphertext = tpke::api::encrypt(message, aad, &pubkey.0, &mut rng)?;
+ let ciphertext =
+ ferveo_tpke::api::encrypt(message, aad, &pubkey.0, &mut rng)?;
Ok(Ciphertext(ciphertext))
}
@@ -64,7 +65,7 @@ pub fn decrypt_with_shared_secret(
shared_secret: &SharedSecret,
) -> Result> {
let dkg_public_params = DkgPublicParameters::default();
- tpke::api::decrypt_with_shared_secret(
+ ferveo_tpke::api::decrypt_with_shared_secret(
&ciphertext.0,
aad,
&shared_secret.0,
@@ -74,7 +75,7 @@ pub fn decrypt_with_shared_secret(
}
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, Eq)]
-pub struct Ciphertext(tpke::api::Ciphertext);
+pub struct Ciphertext(ferveo_tpke::api::Ciphertext);
impl Ciphertext {
pub fn header(&self) -> Result {
@@ -88,7 +89,7 @@ impl Ciphertext {
#[serde_as]
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq)]
-pub struct CiphertextHeader(tpke::api::CiphertextHeader);
+pub struct CiphertextHeader(ferveo_tpke::api::CiphertextHeader);
/// The ferveo variant to use for the decryption share derivation.
#[derive(
@@ -347,7 +348,7 @@ impl AggregatedTranscript {
#[serde_as]
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct DecryptionShareSimple {
- share: tpke::api::DecryptionShareSimple,
+ share: ferveo_tpke::api::DecryptionShareSimple,
#[serde_as(as = "serialization::SerdeAs")]
domain_point: Fr,
}
@@ -389,13 +390,13 @@ pub fn combine_shares_simple(shares: &[DecryptionShareSimple]) -> SharedSecret {
}
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
-pub struct SharedSecret(pub tpke::api::SharedSecret);
+pub struct SharedSecret(pub ferveo_tpke::api::SharedSecret);
#[cfg(test)]
mod test_ferveo_api {
+ use ferveo_tpke::SecretBox;
use itertools::izip;
use rand::{prelude::StdRng, SeedableRng};
- use tpke::SecretBox;
use crate::{api::*, dkg::test_common::*};
diff --git a/ferveo/src/bindings_wasm.rs b/ferveo/src/bindings_wasm.rs
index a8b1f7c7..30defbaa 100644
--- a/ferveo/src/bindings_wasm.rs
+++ b/ferveo/src/bindings_wasm.rs
@@ -1,5 +1,3 @@
-extern crate group_threshold_cryptography as tpke;
-
use std::{
convert::{TryFrom, TryInto},
fmt,
@@ -7,10 +5,10 @@ use std::{
};
use ferveo_common::{FromBytes, ToBytes};
+use ferveo_tpke::SecretBox;
use js_sys::Error;
use rand::thread_rng;
use serde::{Deserialize, Serialize};
-use tpke::SecretBox;
use wasm_bindgen::prelude::*;
use wasm_bindgen_derive::TryFromJsValue;
@@ -202,7 +200,9 @@ generate_common_methods!(DecryptionShareSimple);
#[derive(TryFromJsValue)]
#[wasm_bindgen]
#[derive(Clone, Debug, derive_more::AsRef, derive_more::From)]
-pub struct DecryptionSharePrecomputed(tpke::api::DecryptionSharePrecomputed);
+pub struct DecryptionSharePrecomputed(
+ ferveo_tpke::api::DecryptionSharePrecomputed,
+);
generate_common_methods!(DecryptionSharePrecomputed);
diff --git a/ferveo/src/lib.rs b/ferveo/src/lib.rs
index 41da3ba7..d999ca11 100644
--- a/ferveo/src/lib.rs
+++ b/ferveo/src/lib.rs
@@ -4,7 +4,6 @@
extern crate alloc;
use ark_ec::pairing::Pairing;
-use group_threshold_cryptography as tpke;
use itertools::zip_eq;
#[cfg(feature = "bindings-python")]
@@ -31,7 +30,7 @@ pub use validator::*;
#[derive(Debug, thiserror::Error)]
pub enum Error {
#[error(transparent)]
- ThresholdEncryptionError(#[from] tpke::Error),
+ ThresholdEncryptionError(#[from] ferveo_tpke::Error),
/// DKG is not in a valid state to deal PVSS shares
#[error("Invalid DKG state to deal PVSS shares")]
@@ -127,9 +126,8 @@ mod test_dkg_full {
use ark_poly::EvaluationDomain;
use ark_std::test_rng;
use ferveo_common::Keypair;
- use group_threshold_cryptography as tpke;
- use group_threshold_cryptography::{
- DecryptionSharePrecomputed, DecryptionShareSimple, SecretBox,
+ use ferveo_tpke::{
+ self, DecryptionSharePrecomputed, DecryptionShareSimple, SecretBox,
SharedSecret,
};
use itertools::izip;
@@ -142,7 +140,7 @@ mod test_dkg_full {
fn make_shared_secret_simple_tdec(
dkg: &PubliclyVerifiableDkg,
aad: &[u8],
- ciphertext_header: &tpke::CiphertextHeader,
+ ciphertext_header: &ferveo_tpke::CiphertextHeader,
validator_keypairs: &[Keypair],
) -> (
PubliclyVerifiableSS,
@@ -178,11 +176,12 @@ mod test_dkg_full {
.collect::>();
assert_eq!(domain_points.len(), decryption_shares.len());
- // TODO: Consider refactor this part into tpke::combine_simple and expose it
- // as a public API in tpke::api
+ // TODO: Consider refactor this part into ferveo_tpke::combine_simple and expose it
+ // as a public API in ferveo_tpke::api
- let lagrange_coeffs = tpke::prepare_combine_simple::(domain_points);
- let shared_secret = tpke::share_combine_simple::(
+ let lagrange_coeffs =
+ ferveo_tpke::prepare_combine_simple::(domain_points);
+ let shared_secret = ferveo_tpke::share_combine_simple::(
&decryption_shares,
&lagrange_coeffs,
);
@@ -202,7 +201,7 @@ mod test_dkg_full {
let msg = "my-msg".as_bytes().to_vec();
let aad: &[u8] = "my-aad".as_bytes();
let public_key = dkg.public_key();
- let ciphertext = tpke::encrypt::(
+ let ciphertext = ferveo_tpke::encrypt::(
SecretBox::new(msg.clone()),
aad,
&public_key,
@@ -217,7 +216,7 @@ mod test_dkg_full {
validator_keypairs.as_slice(),
);
- let plaintext = tpke::decrypt_with_shared_secret(
+ let plaintext = ferveo_tpke::decrypt_with_shared_secret(
&ciphertext,
aad,
&shared_secret,
@@ -241,7 +240,7 @@ mod test_dkg_full {
let msg = "my-msg".as_bytes().to_vec();
let aad: &[u8] = "my-aad".as_bytes();
let public_key = dkg.public_key();
- let ciphertext = tpke::encrypt::(
+ let ciphertext = ferveo_tpke::encrypt::(
SecretBox::new(msg.clone()),
aad,
&public_key,
@@ -279,10 +278,10 @@ mod test_dkg_full {
assert_eq!(domain_points.len(), decryption_shares.len());
let shared_secret =
- tpke::share_combine_precomputed::(&decryption_shares);
+ ferveo_tpke::share_combine_precomputed::(&decryption_shares);
// Combination works, let's decrypt
- let plaintext = tpke::decrypt_with_shared_secret(
+ let plaintext = ferveo_tpke::decrypt_with_shared_secret(
&ciphertext,
aad,
&shared_secret,
@@ -301,9 +300,13 @@ mod test_dkg_full {
let msg = "my-msg".as_bytes().to_vec();
let aad: &[u8] = "my-aad".as_bytes();
let public_key = dkg.public_key();
- let ciphertext =
- tpke::encrypt::(SecretBox::new(msg), aad, &public_key, rng)
- .unwrap();
+ let ciphertext = ferveo_tpke::encrypt::(
+ SecretBox::new(msg),
+ aad,
+ &public_key,
+ rng,
+ )
+ .unwrap();
let (pvss_aggregated, decryption_shares, _) =
make_shared_secret_simple_tdec(
@@ -364,9 +367,13 @@ mod test_dkg_full {
let msg = "my-msg".as_bytes().to_vec();
let aad: &[u8] = "my-aad".as_bytes();
let public_key = &dkg.public_key();
- let ciphertext =
- tpke::encrypt::(SecretBox::new(msg), aad, public_key, rng)
- .unwrap();
+ let ciphertext = ferveo_tpke::encrypt::(
+ SecretBox::new(msg),
+ aad,
+ public_key,
+ rng,
+ )
+ .unwrap();
// Create an initial shared secret
let (_, _, old_shared_secret) = make_shared_secret_simple_tdec(
@@ -496,9 +503,11 @@ mod test_dkg_full {
assert_eq!(domain_points.len(), security_threshold as usize);
assert_eq!(decryption_shares.len(), security_threshold as usize);
- let lagrange = tpke::prepare_combine_simple::(domain_points);
- let new_shared_secret =
- tpke::share_combine_simple::(decryption_shares, &lagrange);
+ let lagrange = ferveo_tpke::prepare_combine_simple::(domain_points);
+ let new_shared_secret = ferveo_tpke::share_combine_simple::(
+ decryption_shares,
+ &lagrange,
+ );
assert_eq!(
old_shared_secret, new_shared_secret,
@@ -517,9 +526,13 @@ mod test_dkg_full {
let msg = "my-msg".as_bytes().to_vec();
let aad: &[u8] = "my-aad".as_bytes();
let public_key = &dkg.public_key();
- let ciphertext =
- tpke::encrypt::(SecretBox::new(msg), aad, public_key, rng)
- .unwrap();
+ let ciphertext = ferveo_tpke::encrypt::(
+ SecretBox::new(msg),
+ aad,
+ public_key,
+ rng,
+ )
+ .unwrap();
// Create an initial shared secret
let (_, _, old_shared_secret) = make_shared_secret_simple_tdec(
@@ -594,10 +607,10 @@ mod test_dkg_full {
})
.collect();
- let lagrange = tpke::prepare_combine_simple::(
+ let lagrange = ferveo_tpke::prepare_combine_simple::(
&domain_points[..security_threshold as usize],
);
- let new_shared_secret = tpke::share_combine_simple::(
+ let new_shared_secret = ferveo_tpke::share_combine_simple::(
&decryption_shares[..security_threshold as usize],
&lagrange,
);
diff --git a/ferveo/src/pvss.rs b/ferveo/src/pvss.rs
index 91976ee9..3e28dd67 100644
--- a/ferveo/src/pvss.rs
+++ b/ferveo/src/pvss.rs
@@ -6,16 +6,15 @@ use ark_poly::{
polynomial::univariate::DensePolynomial, DenseUVPolynomial,
EvaluationDomain,
};
-use group_threshold_cryptography as tpke;
+use ferveo_tpke::{
+ prepare_combine_simple, CiphertextHeader, DecryptionSharePrecomputed,
+ DecryptionShareSimple, PrivateKeyShare,
+};
use itertools::Itertools;
use rand::RngCore;
use serde::{Deserialize, Serialize};
use serde_with::serde_as;
use subproductdomain::fast_multiexp;
-use tpke::{
- prepare_combine_simple, CiphertextHeader, DecryptionSharePrecomputed,
- DecryptionShareSimple, PrivateKeyShare,
-};
use zeroize::{self, Zeroize, ZeroizeOnDrop};
use crate::{
diff --git a/ferveo/src/refresh.rs b/ferveo/src/refresh.rs
index ce87c81c..9b1ed904 100644
--- a/ferveo/src/refresh.rs
+++ b/ferveo/src/refresh.rs
@@ -3,10 +3,9 @@ use std::{ops::Mul, usize};
use ark_ec::{pairing::Pairing, AffineRepr, CurveGroup};
use ark_ff::Zero;
use ark_poly::{univariate::DensePolynomial, DenseUVPolynomial, Polynomial};
-use group_threshold_cryptography as tpke;
+use ferveo_tpke::{lagrange_basis_at, PrivateKeyShare};
use itertools::zip_eq;
use rand_core::RngCore;
-use tpke::{lagrange_basis_at, PrivateKeyShare};
// SHARE UPDATE FUNCTIONS:
@@ -130,7 +129,7 @@ mod tests_refresh {
type E = ark_bls12_381::Bls12_381;
type ScalarField = ::ScalarField;
- use group_threshold_cryptography::{
+ use ferveo_tpke::{
test_common::setup_simple, PrivateDecryptionContextSimple,
PrivateKeyShare,
};
diff --git a/tpke/Cargo.toml b/tpke/Cargo.toml
index 0e65d20e..0c1bd626 100644
--- a/tpke/Cargo.toml
+++ b/tpke/Cargo.toml
@@ -1,5 +1,5 @@
[package]
-name = "group-threshold-cryptography-pre-release"
+name = "ferveo-tpke"
version = "0.2.0"
edition = "2021"
authors = ["Heliax AG ", "Piotr Roslaniec "]
diff --git a/tpke/benches/tpke.rs b/tpke/benches/tpke.rs
index cb553c27..287ba81d 100644
--- a/tpke/benches/tpke.rs
+++ b/tpke/benches/tpke.rs
@@ -5,7 +5,7 @@ use ark_ec::pairing::Pairing;
use criterion::{
black_box, criterion_group, criterion_main, BenchmarkId, Criterion,
};
-use group_threshold_cryptography_pre_release::{
+use ferveo_tpke::{
test_common::{setup_fast, setup_simple},
*,
};
From de4cde2db6ac5f87f7675e8956bb4c71f067bb4f Mon Sep 17 00:00:00 2001
From: Piotr Roslaniec
Date: Tue, 31 Oct 2023 15:12:46 +0100
Subject: [PATCH 03/12] chore: rename tpke dir to ferveo-tpke
---
Cargo.toml | 2 +-
{tpke => ferveo-tpke}/BENCHMARK.md | 0
{tpke => ferveo-tpke}/CHANGELOG.md | 0
{tpke => ferveo-tpke}/Cargo.toml | 0
{tpke => ferveo-tpke}/README.md | 0
{tpke => ferveo-tpke}/benches/arkworks.rs | 0
{tpke => ferveo-tpke}/benches/tpke.rs | 0
{tpke => ferveo-tpke}/src/api.rs | 0
{tpke => ferveo-tpke}/src/ciphertext.rs | 0
{tpke => ferveo-tpke}/src/combine.rs | 0
{tpke => ferveo-tpke}/src/context.rs | 0
{tpke => ferveo-tpke}/src/decryption.rs | 0
{tpke => ferveo-tpke}/src/hash_to_curve.rs | 0
{tpke => ferveo-tpke}/src/key_share.rs | 0
{tpke => ferveo-tpke}/src/lib.rs | 0
{tpke => ferveo-tpke}/src/secret_box.rs | 0
ferveo/Cargo.toml | 2 +-
17 files changed, 2 insertions(+), 2 deletions(-)
rename {tpke => ferveo-tpke}/BENCHMARK.md (100%)
rename {tpke => ferveo-tpke}/CHANGELOG.md (100%)
rename {tpke => ferveo-tpke}/Cargo.toml (100%)
rename {tpke => ferveo-tpke}/README.md (100%)
rename {tpke => ferveo-tpke}/benches/arkworks.rs (100%)
rename {tpke => ferveo-tpke}/benches/tpke.rs (100%)
rename {tpke => ferveo-tpke}/src/api.rs (100%)
rename {tpke => ferveo-tpke}/src/ciphertext.rs (100%)
rename {tpke => ferveo-tpke}/src/combine.rs (100%)
rename {tpke => ferveo-tpke}/src/context.rs (100%)
rename {tpke => ferveo-tpke}/src/decryption.rs (100%)
rename {tpke => ferveo-tpke}/src/hash_to_curve.rs (100%)
rename {tpke => ferveo-tpke}/src/key_share.rs (100%)
rename {tpke => ferveo-tpke}/src/lib.rs (100%)
rename {tpke => ferveo-tpke}/src/secret_box.rs (100%)
diff --git a/Cargo.toml b/Cargo.toml
index 6526bd30..b7c73f4f 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -6,7 +6,7 @@ members = [
"ferveo-python",
"ferveo-wasm",
"subproductdomain",
- "tpke",
+ "ferveo-tpke",
]
[profile.bench]
diff --git a/tpke/BENCHMARK.md b/ferveo-tpke/BENCHMARK.md
similarity index 100%
rename from tpke/BENCHMARK.md
rename to ferveo-tpke/BENCHMARK.md
diff --git a/tpke/CHANGELOG.md b/ferveo-tpke/CHANGELOG.md
similarity index 100%
rename from tpke/CHANGELOG.md
rename to ferveo-tpke/CHANGELOG.md
diff --git a/tpke/Cargo.toml b/ferveo-tpke/Cargo.toml
similarity index 100%
rename from tpke/Cargo.toml
rename to ferveo-tpke/Cargo.toml
diff --git a/tpke/README.md b/ferveo-tpke/README.md
similarity index 100%
rename from tpke/README.md
rename to ferveo-tpke/README.md
diff --git a/tpke/benches/arkworks.rs b/ferveo-tpke/benches/arkworks.rs
similarity index 100%
rename from tpke/benches/arkworks.rs
rename to ferveo-tpke/benches/arkworks.rs
diff --git a/tpke/benches/tpke.rs b/ferveo-tpke/benches/tpke.rs
similarity index 100%
rename from tpke/benches/tpke.rs
rename to ferveo-tpke/benches/tpke.rs
diff --git a/tpke/src/api.rs b/ferveo-tpke/src/api.rs
similarity index 100%
rename from tpke/src/api.rs
rename to ferveo-tpke/src/api.rs
diff --git a/tpke/src/ciphertext.rs b/ferveo-tpke/src/ciphertext.rs
similarity index 100%
rename from tpke/src/ciphertext.rs
rename to ferveo-tpke/src/ciphertext.rs
diff --git a/tpke/src/combine.rs b/ferveo-tpke/src/combine.rs
similarity index 100%
rename from tpke/src/combine.rs
rename to ferveo-tpke/src/combine.rs
diff --git a/tpke/src/context.rs b/ferveo-tpke/src/context.rs
similarity index 100%
rename from tpke/src/context.rs
rename to ferveo-tpke/src/context.rs
diff --git a/tpke/src/decryption.rs b/ferveo-tpke/src/decryption.rs
similarity index 100%
rename from tpke/src/decryption.rs
rename to ferveo-tpke/src/decryption.rs
diff --git a/tpke/src/hash_to_curve.rs b/ferveo-tpke/src/hash_to_curve.rs
similarity index 100%
rename from tpke/src/hash_to_curve.rs
rename to ferveo-tpke/src/hash_to_curve.rs
diff --git a/tpke/src/key_share.rs b/ferveo-tpke/src/key_share.rs
similarity index 100%
rename from tpke/src/key_share.rs
rename to ferveo-tpke/src/key_share.rs
diff --git a/tpke/src/lib.rs b/ferveo-tpke/src/lib.rs
similarity index 100%
rename from tpke/src/lib.rs
rename to ferveo-tpke/src/lib.rs
diff --git a/tpke/src/secret_box.rs b/ferveo-tpke/src/secret_box.rs
similarity index 100%
rename from tpke/src/secret_box.rs
rename to ferveo-tpke/src/secret_box.rs
diff --git a/ferveo/Cargo.toml b/ferveo/Cargo.toml
index 6503ff5c..9289a344 100644
--- a/ferveo/Cargo.toml
+++ b/ferveo/Cargo.toml
@@ -22,7 +22,7 @@ ark-serialize = "0.4"
ark-std = "0.4"
bincode = "1.3"
ferveo-common = { package = "ferveo-common-pre-release", path = "../ferveo-common", version = "^0.1.1" }
-ferveo-tpke = { package = "ferveo-tpke", path = "../tpke", features = ["api", "test-common"], version = "^0.2.0" }
+ferveo-tpke = { package = "ferveo-tpke", path = "../ferveo-tpke", features = ["api", "test-common"], version = "^0.2.0" }
hex = "0.4.3"
itertools = "0.10.5"
measure_time = "0.8"
From b31d167e75743792a2894727be0d35c79e5762c3 Mon Sep 17 00:00:00 2001
From: Piotr Roslaniec
Date: Tue, 31 Oct 2023 15:20:15 +0100
Subject: [PATCH 04/12] chore(linter): fix cargo.toml not sorted
---
Cargo.toml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Cargo.toml b/Cargo.toml
index b7c73f4f..dcf8f61d 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -4,9 +4,9 @@ members = [
"ferveo",
"ferveo-common",
"ferveo-python",
+ "ferveo-tpke",
"ferveo-wasm",
"subproductdomain",
- "ferveo-tpke",
]
[profile.bench]
From 58902b72e84a4803b41ace14916d50675a084f43 Mon Sep 17 00:00:00 2001
From: Piotr Roslaniec
Date: Fri, 3 Nov 2023 12:16:23 +0100
Subject: [PATCH 05/12] chore(linter): add ruff linter
---
.github/workflows/workspace.yml | 6 +-
ferveo-python/ferveo/__init__.pyi | 245 +++++++----------------
ferveo-python/pyproject.toml | 2 +
ferveo-python/setup.py | 8 +-
ferveo-python/test/test_ferveo.py | 21 +-
ferveo-python/test/test_serialization.py | 2 +-
6 files changed, 96 insertions(+), 188 deletions(-)
diff --git a/.github/workflows/workspace.yml b/.github/workflows/workspace.yml
index c8d43415..709f4080 100644
--- a/.github/workflows/workspace.yml
+++ b/.github/workflows/workspace.yml
@@ -176,7 +176,7 @@ jobs:
working-directory: ferveo-python
- name: Install pip dependencies
- run: pip install pytest mypy
+ run: pip install pytest mypy ruff
- name: Run pytest
run: pytest
@@ -186,6 +186,10 @@ jobs:
run: python -m mypy.stubtest ferveo
working-directory: ferveo-python
+ - name: Run ruff
+ run: ruff check .
+ working-directory: ferveo-python
+
codecov:
runs-on: ubuntu-latest
needs: [ test ]
diff --git a/ferveo-python/ferveo/__init__.pyi b/ferveo-python/ferveo/__init__.pyi
index 77c1746e..a7c5abb6 100644
--- a/ferveo-python/ferveo/__init__.pyi
+++ b/ferveo-python/ferveo/__init__.pyi
@@ -1,121 +1,78 @@
from typing import Sequence, final
-
@final
class Keypair:
@staticmethod
- def random() -> Keypair:
- ...
-
+ def random() -> Keypair: ...
@staticmethod
- def from_secure_randomness(secure_randomness: bytes) -> Keypair:
- ...
-
+ def from_secure_randomness(secure_randomness: bytes) -> Keypair: ...
@staticmethod
- def secure_randomness_size() -> int:
- ...
-
+ def secure_randomness_size() -> int: ...
@staticmethod
- def from_bytes(data: bytes) -> Keypair:
- ...
-
- def __bytes__(self) -> bytes:
- ...
-
- def public_key(self) -> FerveoPublicKey:
- ...
-
+ def from_bytes(data: bytes) -> Keypair: ...
+ def __bytes__(self) -> bytes: ...
+ def public_key(self) -> FerveoPublicKey: ...
@final
class FerveoPublicKey:
@staticmethod
- def from_bytes(data: bytes) -> FerveoPublicKey:
- ...
-
- def __bytes__(self) -> bytes:
- ...
-
- def __hash__(self) -> int:
- ...
-
+ def from_bytes(data: bytes) -> FerveoPublicKey: ...
+ def __bytes__(self) -> bytes: ...
+ def __hash__(self) -> int: ...
@staticmethod
- def serialized_size() -> int:
- ...
-
- def __eq__(self, other: object) -> bool:
- ...
-
+ def serialized_size() -> int: ...
+ def __eq__(self, other: object) -> bool: ...
@final
class Validator:
-
- def __init__(self, address: str, public_key: FerveoPublicKey):
- ...
+ def __init__(self, address: str, public_key: FerveoPublicKey): ...
address: str
public_key: FerveoPublicKey
-
@final
class Transcript:
@staticmethod
- def from_bytes(data: bytes) -> Transcript:
- ...
-
- def __bytes__(self) -> bytes:
- ...
-
+ def from_bytes(data: bytes) -> Transcript: ...
+ def __bytes__(self) -> bytes: ...
@final
class DkgPublicKey:
@staticmethod
- def from_bytes(data: bytes) -> DkgPublicKey:
- ...
-
- def __bytes__(self) -> bytes:
- ...
-
+ def from_bytes(data: bytes) -> DkgPublicKey: ...
+ def __bytes__(self) -> bytes: ...
@staticmethod
- def serialized_size() -> int:
- ...
-
+ def serialized_size() -> int: ...
@final
class ValidatorMessage:
-
def __init__(
- self,
- validator: Validator,
- transcript: Transcript,
- ):
- ...
+ self,
+ validator: Validator,
+ transcript: Transcript,
+ ): ...
validator: Validator
transcript: Transcript
-
@final
class Dkg:
-
def __init__(
- self,
- tau: int,
- shares_num: int,
- security_threshold: int,
- validators: Sequence[Validator],
- me: Validator,
- ):
- ...
+ self,
+ tau: int,
+ shares_num: int,
+ security_threshold: int,
+ validators: Sequence[Validator],
+ me: Validator,
+ ): ...
public_key: DkgPublicKey
- def generate_transcript(self) -> Transcript:
- ...
-
- def aggregate_transcripts(self, messages: Sequence[ValidatorMessage]) -> AggregatedTranscript:
- ...
-
+ def generate_transcript(self) -> Transcript: ...
+ def aggregate_transcripts(
+ self, messages: Sequence[ValidatorMessage]
+ ) -> AggregatedTranscript: ...
@final
class Ciphertext:
@@ -123,184 +80,120 @@ class Ciphertext:
payload: bytes
@staticmethod
- def from_bytes(data: bytes) -> Ciphertext:
- ...
-
- def __bytes__(self) -> bytes:
- ...
-
+ def from_bytes(data: bytes) -> Ciphertext: ...
+ def __bytes__(self) -> bytes: ...
@final
class CiphertextHeader:
@staticmethod
- def from_bytes(data: bytes) -> CiphertextHeader:
- ...
-
- def __bytes__(self) -> bytes:
- ...
-
+ def from_bytes(data: bytes) -> CiphertextHeader: ...
+ def __bytes__(self) -> bytes: ...
@final
class DecryptionShareSimple:
@staticmethod
- def from_bytes(data: bytes) -> DecryptionShareSimple:
- ...
-
- def __bytes__(self) -> bytes:
- ...
-
+ def from_bytes(data: bytes) -> DecryptionShareSimple: ...
+ def __bytes__(self) -> bytes: ...
@final
class DecryptionSharePrecomputed:
@staticmethod
- def from_bytes(data: bytes) -> DecryptionSharePrecomputed:
- ...
-
- def __bytes__(self) -> bytes:
- ...
-
+ def from_bytes(data: bytes) -> DecryptionSharePrecomputed: ...
+ def __bytes__(self) -> bytes: ...
@final
class AggregatedTranscript:
-
- def __init__(self, messages: Sequence[ValidatorMessage]):
- ...
-
- def verify(self, shares_num: int, messages: Sequence[ValidatorMessage]) -> bool:
- ...
-
+ def __init__(self, messages: Sequence[ValidatorMessage]): ...
+ def verify(self, shares_num: int, messages: Sequence[ValidatorMessage]) -> bool: ...
def create_decryption_share_simple(
- self,
- dkg: Dkg,
- ciphertext_header: CiphertextHeader,
- aad: bytes,
- validator_keypair: Keypair
- ) -> DecryptionShareSimple:
- ...
-
+ self,
+ dkg: Dkg,
+ ciphertext_header: CiphertextHeader,
+ aad: bytes,
+ validator_keypair: Keypair,
+ ) -> DecryptionShareSimple: ...
def create_decryption_share_precomputed(
- self,
- dkg: Dkg,
- ciphertext_header: CiphertextHeader,
- aad: bytes,
- validator_keypair: Keypair
- ) -> DecryptionSharePrecomputed:
- ...
-
+ self,
+ dkg: Dkg,
+ ciphertext_header: CiphertextHeader,
+ aad: bytes,
+ validator_keypair: Keypair,
+ ) -> DecryptionSharePrecomputed: ...
@staticmethod
- def from_bytes(data: bytes) -> AggregatedTranscript:
- ...
-
- def __bytes__(self) -> bytes:
- ...
-
+ def from_bytes(data: bytes) -> AggregatedTranscript: ...
+ def __bytes__(self) -> bytes: ...
@final
class SharedSecret:
-
@staticmethod
- def from_bytes(data: bytes) -> SharedSecret:
- ...
-
- def __bytes__(self) -> bytes:
- ...
-
+ def from_bytes(data: bytes) -> SharedSecret: ...
+ def __bytes__(self) -> bytes: ...
@final
class FerveoVariant:
Simple: FerveoVariant
Precomputed: FerveoVariant
- def __eq__(self, other: object) -> bool:
- ...
-
- def __hash__(self) -> int:
- ...
-
-
-def encrypt(message: bytes, aad: bytes, dkg_public_key: DkgPublicKey) -> Ciphertext:
- ...
-
+ def __eq__(self, other: object) -> bool: ...
+ def __hash__(self) -> int: ...
+def encrypt(message: bytes, aad: bytes, dkg_public_key: DkgPublicKey) -> Ciphertext: ...
def combine_decryption_shares_simple(
- decryption_shares: Sequence[DecryptionShareSimple],
-) -> SharedSecret:
- ...
-
-
+ decryption_shares: Sequence[DecryptionShareSimple],
+) -> SharedSecret: ...
def combine_decryption_shares_precomputed(
- decryption_shares: Sequence[DecryptionSharePrecomputed],
-) -> SharedSecret:
- ...
-
-
+ decryption_shares: Sequence[DecryptionSharePrecomputed],
+) -> SharedSecret: ...
def decrypt_with_shared_secret(
- ciphertext: Ciphertext,
- aad: bytes,
- shared_secret: SharedSecret,
-) -> bytes:
- ...
-
+ ciphertext: Ciphertext,
+ aad: bytes,
+ shared_secret: SharedSecret,
+) -> bytes: ...
class ThresholdEncryptionError(Exception):
pass
-
class InvalidDkgStateToDeal(Exception):
pass
-
class InvalidDkgStateToAggregate(Exception):
pass
-
class InvalidDkgStateToVerify(Exception):
pass
-
class InvalidDkgStateToIngest(Exception):
pass
-
class DealerNotInValidatorSet(Exception):
pass
-
class UnknownDealer(Exception):
pass
-
class DuplicateDealer(Exception):
pass
-
class InvalidPvssTranscript(Exception):
pass
-
class InsufficientTranscriptsForAggregate(Exception):
pass
-
class InvalidDkgPublicKey(Exception):
pass
-
class InsufficientValidators(Exception):
pass
-
class InvalidTranscriptAggregate(Exception):
pass
-
class ValidatorsNotSorted(Exception):
pass
-
class ValidatorPublicKeyMismatch(Exception):
pass
-
class SerializationError(Exception):
pass
diff --git a/ferveo-python/pyproject.toml b/ferveo-python/pyproject.toml
index f92911b2..610492e4 100644
--- a/ferveo-python/pyproject.toml
+++ b/ferveo-python/pyproject.toml
@@ -1,4 +1,6 @@
[build-system]
requires = ["setuptools", "wheel", "setuptools-rust"]
+[tool.ruff]
+exclude = ["ferveo/__init__.py"]
diff --git a/ferveo-python/setup.py b/ferveo-python/setup.py
index 25e9d1de..1c8ea4fb 100644
--- a/ferveo-python/setup.py
+++ b/ferveo-python/setup.py
@@ -2,6 +2,7 @@
from setuptools_rust import Binding, RustExtension
from pathlib import Path
+
this_directory = Path(__file__).parent
long_description = (this_directory / "README.md").read_text()
@@ -14,11 +15,12 @@
author="Piotr Roslaniec",
author_email="p.roslaniec@gmail.com",
url="https://github.com/nucypher/ferveo/tree/master/ferveo-python",
- rust_extensions=[RustExtension(
- "ferveo._ferveo", binding=Binding.PyO3, debug=False)],
+ rust_extensions=[
+ RustExtension("ferveo._ferveo", binding=Binding.PyO3, debug=False)
+ ],
packages=["ferveo"],
package_data={
- 'ferveo': ['py.typed', '__init__.pyi'],
+ "ferveo": ["py.typed", "__init__.pyi"],
},
# rust extensions are not zip safe, just like C-extensions.
zip_safe=False,
diff --git a/ferveo-python/test/test_ferveo.py b/ferveo-python/test/test_ferveo.py
index 42a82a84..6f00b6df 100644
--- a/ferveo-python/test/test_ferveo.py
+++ b/ferveo-python/test/test_ferveo.py
@@ -9,10 +9,9 @@
Validator,
ValidatorMessage,
Dkg,
- AggregatedTranscript,
DkgPublicKey,
ThresholdEncryptionError,
- FerveoVariant
+ FerveoVariant,
)
@@ -114,19 +113,27 @@ def scenario_for_variant(variant: FerveoVariant, shares_num, threshold, shares_t
def test_simple_tdec_has_enough_messages():
- scenario_for_variant(FerveoVariant.Simple, shares_num=4, threshold=3, shares_to_use=3)
+ scenario_for_variant(
+ FerveoVariant.Simple, shares_num=4, threshold=3, shares_to_use=3
+ )
def test_simple_tdec_doesnt_have_enough_messages():
- scenario_for_variant(FerveoVariant.Simple, shares_num=4, threshold=3, shares_to_use=2)
+ scenario_for_variant(
+ FerveoVariant.Simple, shares_num=4, threshold=3, shares_to_use=2
+ )
def test_precomputed_tdec_has_enough_messages():
- scenario_for_variant(FerveoVariant.Precomputed, shares_num=4, threshold=4, shares_to_use=4)
+ scenario_for_variant(
+ FerveoVariant.Precomputed, shares_num=4, threshold=4, shares_to_use=4
+ )
def test_precomputed_tdec_doesnt_have_enough_messages():
- scenario_for_variant(FerveoVariant.Precomputed, shares_num=4, threshold=4, shares_to_use=3)
+ scenario_for_variant(
+ FerveoVariant.Precomputed, shares_num=4, threshold=4, shares_to_use=3
+ )
PARAMS = [
@@ -143,7 +150,7 @@ def test_precomputed_tdec_doesnt_have_enough_messages():
]
TEST_CASES_WITH_THRESHOLD_RANGE = []
-for (shares_num, variant) in PARAMS:
+for shares_num, variant in PARAMS:
for threshold in range(1, shares_num):
TEST_CASES_WITH_THRESHOLD_RANGE.append((variant, shares_num, threshold))
diff --git a/ferveo-python/test/test_serialization.py b/ferveo-python/test/test_serialization.py
index 8533d437..57032c6a 100644
--- a/ferveo-python/test/test_serialization.py
+++ b/ferveo-python/test/test_serialization.py
@@ -5,7 +5,6 @@
DkgPublicKey,
FerveoPublicKey,
FerveoVariant,
- SharedSecret,
)
@@ -54,6 +53,7 @@ def make_pk():
# # assert shared_secret == deserialized
# assert serialized == bytes(deserialized)
+
def test_keypair_serialization():
keypair = Keypair.random()
serialized = bytes(keypair)
From 608cddc6f84bd1fcd652eb263515f21f61489c56 Mon Sep 17 00:00:00 2001
From: Piotr Roslaniec
Date: Sun, 5 Nov 2023 09:19:39 +0100
Subject: [PATCH 06/12] chore(python): update supported python versions
---
.github/workflows/workspace.yml | 2 +-
Pipfile | 2 +-
ferveo-python/Pipfile | 2 +-
ferveo-python/setup.py | 4 ++--
4 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/.github/workflows/workspace.yml b/.github/workflows/workspace.yml
index 709f4080..9266f268 100644
--- a/.github/workflows/workspace.yml
+++ b/.github/workflows/workspace.yml
@@ -148,7 +148,7 @@ jobs:
target:
- wasm32-unknown-unknown
python:
- - "3.10"
+ - "3.12"
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
diff --git a/Pipfile b/Pipfile
index c398b0d5..645a67ea 100644
--- a/Pipfile
+++ b/Pipfile
@@ -8,4 +8,4 @@ name = "pypi"
[dev-packages]
[requires]
-python_version = "3.10"
+python_version = "3.12"
diff --git a/ferveo-python/Pipfile b/ferveo-python/Pipfile
index c398b0d5..645a67ea 100644
--- a/ferveo-python/Pipfile
+++ b/ferveo-python/Pipfile
@@ -8,4 +8,4 @@ name = "pypi"
[dev-packages]
[requires]
-python_version = "3.10"
+python_version = "3.12"
diff --git a/ferveo-python/setup.py b/ferveo-python/setup.py
index 1c8ea4fb..99e1d715 100644
--- a/ferveo-python/setup.py
+++ b/ferveo-python/setup.py
@@ -32,10 +32,10 @@
"Programming Language :: Rust",
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: 3 :: Only",
- "Programming Language :: Python :: 3.7",
- "Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
+ "Programming Language :: Python :: 3.11",
+ "Programming Language :: Python :: 3.12",
"Topic :: Security :: Cryptography",
],
)
From 2afd0fa122e0b41472d3279a17fb18594504a272 Mon Sep 17 00:00:00 2001
From: Piotr Roslaniec
Date: Tue, 7 Nov 2023 11:04:30 +0100
Subject: [PATCH 07/12] chore(ruff): use nucypher-compatible ruff rules
---
.github/workflows/workspace.yml | 2 +-
ferveo-python/pyproject.toml | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/.github/workflows/workspace.yml b/.github/workflows/workspace.yml
index 9266f268..9acd2f1a 100644
--- a/.github/workflows/workspace.yml
+++ b/.github/workflows/workspace.yml
@@ -187,7 +187,7 @@ jobs:
working-directory: ferveo-python
- name: Run ruff
- run: ruff check .
+ run: ruff check ferveo
working-directory: ferveo-python
codecov:
diff --git a/ferveo-python/pyproject.toml b/ferveo-python/pyproject.toml
index 610492e4..2532c800 100644
--- a/ferveo-python/pyproject.toml
+++ b/ferveo-python/pyproject.toml
@@ -2,5 +2,5 @@
requires = ["setuptools", "wheel", "setuptools-rust"]
[tool.ruff]
-exclude = ["ferveo/__init__.py"]
-
+exclude = ["ferveo/__init__.py"] # false-positive unused-import
+select = ["E", "F", "I"]
From 58002f50155df31a11b9d58d94750a2ed1076102 Mon Sep 17 00:00:00 2001
From: Piotr Roslaniec
Date: Tue, 7 Nov 2023 11:36:05 +0100
Subject: [PATCH 08/12] chore(refactor): rename ferveo-tpke package to
ferveo-tdec
---
Cargo.lock | 4 +-
Cargo.toml | 2 +-
{ferveo-tpke => ferveo-tdec}/BENCHMARK.md | 0
{ferveo-tpke => ferveo-tdec}/CHANGELOG.md | 0
{ferveo-tpke => ferveo-tdec}/Cargo.toml | 2 +-
{ferveo-tpke => ferveo-tdec}/README.md | 2 +-
.../benches/arkworks.rs | 0
{ferveo-tpke => ferveo-tdec}/benches/tpke.rs | 2 +-
{ferveo-tpke => ferveo-tdec}/src/api.rs | 0
.../src/ciphertext.rs | 0
{ferveo-tpke => ferveo-tdec}/src/combine.rs | 0
{ferveo-tpke => ferveo-tdec}/src/context.rs | 0
.../src/decryption.rs | 0
.../src/hash_to_curve.rs | 0
{ferveo-tpke => ferveo-tdec}/src/key_share.rs | 0
{ferveo-tpke => ferveo-tdec}/src/lib.rs | 0
.../src/secret_box.rs | 0
ferveo/Cargo.toml | 2 +-
ferveo/src/api.rs | 18 ++++-----
ferveo/src/bindings_wasm.rs | 4 +-
ferveo/src/lib.rs | 38 +++++++++----------
ferveo/src/pvss.rs | 2 +-
ferveo/src/refresh.rs | 4 +-
23 files changed, 40 insertions(+), 40 deletions(-)
rename {ferveo-tpke => ferveo-tdec}/BENCHMARK.md (100%)
rename {ferveo-tpke => ferveo-tdec}/CHANGELOG.md (100%)
rename {ferveo-tpke => ferveo-tdec}/Cargo.toml (98%)
rename {ferveo-tpke => ferveo-tdec}/README.md (97%)
rename {ferveo-tpke => ferveo-tdec}/benches/arkworks.rs (100%)
rename {ferveo-tpke => ferveo-tdec}/benches/tpke.rs (99%)
rename {ferveo-tpke => ferveo-tdec}/src/api.rs (100%)
rename {ferveo-tpke => ferveo-tdec}/src/ciphertext.rs (100%)
rename {ferveo-tpke => ferveo-tdec}/src/combine.rs (100%)
rename {ferveo-tpke => ferveo-tdec}/src/context.rs (100%)
rename {ferveo-tpke => ferveo-tdec}/src/decryption.rs (100%)
rename {ferveo-tpke => ferveo-tdec}/src/hash_to_curve.rs (100%)
rename {ferveo-tpke => ferveo-tdec}/src/key_share.rs (100%)
rename {ferveo-tpke => ferveo-tdec}/src/lib.rs (100%)
rename {ferveo-tpke => ferveo-tdec}/src/secret_box.rs (100%)
diff --git a/Cargo.lock b/Cargo.lock
index f8a43ed7..7aa7e272 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -771,7 +771,7 @@ dependencies = [
"derive_more",
"digest",
"ferveo-common-pre-release",
- "ferveo-tpke",
+ "ferveo-tdec",
"generic-array",
"getrandom 0.2.9",
"hex",
@@ -802,7 +802,7 @@ dependencies = [
]
[[package]]
-name = "ferveo-tpke"
+name = "ferveo-tdec"
version = "0.2.0"
dependencies = [
"ark-bls12-381",
diff --git a/Cargo.toml b/Cargo.toml
index dcf8f61d..3af8d039 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -4,7 +4,7 @@ members = [
"ferveo",
"ferveo-common",
"ferveo-python",
- "ferveo-tpke",
+ "ferveo-tdec",
"ferveo-wasm",
"subproductdomain",
]
diff --git a/ferveo-tpke/BENCHMARK.md b/ferveo-tdec/BENCHMARK.md
similarity index 100%
rename from ferveo-tpke/BENCHMARK.md
rename to ferveo-tdec/BENCHMARK.md
diff --git a/ferveo-tpke/CHANGELOG.md b/ferveo-tdec/CHANGELOG.md
similarity index 100%
rename from ferveo-tpke/CHANGELOG.md
rename to ferveo-tdec/CHANGELOG.md
diff --git a/ferveo-tpke/Cargo.toml b/ferveo-tdec/Cargo.toml
similarity index 98%
rename from ferveo-tpke/Cargo.toml
rename to ferveo-tdec/Cargo.toml
index 0c1bd626..cfc7e3f1 100644
--- a/ferveo-tpke/Cargo.toml
+++ b/ferveo-tdec/Cargo.toml
@@ -1,5 +1,5 @@
[package]
-name = "ferveo-tpke"
+name = "ferveo-tdec"
version = "0.2.0"
edition = "2021"
authors = ["Heliax AG ", "Piotr Roslaniec "]
diff --git a/ferveo-tpke/README.md b/ferveo-tdec/README.md
similarity index 97%
rename from ferveo-tpke/README.md
rename to ferveo-tdec/README.md
index e48dc7ea..b19e9875 100644
--- a/ferveo-tpke/README.md
+++ b/ferveo-tdec/README.md
@@ -1,4 +1,4 @@
-# tpke
+# ferveo-tdec
## Benchmarks
diff --git a/ferveo-tpke/benches/arkworks.rs b/ferveo-tdec/benches/arkworks.rs
similarity index 100%
rename from ferveo-tpke/benches/arkworks.rs
rename to ferveo-tdec/benches/arkworks.rs
diff --git a/ferveo-tpke/benches/tpke.rs b/ferveo-tdec/benches/tpke.rs
similarity index 99%
rename from ferveo-tpke/benches/tpke.rs
rename to ferveo-tdec/benches/tpke.rs
index 287ba81d..e47d6b51 100644
--- a/ferveo-tpke/benches/tpke.rs
+++ b/ferveo-tdec/benches/tpke.rs
@@ -5,7 +5,7 @@ use ark_ec::pairing::Pairing;
use criterion::{
black_box, criterion_group, criterion_main, BenchmarkId, Criterion,
};
-use ferveo_tpke::{
+use ferveo_tdec::{
test_common::{setup_fast, setup_simple},
*,
};
diff --git a/ferveo-tpke/src/api.rs b/ferveo-tdec/src/api.rs
similarity index 100%
rename from ferveo-tpke/src/api.rs
rename to ferveo-tdec/src/api.rs
diff --git a/ferveo-tpke/src/ciphertext.rs b/ferveo-tdec/src/ciphertext.rs
similarity index 100%
rename from ferveo-tpke/src/ciphertext.rs
rename to ferveo-tdec/src/ciphertext.rs
diff --git a/ferveo-tpke/src/combine.rs b/ferveo-tdec/src/combine.rs
similarity index 100%
rename from ferveo-tpke/src/combine.rs
rename to ferveo-tdec/src/combine.rs
diff --git a/ferveo-tpke/src/context.rs b/ferveo-tdec/src/context.rs
similarity index 100%
rename from ferveo-tpke/src/context.rs
rename to ferveo-tdec/src/context.rs
diff --git a/ferveo-tpke/src/decryption.rs b/ferveo-tdec/src/decryption.rs
similarity index 100%
rename from ferveo-tpke/src/decryption.rs
rename to ferveo-tdec/src/decryption.rs
diff --git a/ferveo-tpke/src/hash_to_curve.rs b/ferveo-tdec/src/hash_to_curve.rs
similarity index 100%
rename from ferveo-tpke/src/hash_to_curve.rs
rename to ferveo-tdec/src/hash_to_curve.rs
diff --git a/ferveo-tpke/src/key_share.rs b/ferveo-tdec/src/key_share.rs
similarity index 100%
rename from ferveo-tpke/src/key_share.rs
rename to ferveo-tdec/src/key_share.rs
diff --git a/ferveo-tpke/src/lib.rs b/ferveo-tdec/src/lib.rs
similarity index 100%
rename from ferveo-tpke/src/lib.rs
rename to ferveo-tdec/src/lib.rs
diff --git a/ferveo-tpke/src/secret_box.rs b/ferveo-tdec/src/secret_box.rs
similarity index 100%
rename from ferveo-tpke/src/secret_box.rs
rename to ferveo-tdec/src/secret_box.rs
diff --git a/ferveo/Cargo.toml b/ferveo/Cargo.toml
index 9289a344..9ab8ec9b 100644
--- a/ferveo/Cargo.toml
+++ b/ferveo/Cargo.toml
@@ -22,7 +22,7 @@ ark-serialize = "0.4"
ark-std = "0.4"
bincode = "1.3"
ferveo-common = { package = "ferveo-common-pre-release", path = "../ferveo-common", version = "^0.1.1" }
-ferveo-tpke = { package = "ferveo-tpke", path = "../ferveo-tpke", features = ["api", "test-common"], version = "^0.2.0" }
+ferveo-tdec = { package = "ferveo-tdec", path = "../ferveo-tdec", features = ["api", "test-common"], version = "^0.2.0" }
hex = "0.4.3"
itertools = "0.10.5"
measure_time = "0.8"
diff --git a/ferveo/src/api.rs b/ferveo/src/api.rs
index 9f83eca0..af3edcd4 100644
--- a/ferveo/src/api.rs
+++ b/ferveo/src/api.rs
@@ -5,7 +5,7 @@ use ark_serialize::{CanonicalDeserialize, CanonicalSerialize};
use ark_std::UniformRand;
use bincode;
use ferveo_common::serialization;
-pub use ferveo_tpke::api::{
+pub use ferveo_tdec::api::{
prepare_combine_simple, share_combine_precomputed, share_combine_simple,
Fr, G1Affine, G1Prepared, G2Affine, SecretBox, E,
};
@@ -31,7 +31,7 @@ use crate::{
};
pub type DecryptionSharePrecomputed =
- ferveo_tpke::api::DecryptionSharePrecomputed;
+ ferveo_tdec::api::DecryptionSharePrecomputed;
// Normally, we would use a custom trait for this, but we can't because
// the arkworks will not let us create a blanket implementation for G1Affine
@@ -55,7 +55,7 @@ pub fn encrypt(
) -> Result {
let mut rng = rand::thread_rng();
let ciphertext =
- ferveo_tpke::api::encrypt(message, aad, &pubkey.0, &mut rng)?;
+ ferveo_tdec::api::encrypt(message, aad, &pubkey.0, &mut rng)?;
Ok(Ciphertext(ciphertext))
}
@@ -65,7 +65,7 @@ pub fn decrypt_with_shared_secret(
shared_secret: &SharedSecret,
) -> Result> {
let dkg_public_params = DkgPublicParameters::default();
- ferveo_tpke::api::decrypt_with_shared_secret(
+ ferveo_tdec::api::decrypt_with_shared_secret(
&ciphertext.0,
aad,
&shared_secret.0,
@@ -75,7 +75,7 @@ pub fn decrypt_with_shared_secret(
}
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, Eq)]
-pub struct Ciphertext(ferveo_tpke::api::Ciphertext);
+pub struct Ciphertext(ferveo_tdec::api::Ciphertext);
impl Ciphertext {
pub fn header(&self) -> Result {
@@ -89,7 +89,7 @@ impl Ciphertext {
#[serde_as]
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq)]
-pub struct CiphertextHeader(ferveo_tpke::api::CiphertextHeader);
+pub struct CiphertextHeader(ferveo_tdec::api::CiphertextHeader);
/// The ferveo variant to use for the decryption share derivation.
#[derive(
@@ -348,7 +348,7 @@ impl AggregatedTranscript {
#[serde_as]
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct DecryptionShareSimple {
- share: ferveo_tpke::api::DecryptionShareSimple,
+ share: ferveo_tdec::api::DecryptionShareSimple,
#[serde_as(as = "serialization::SerdeAs")]
domain_point: Fr,
}
@@ -390,11 +390,11 @@ pub fn combine_shares_simple(shares: &[DecryptionShareSimple]) -> SharedSecret {
}
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
-pub struct SharedSecret(pub ferveo_tpke::api::SharedSecret);
+pub struct SharedSecret(pub ferveo_tdec::api::SharedSecret);
#[cfg(test)]
mod test_ferveo_api {
- use ferveo_tpke::SecretBox;
+ use ferveo_tdec::SecretBox;
use itertools::izip;
use rand::{prelude::StdRng, SeedableRng};
diff --git a/ferveo/src/bindings_wasm.rs b/ferveo/src/bindings_wasm.rs
index 30defbaa..e412b6e0 100644
--- a/ferveo/src/bindings_wasm.rs
+++ b/ferveo/src/bindings_wasm.rs
@@ -5,7 +5,7 @@ use std::{
};
use ferveo_common::{FromBytes, ToBytes};
-use ferveo_tpke::SecretBox;
+use ferveo_tdec::SecretBox;
use js_sys::Error;
use rand::thread_rng;
use serde::{Deserialize, Serialize};
@@ -201,7 +201,7 @@ generate_common_methods!(DecryptionShareSimple);
#[wasm_bindgen]
#[derive(Clone, Debug, derive_more::AsRef, derive_more::From)]
pub struct DecryptionSharePrecomputed(
- ferveo_tpke::api::DecryptionSharePrecomputed,
+ ferveo_tdec::api::DecryptionSharePrecomputed,
);
generate_common_methods!(DecryptionSharePrecomputed);
diff --git a/ferveo/src/lib.rs b/ferveo/src/lib.rs
index d999ca11..59a44024 100644
--- a/ferveo/src/lib.rs
+++ b/ferveo/src/lib.rs
@@ -30,7 +30,7 @@ pub use validator::*;
#[derive(Debug, thiserror::Error)]
pub enum Error {
#[error(transparent)]
- ThresholdEncryptionError(#[from] ferveo_tpke::Error),
+ ThresholdEncryptionError(#[from] ferveo_tdec::Error),
/// DKG is not in a valid state to deal PVSS shares
#[error("Invalid DKG state to deal PVSS shares")]
@@ -126,7 +126,7 @@ mod test_dkg_full {
use ark_poly::EvaluationDomain;
use ark_std::test_rng;
use ferveo_common::Keypair;
- use ferveo_tpke::{
+ use ferveo_tdec::{
self, DecryptionSharePrecomputed, DecryptionShareSimple, SecretBox,
SharedSecret,
};
@@ -140,7 +140,7 @@ mod test_dkg_full {
fn make_shared_secret_simple_tdec(
dkg: &PubliclyVerifiableDkg,
aad: &[u8],
- ciphertext_header: &ferveo_tpke::CiphertextHeader,
+ ciphertext_header: &ferveo_tdec::CiphertextHeader,
validator_keypairs: &[Keypair],
) -> (
PubliclyVerifiableSS,
@@ -176,12 +176,12 @@ mod test_dkg_full {
.collect::>();
assert_eq!(domain_points.len(), decryption_shares.len());
- // TODO: Consider refactor this part into ferveo_tpke::combine_simple and expose it
- // as a public API in ferveo_tpke::api
+ // TODO: Consider refactor this part into ferveo_tdec::combine_simple and expose it
+ // as a public API in ferveo_tdec::api
let lagrange_coeffs =
- ferveo_tpke::prepare_combine_simple::(domain_points);
- let shared_secret = ferveo_tpke::share_combine_simple::(
+ ferveo_tdec::prepare_combine_simple::(domain_points);
+ let shared_secret = ferveo_tdec::share_combine_simple::(
&decryption_shares,
&lagrange_coeffs,
);
@@ -201,7 +201,7 @@ mod test_dkg_full {
let msg = "my-msg".as_bytes().to_vec();
let aad: &[u8] = "my-aad".as_bytes();
let public_key = dkg.public_key();
- let ciphertext = ferveo_tpke::encrypt::(
+ let ciphertext = ferveo_tdec::encrypt::(
SecretBox::new(msg.clone()),
aad,
&public_key,
@@ -216,7 +216,7 @@ mod test_dkg_full {
validator_keypairs.as_slice(),
);
- let plaintext = ferveo_tpke::decrypt_with_shared_secret(
+ let plaintext = ferveo_tdec::decrypt_with_shared_secret(
&ciphertext,
aad,
&shared_secret,
@@ -240,7 +240,7 @@ mod test_dkg_full {
let msg = "my-msg".as_bytes().to_vec();
let aad: &[u8] = "my-aad".as_bytes();
let public_key = dkg.public_key();
- let ciphertext = ferveo_tpke::encrypt::(
+ let ciphertext = ferveo_tdec::encrypt::(
SecretBox::new(msg.clone()),
aad,
&public_key,
@@ -278,10 +278,10 @@ mod test_dkg_full {
assert_eq!(domain_points.len(), decryption_shares.len());
let shared_secret =
- ferveo_tpke::share_combine_precomputed::(&decryption_shares);
+ ferveo_tdec::share_combine_precomputed::(&decryption_shares);
// Combination works, let's decrypt
- let plaintext = ferveo_tpke::decrypt_with_shared_secret(
+ let plaintext = ferveo_tdec::decrypt_with_shared_secret(
&ciphertext,
aad,
&shared_secret,
@@ -300,7 +300,7 @@ mod test_dkg_full {
let msg = "my-msg".as_bytes().to_vec();
let aad: &[u8] = "my-aad".as_bytes();
let public_key = dkg.public_key();
- let ciphertext = ferveo_tpke::encrypt::(
+ let ciphertext = ferveo_tdec::encrypt::(
SecretBox::new(msg),
aad,
&public_key,
@@ -367,7 +367,7 @@ mod test_dkg_full {
let msg = "my-msg".as_bytes().to_vec();
let aad: &[u8] = "my-aad".as_bytes();
let public_key = &dkg.public_key();
- let ciphertext = ferveo_tpke::encrypt::(
+ let ciphertext = ferveo_tdec::encrypt::(
SecretBox::new(msg),
aad,
public_key,
@@ -503,8 +503,8 @@ mod test_dkg_full {
assert_eq!(domain_points.len(), security_threshold as usize);
assert_eq!(decryption_shares.len(), security_threshold as usize);
- let lagrange = ferveo_tpke::prepare_combine_simple::(domain_points);
- let new_shared_secret = ferveo_tpke::share_combine_simple::(
+ let lagrange = ferveo_tdec::prepare_combine_simple::(domain_points);
+ let new_shared_secret = ferveo_tdec::share_combine_simple::(
decryption_shares,
&lagrange,
);
@@ -526,7 +526,7 @@ mod test_dkg_full {
let msg = "my-msg".as_bytes().to_vec();
let aad: &[u8] = "my-aad".as_bytes();
let public_key = &dkg.public_key();
- let ciphertext = ferveo_tpke::encrypt::(
+ let ciphertext = ferveo_tdec::encrypt::(
SecretBox::new(msg),
aad,
public_key,
@@ -607,10 +607,10 @@ mod test_dkg_full {
})
.collect();
- let lagrange = ferveo_tpke::prepare_combine_simple::(
+ let lagrange = ferveo_tdec::prepare_combine_simple::(
&domain_points[..security_threshold as usize],
);
- let new_shared_secret = ferveo_tpke::share_combine_simple::(
+ let new_shared_secret = ferveo_tdec::share_combine_simple::(
&decryption_shares[..security_threshold as usize],
&lagrange,
);
diff --git a/ferveo/src/pvss.rs b/ferveo/src/pvss.rs
index 3e28dd67..4f63da82 100644
--- a/ferveo/src/pvss.rs
+++ b/ferveo/src/pvss.rs
@@ -6,7 +6,7 @@ use ark_poly::{
polynomial::univariate::DensePolynomial, DenseUVPolynomial,
EvaluationDomain,
};
-use ferveo_tpke::{
+use ferveo_tdec::{
prepare_combine_simple, CiphertextHeader, DecryptionSharePrecomputed,
DecryptionShareSimple, PrivateKeyShare,
};
diff --git a/ferveo/src/refresh.rs b/ferveo/src/refresh.rs
index 9b1ed904..c9e692d4 100644
--- a/ferveo/src/refresh.rs
+++ b/ferveo/src/refresh.rs
@@ -3,7 +3,7 @@ use std::{ops::Mul, usize};
use ark_ec::{pairing::Pairing, AffineRepr, CurveGroup};
use ark_ff::Zero;
use ark_poly::{univariate::DensePolynomial, DenseUVPolynomial, Polynomial};
-use ferveo_tpke::{lagrange_basis_at, PrivateKeyShare};
+use ferveo_tdec::{lagrange_basis_at, PrivateKeyShare};
use itertools::zip_eq;
use rand_core::RngCore;
@@ -129,7 +129,7 @@ mod tests_refresh {
type E = ark_bls12_381::Bls12_381;
type ScalarField = ::ScalarField;
- use ferveo_tpke::{
+ use ferveo_tdec::{
test_common::setup_simple, PrivateDecryptionContextSimple,
PrivateKeyShare,
};
From 07c907a0e59640bca86942c495dfa99ac5ac7898 Mon Sep 17 00:00:00 2001
From: Piotr Roslaniec
Date: Mon, 8 Jan 2024 16:56:31 +0100
Subject: [PATCH 09/12] chore(ci): compile benchmarks on ci
---
.github/workflows/workspace.yml | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/.github/workflows/workspace.yml b/.github/workflows/workspace.yml
index 9acd2f1a..862c90ec 100644
--- a/.github/workflows/workspace.yml
+++ b/.github/workflows/workspace.yml
@@ -213,6 +213,21 @@ jobs:
files: lcov.info
fail_ci_if_error: true
+ compile-benchmarks:
+ # Temporarily replaces "benchmark" job. TODO: Remove this job once the "benchmark" job is fixed.
+ runs-on: ubuntu-latest
+ needs: [ test ]
+ steps:
+ - uses: actions/checkout@v3
+ - uses: actions-rs/toolchain@v1
+ with:
+ profile: minimal
+ toolchain: stable
+ target: x86_64-unknown-linux-gnu
+ override: true
+ - name: Compile benchmarks
+ run: cargo bench --no-run --no-default-features
+
benchmark:
# TODO: This job is failing with error:
From 749a846bb9a5c129bbc0cf7ff25a84ca6dbdb8a5 Mon Sep 17 00:00:00 2001
From: Piotr Roslaniec
Date: Mon, 8 Jan 2024 17:01:16 +0100
Subject: [PATCH 10/12] chore: remove unused curves
---
ferveo/benches/benchmarks/pairing.rs | 105 +--------------------------
ferveo/src/dkg.rs | 2 +-
2 files changed, 2 insertions(+), 105 deletions(-)
diff --git a/ferveo/benches/benchmarks/pairing.rs b/ferveo/benches/benchmarks/pairing.rs
index 47cce6ad..f4c957c4 100644
--- a/ferveo/benches/benchmarks/pairing.rs
+++ b/ferveo/benches/benchmarks/pairing.rs
@@ -3,11 +3,9 @@
use ark_bls12_381::*;
use ark_ec::*;
use criterion::{black_box, criterion_group, Criterion};
-//use redjubjub::*;
use ark_ff::Field;
use ark_std::UniformRand;
-use ed25519_dalek::verify_batch;
pub fn lagrange(c: &mut Criterion) {
let rng = &mut ark_std::test_rng();
@@ -41,7 +39,7 @@ pub fn lagrange(c: &mut Criterion) {
subproductdomain::SubproductDomain::::new(
u.clone(),
)
- .inverse_lagrange_coefficients(),
+ .inverse_lagrange_coefficients(),
)
})
});
@@ -255,105 +253,6 @@ pub fn pairing(c: &mut Criterion) {
})
});
}
-/*
-enum Item {
- SpendAuth {
- vk_bytes: VerificationKeyBytes,
- sig: Signature,
- },
- Binding {
- vk_bytes: VerificationKeyBytes,
- sig: Signature,
- },
-}
-
-fn sigs_with_distinct_keys() -> impl Iterator- {
- use rand::{thread_rng, Rng};
- std::iter::repeat_with(|| {
- let mut rng = thread_rng();
- let msg = b"Bench";
- match rng.gen::() % 2 {
- 0 => {
- let sk = SigningKey::::new(thread_rng());
- let vk_bytes = VerificationKey::from(&sk).into();
- let sig = sk.sign(thread_rng(), &msg[..]);
- Item::SpendAuth { vk_bytes, sig }
- }
- 1 => {
- let sk = SigningKey::::new(thread_rng());
- let vk_bytes = VerificationKey::from(&sk).into();
- let sig = sk.sign(thread_rng(), &msg[..]);
- Item::Binding { vk_bytes, sig }
- }
- _ => panic!(),
- }
- })
-}
-
-pub fn redjubjub(c: &mut Criterion) {
- let mut group = c.benchmark_group("Redjubjub Batch Verification");
- group.sample_size(10);
- group.measurement_time(core::time::Duration::new(10, 0));
-
- for &n in [1, 100usize, 1024 * 2 / 3, 8192 * 2 / 3].iter() {
- let sigs = sigs_with_distinct_keys().take(n).collect::>();
-
- group.bench_with_input(
- criterion::BenchmarkId::new("Batched verification", n),
- &sigs,
- |b, sigs| {
- b.iter(|| {
- let mut batch = batch::Verifier::new();
- for item in sigs.iter() {
- let msg = b"Bench";
- match item {
- Item::SpendAuth { vk_bytes, sig } => {
- batch.queue((*vk_bytes, *sig, msg));
- }
- Item::Binding { vk_bytes, sig } => {
- batch.queue((*vk_bytes, *sig, msg));
- }
- }
- }
- batch.verify(thread_rng())
- })
- },
- );
- }
- group.finish();
-}*/
-
-fn ed25519_batch(c: &mut Criterion) {
- let mut group = c.benchmark_group("Ed25519 Batch Verification");
- group.sample_size(10);
- group.measurement_time(core::time::Duration::new(10, 0));
-
- use ed25519_dalek::Signer;
- use ed25519_dalek::{Keypair, PublicKey, Signature};
- for &n in [1, 100usize, 1024 * 2 / 3, 8192 * 2 / 3].iter() {
- let mut csprng = rand_old::thread_rng();
- let keypairs: Vec =
- (0..n).map(|_| Keypair::generate(&mut csprng)).collect();
- let msg: &[u8] =
- b"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
- let messages: Vec<&[u8]> = (0..n).map(|_| msg).collect();
- let signatures: Vec =
- keypairs.iter().map(|key| key.sign(msg)).collect();
- let public_keys: Vec =
- keypairs.iter().map(|key| key.public).collect();
-
- group.bench_with_input(
- criterion::BenchmarkId::new(
- "Ed25519 batch signature verification",
- n,
- ),
- &(messages, signatures, public_keys),
- |b, sigs| {
- b.iter(|| verify_batch(&sigs.0, &sigs.1, &sigs.2));
- },
- );
- }
-}
pub fn bench_batch_inverse(c: &mut Criterion) {
let rng = &mut ark_std::test_rng();
@@ -378,8 +277,6 @@ pub fn bench_batch_inverse(c: &mut Criterion) {
criterion_group!(
ec,
pairing,
- //redjubjub,
- ed25519_batch,
lagrange,
bench_batch_inverse
);
diff --git a/ferveo/src/dkg.rs b/ferveo/src/dkg.rs
index 3c9bdf83..fa389458 100644
--- a/ferveo/src/dkg.rs
+++ b/ferveo/src/dkg.rs
@@ -66,7 +66,7 @@ pub struct PubliclyVerifiableDkg {
impl PubliclyVerifiableDkg {
/// Create a new DKG context to participate in the DKG
- /// Every identity in the DKG is linked to an ed25519 public key;
+ /// Every identity in the DKG is linked to a bls12-381 public key;
/// `validators`: List of validators
/// `params` contains the parameters of the DKG such as number of shares
/// `me` the validator creating this instance
From 0e6c03ee643af057ddae5c275d33879019776c5b Mon Sep 17 00:00:00 2001
From: Piotr Roslaniec
Date: Mon, 8 Jan 2024 17:12:54 +0100
Subject: [PATCH 11/12] chore(cargo-machete): fix false-positives in cargo
machete check
---
ferveo/Cargo.toml | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/ferveo/Cargo.toml b/ferveo/Cargo.toml
index 9ab8ec9b..c063c502 100644
--- a/ferveo/Cargo.toml
+++ b/ferveo/Cargo.toml
@@ -76,5 +76,8 @@ path = "benches/bench_main.rs"
harness = false
[package.metadata.cargo-machete]
-ignored = ["ark-serialize", "getrandom"]
+ignored = [
+ "getrandom",
+ "rand_old" # used by benchmarks/pairing.rs
+]
From 87c5f34fd44dfefe85f345c324535868a70df30a Mon Sep 17 00:00:00 2001
From: Piotr Roslaniec
Date: Mon, 8 Jan 2024 17:25:32 +0100
Subject: [PATCH 12/12] chore: fix unused import breaking release compilation
---
ferveo/benches/benchmarks/eval_domain.rs | 1 -
ferveo/src/dkg.rs | 1 -
2 files changed, 2 deletions(-)
diff --git a/ferveo/benches/benchmarks/eval_domain.rs b/ferveo/benches/benchmarks/eval_domain.rs
index 23cd8065..259e7ce3 100644
--- a/ferveo/benches/benchmarks/eval_domain.rs
+++ b/ferveo/benches/benchmarks/eval_domain.rs
@@ -1,7 +1,6 @@
#![allow(clippy::redundant_closure)]
#![allow(clippy::unit_arg)]
-pub use ark_bls12_381::Bls12_381 as EllipticCurve;
use ark_ff::Field;
use ark_poly::EvaluationDomain;
use criterion::{black_box, criterion_group, BenchmarkId, Criterion};
diff --git a/ferveo/src/dkg.rs b/ferveo/src/dkg.rs
index fa389458..3f7fc09d 100644
--- a/ferveo/src/dkg.rs
+++ b/ferveo/src/dkg.rs
@@ -320,7 +320,6 @@ pub(crate) mod test_common {
use std::str::FromStr;
pub use ark_bls12_381::Bls12_381 as E;
- pub use ark_ff::UniformRand;
use ferveo_common::Keypair;
pub use super::*;