Skip to content

Commit

Permalink
chore(refactor): rename ferveo-tpke package to ferveo-tdec
Browse files Browse the repository at this point in the history
  • Loading branch information
piotr-roslaniec committed Nov 8, 2023
1 parent 2afd0fa commit 58002f5
Show file tree
Hide file tree
Showing 23 changed files with 40 additions and 40 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ members = [
"ferveo",
"ferveo-common",
"ferveo-python",
"ferveo-tpke",
"ferveo-tdec",
"ferveo-wasm",
"subproductdomain",
]
Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion ferveo-tpke/Cargo.toml → ferveo-tdec/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "ferveo-tpke"
name = "ferveo-tdec"
version = "0.2.0"
edition = "2021"
authors = ["Heliax AG <hello@heliax.dev>", "Piotr Roslaniec <p.roslaniec@gmail.com>"]
Expand Down
2 changes: 1 addition & 1 deletion ferveo-tpke/README.md → ferveo-tdec/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# tpke
# ferveo-tdec

## Benchmarks

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -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},
*,
};
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion ferveo/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
18 changes: 9 additions & 9 deletions ferveo/src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
Expand All @@ -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
Expand All @@ -55,7 +55,7 @@ pub fn encrypt(
) -> Result<Ciphertext> {
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))
}

Expand All @@ -65,7 +65,7 @@ pub fn decrypt_with_shared_secret(
shared_secret: &SharedSecret,
) -> Result<Vec<u8>> {
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,
Expand All @@ -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<CiphertextHeader> {
Expand All @@ -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(
Expand Down Expand Up @@ -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,
}
Expand Down Expand Up @@ -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<E>);
pub struct SharedSecret(pub ferveo_tdec::api::SharedSecret<E>);

#[cfg(test)]
mod test_ferveo_api {
use ferveo_tpke::SecretBox;
use ferveo_tdec::SecretBox;
use itertools::izip;
use rand::{prelude::StdRng, SeedableRng};

Expand Down
4 changes: 2 additions & 2 deletions ferveo/src/bindings_wasm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -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);
Expand Down
38 changes: 19 additions & 19 deletions ferveo/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
Expand Down Expand Up @@ -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,
};
Expand All @@ -140,7 +140,7 @@ mod test_dkg_full {
fn make_shared_secret_simple_tdec(
dkg: &PubliclyVerifiableDkg<E>,
aad: &[u8],
ciphertext_header: &ferveo_tpke::CiphertextHeader<E>,
ciphertext_header: &ferveo_tdec::CiphertextHeader<E>,
validator_keypairs: &[Keypair<E>],
) -> (
PubliclyVerifiableSS<E, Aggregated>,
Expand Down Expand Up @@ -176,12 +176,12 @@ mod test_dkg_full {
.collect::<Vec<_>>();
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::<E>(domain_points);
let shared_secret = ferveo_tpke::share_combine_simple::<E>(
ferveo_tdec::prepare_combine_simple::<E>(domain_points);
let shared_secret = ferveo_tdec::share_combine_simple::<E>(
&decryption_shares,
&lagrange_coeffs,
);
Expand All @@ -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::<E>(
let ciphertext = ferveo_tdec::encrypt::<E>(
SecretBox::new(msg.clone()),
aad,
&public_key,
Expand All @@ -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,
Expand All @@ -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::<E>(
let ciphertext = ferveo_tdec::encrypt::<E>(
SecretBox::new(msg.clone()),
aad,
&public_key,
Expand Down Expand Up @@ -278,10 +278,10 @@ mod test_dkg_full {
assert_eq!(domain_points.len(), decryption_shares.len());

let shared_secret =
ferveo_tpke::share_combine_precomputed::<E>(&decryption_shares);
ferveo_tdec::share_combine_precomputed::<E>(&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,
Expand All @@ -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::<E>(
let ciphertext = ferveo_tdec::encrypt::<E>(
SecretBox::new(msg),
aad,
&public_key,
Expand Down Expand Up @@ -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::<E>(
let ciphertext = ferveo_tdec::encrypt::<E>(
SecretBox::new(msg),
aad,
public_key,
Expand Down Expand Up @@ -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::<E>(domain_points);
let new_shared_secret = ferveo_tpke::share_combine_simple::<E>(
let lagrange = ferveo_tdec::prepare_combine_simple::<E>(domain_points);
let new_shared_secret = ferveo_tdec::share_combine_simple::<E>(
decryption_shares,
&lagrange,
);
Expand All @@ -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::<E>(
let ciphertext = ferveo_tdec::encrypt::<E>(
SecretBox::new(msg),
aad,
public_key,
Expand Down Expand Up @@ -607,10 +607,10 @@ mod test_dkg_full {
})
.collect();

let lagrange = ferveo_tpke::prepare_combine_simple::<E>(
let lagrange = ferveo_tdec::prepare_combine_simple::<E>(
&domain_points[..security_threshold as usize],
);
let new_shared_secret = ferveo_tpke::share_combine_simple::<E>(
let new_shared_secret = ferveo_tdec::share_combine_simple::<E>(
&decryption_shares[..security_threshold as usize],
&lagrange,
);
Expand Down
2 changes: 1 addition & 1 deletion ferveo/src/pvss.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
Expand Down
4 changes: 2 additions & 2 deletions ferveo/src/refresh.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -129,7 +129,7 @@ mod tests_refresh {
type E = ark_bls12_381::Bls12_381;
type ScalarField = <E as Pairing>::ScalarField;

use ferveo_tpke::{
use ferveo_tdec::{
test_common::setup_simple, PrivateDecryptionContextSimple,
PrivateKeyShare,
};
Expand Down

0 comments on commit 58002f5

Please sign in to comment.