From 58002f50155df31a11b9d58d94750a2ed1076102 Mon Sep 17 00:00:00 2001
From: Piotr Roslaniec
Date: Tue, 7 Nov 2023 11:36:05 +0100
Subject: [PATCH] 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,
};