Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Epic - Recovery & Refreshing #188

Draft
wants to merge 22 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
8b26396
refactor: avoid using crypto primitives directly, part 1
piotr-roslaniec Feb 6, 2024
cfa8c99
refactor: avoid using crypto primitives directly, part 2
piotr-roslaniec Feb 7, 2024
4713848
feature: introduce refreshing api in ferveo
piotr-roslaniec Feb 12, 2024
315d2b4
feature!: remove state from dkg, part 1
piotr-roslaniec Feb 14, 2024
c9f1adc
feature!: remove state from dkg, part 2
piotr-roslaniec Feb 19, 2024
0ef7de4
refactor: rename public key share to public key
piotr-roslaniec Feb 20, 2024
ba12d6b
refactor: update serde serialization
piotr-roslaniec Feb 20, 2024
b67aef9
refactor: hide g_inv from internat apis
piotr-roslaniec Feb 22, 2024
93807a2
feature: remove deprecated exceptions
piotr-roslaniec Feb 26, 2024
2c97934
Merge pull request #175 from piotr-roslaniec/rewrite-refreshing
cygnusv Mar 19, 2024
0117a87
feature: introduce refreshing api in ferveo
piotr-roslaniec Feb 12, 2024
9aca6ae
test: document domain point determinism
piotr-roslaniec Feb 14, 2024
4a8375d
test: fix tests sensitive to message ordering
piotr-roslaniec Feb 22, 2024
975dae0
fix: not using subset of participants in precomputed variant
piotr-roslaniec Mar 13, 2024
703cbdd
Merge pull request #182 from piotr-roslaniec/domain_points
piotr-roslaniec Mar 19, 2024
aa69b36
Merge pull request #183 from piotr-roslaniec/remove-dkg-state
piotr-roslaniec Mar 19, 2024
299a471
Merge pull request #185 from piotr-roslaniec/aggregate-from-subset
cygnusv Mar 19, 2024
dc2f167
chore: fix a bad rebase
piotr-roslaniec Mar 19, 2024
6e3369d
feature!: remove fast variant
piotr-roslaniec Mar 13, 2024
b72a338
Merge pull request #187 from piotr-roslaniec/remove-fast-variant
piotr-roslaniec Mar 19, 2024
983110c
chore(deps): move shared dependencies to workspace crate
piotr-roslaniec Mar 20, 2024
be98542
Merge pull request #189 from piotr-roslaniec/workspace-deps
piotr-roslaniec Apr 25, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
114 changes: 6 additions & 108 deletions Cargo.lock

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

41 changes: 41 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,47 @@ members = [
"subproductdomain",
]

[workspace.dependencies]
anyhow = "1.0.47"
ark-bls12-381 = "0.4.0"
ark-ec = "0.4"
ark-ff = "0.4"
ark-poly = "0.4"
ark-serialize = "0.4"
ark-std = "0.4"
bincode = "1.3.3"
chacha20poly1305 = "0.10.1"
criterion = "0.3"
console_error_panic_hook = "0.1.7"
derive_more = { version = "0.99", default-features = false }
digest = "0.10.0"
ferveo-common = { path = "ferveo-common" }
ferveo-tdec = { path = "ferveo-tdec" }
generic-array = "0.14.7"
getrandom = "0.2"
hex = "0.4"
itertools = "0.10.5"
js-sys = "0.3.63"
measure_time = "0.8"
miracl_core = "=2.3.0"
pprof = "0.6"
pyo3 = "0.18.2"
pyo3-build-config = "*"
rand = "0.8"
rand_core = "0.6.4"
rand_old = { package = "rand", version = "0.7" } # TODO: Used by benchmarks/pairing.rs, update to rand = "0.8" when possible
serde = "1.0"
serde_bytes = "0.11.9"
serde_with = "2.2.0"
sha2 = "0.10.6"
subproductdomain = { path = "subproductdomain" }
test-case = "3.3.1"
thiserror = "1.0"
wasm-bindgen = "0.2.86"
wasm-bindgen-derive = "0.2.1"
wasm-bindgen-test = "0.3.28"
zeroize = "1.6.0"

[profile.bench]
opt-level = 3
debug = true
Expand Down
18 changes: 9 additions & 9 deletions ferveo-common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ authors = ["Heliax AG <[email protected]>", "Piotr Roslaniec <[email protected]
description = "Common types and traits for Ferveo"

[dependencies]
ark-ec = "0.4"
ark-serialize = { version = "0.4", features = ["derive"] }
ark-std = "0.4"
bincode = "1.3.3"
generic-array = "0.14.7"
rand = "0.8"
serde = { version = "1.0", features = ["derive"] }
serde_with = "2.2.0"
ark-ec = { workspace = true }
ark-serialize = { workspace = true, features = ["derive"] }
ark-std = { workspace = true }
bincode = { workspace = true }
generic-array = { workspace = true }
rand = { workspace = true }
serde = { workspace = true, features = ["derive"] }
serde_with = { workspace = true }

[dev-dependencies]
ark-bls12-381 = "0.4.0"
ark-bls12-381 = { workspace = true }
9 changes: 5 additions & 4 deletions ferveo-common/src/keypair.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ use ark_std::{
rand::{prelude::StdRng, RngCore, SeedableRng},
UniformRand,
};
use generic_array::{typenum::U96, GenericArray};
use generic_array::{
typenum::{Unsigned, U96},
GenericArray,
};
use serde::*;
use serde_with::serde_as;

Expand Down Expand Up @@ -55,7 +58,7 @@ impl<E: Pairing> PublicKey<E> {
}

pub fn serialized_size() -> usize {
96
U96::to_usize()
}
}

Expand Down Expand Up @@ -106,7 +109,6 @@ impl<E: Pairing> Ord for Keypair<E> {

impl<E: Pairing> Keypair<E> {
/// Returns the public session key for the publicly verifiable DKG participant

pub fn public_key(&self) -> PublicKey<E> {
PublicKey::<E> {
encryption_key: E::G2Affine::generator()
Expand All @@ -116,7 +118,6 @@ impl<E: Pairing> Keypair<E> {
}

/// Creates a new ephemeral session key for participating in the DKG

pub fn new<R: RngCore>(rng: &mut R) -> Self {
Self {
decryption_key: E::ScalarField::rand(rng),
Expand Down
4 changes: 2 additions & 2 deletions ferveo-python/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ default = ["extension-module"]

[dependencies]
ferveo = { package = "ferveo-pre-release", path = "../ferveo", features = ["bindings-python"] }
pyo3 = "0.18.2"
pyo3 = { workspace = true }

[build-dependencies]
pyo3-build-config = "*"
pyo3-build-config = { workspace = true }
17 changes: 13 additions & 4 deletions ferveo-python/examples/server_api_precomputed.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ def gen_eth_addr(i: int) -> str:
)
messages.append(ValidatorMessage(sender, dkg.generate_transcript()))

# We only need `shares_num` messages to aggregate the transcript
messages = messages[:shares_num]

# Every validator can aggregate the transcripts
dkg = Dkg(
tau=tau,
Expand All @@ -59,11 +62,15 @@ def gen_eth_addr(i: int) -> str:
# In the meantime, the client creates a ciphertext and decryption request
msg = "abc".encode()
aad = "my-aad".encode()
ciphertext = encrypt(msg, aad, dkg.public_key)
ciphertext = encrypt(msg, aad, client_aggregate.public_key)

# In precomputed variant, the client selects a subset of validators to use for decryption
selected_validators = validators[:security_threshold]
selected_keypairs = validator_keypairs[:security_threshold]

# Having aggregated the transcripts, the validators can now create decryption shares
decryption_shares = []
for validator, validator_keypair in zip(validators, validator_keypairs):
for validator, validator_keypair in zip(selected_validators, selected_keypairs):
dkg = Dkg(
tau=tau,
shares_num=shares_num,
Expand All @@ -80,13 +87,15 @@ def gen_eth_addr(i: int) -> str:

# Create a decryption share for the ciphertext
decryption_share = aggregate.create_decryption_share_precomputed(
dkg, ciphertext.header, aad, validator_keypair
dkg, ciphertext.header, aad, validator_keypair, selected_validators
)
decryption_shares.append(decryption_share)

# We need at most `security_threshold` decryption shares
decryption_shares = decryption_shares[:security_threshold]

# Now, the decryption share can be used to decrypt the ciphertext
# This part is in the client API

shared_secret = combine_decryption_shares_precomputed(decryption_shares)

# The client should have access to the public parameters of the DKG
Expand Down
8 changes: 7 additions & 1 deletion ferveo-python/examples/server_api_simple.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ def gen_eth_addr(i: int) -> str:
)
messages.append(ValidatorMessage(sender, dkg.generate_transcript()))

# We only need `shares_num` messages to aggregate the transcript
messages = messages[:shares_num]

# Now that every validator holds a dkg instance and a transcript for every other validator,
# every validator can aggregate the transcripts
me = validators[0]
Expand All @@ -62,7 +65,7 @@ def gen_eth_addr(i: int) -> str:
# In the meantime, the client creates a ciphertext and decryption request
msg = "abc".encode()
aad = "my-aad".encode()
ciphertext = encrypt(msg, aad, dkg.public_key)
ciphertext = encrypt(msg, aad, client_aggregate.public_key)

# The client can serialize/deserialize ciphertext for transport
ciphertext_ser = bytes(ciphertext)
Expand Down Expand Up @@ -90,6 +93,9 @@ def gen_eth_addr(i: int) -> str:
)
decryption_shares.append(decryption_share)

# We only need `threshold` decryption shares in simple variant
decryption_shares = decryption_shares[:security_threshold]

# Now, the decryption share can be used to decrypt the ciphertext
# This part is in the client API

Expand Down
Loading
Loading