forked from anoma/ferveo
-
Notifications
You must be signed in to change notification settings - Fork 10
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
Validity checks #38
Merged
Merged
Validity checks #38
Changes from all commits
Commits
Show all changes
41 commits
Select commit
Hold shift + click to select a range
08bac73
initial work on simple threshold decryption
piotr-roslaniec 719b4a1
calculate lagrange using private context
piotr-roslaniec 17cdb5b
calculate lagrange using public context
piotr-roslaniec 8cb52d8
wip
piotr-roslaniec 81d4dd2
incorrect length of decrypted shares after pvss combination
piotr-roslaniec 9d38f62
initial removal of share partitioning
piotr-roslaniec 9759860
updating scheme
piotr-roslaniec 32f9c49
update aggregation
piotr-roslaniec 57255f5
simple decryption with one validator works with ferveo dkg
piotr-roslaniec 7cad9ae
fix clippy
piotr-roslaniec 856790c
simple threshold decryption works
piotr-roslaniec 364580e
remove dealer's lagrange coeffs calculation
piotr-roslaniec 89ebffc
self code review
piotr-roslaniec 44bd186
fix clippy after 1.66 update
piotr-roslaniec 1d9f623
cargo fmt
piotr-roslaniec 668184c
fix after rebase
piotr-roslaniec 4f62c70
remove ValidatorSet
piotr-roslaniec 995fdce
rename TendermintValidator to ExternalValidator
piotr-roslaniec fb05e62
remove unused code
piotr-roslaniec 99d2b9c
fix rustfmt
piotr-roslaniec 26fe690
fix after rebase
piotr-roslaniec 8f7308b
documents and refactor code
piotr-roslaniec 838d3d2
remove rebasing artifact
piotr-roslaniec b6c9189
refactor to a single share per validator
piotr-roslaniec a484971
enable key share blinding in fast tdec
piotr-roslaniec e99f43c
check ciphertext validity before creating a decryption share
piotr-roslaniec a0d9930
decryption share verification for fast variant
piotr-roslaniec c80a197
fix after rebase
piotr-roslaniec 444ff80
fix formulas
piotr-roslaniec 20445cd
implement simplified decryption share verification
piotr-roslaniec 249c3c1
refactor share verification
piotr-roslaniec 8e43ae4
add negative test case for verify_full
piotr-roslaniec da92818
update function docstring
piotr-roslaniec f0864ae
bench ciphertext validity check
piotr-roslaniec a21fb93
benchmark ciphertext validity check
piotr-roslaniec 91fa243
disable arkworks benchmark
piotr-roslaniec 534dce2
limit nr of benchmarks running on ci
piotr-roslaniec 208d95c
Merge branch 'main' into validity-checks
piotr-roslaniec 886ca60
add pvss verification benchmarks
piotr-roslaniec dd9e458
Merge branch 'main' into validity-checks
piotr-roslaniec 1f76347
apply pr suggestions
piotr-roslaniec File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
//pub mod block_proposer; | ||
pub mod pairing; | ||
// pub mod pairing; | ||
pub mod validity_checks; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
#![allow(clippy::redundant_closure)] | ||
#![allow(clippy::unit_arg)] | ||
|
||
use ark_bls12_381::Bls12_381; | ||
pub use ark_bls12_381::Bls12_381 as EllipticCurve; | ||
use criterion::{black_box, criterion_group, BenchmarkId, Criterion}; | ||
use digest::crypto_common::rand_core::SeedableRng; | ||
use ferveo::*; | ||
use ferveo_common::ExternalValidator; | ||
use rand::prelude::StdRng; | ||
|
||
const NUM_SHARES_CASES: [usize; 5] = [4, 8, 16, 32, 64]; | ||
|
||
// TODO: Can we expose ferveo test methods to reuse `setup_dkg` et al instead of reimplementing it here? | ||
|
||
fn gen_keypairs(num: u32) -> Vec<ferveo_common::Keypair<EllipticCurve>> { | ||
let rng = &mut ark_std::test_rng(); | ||
(0..num) | ||
.map(|_| ferveo_common::Keypair::<EllipticCurve>::new(rng)) | ||
.collect() | ||
} | ||
|
||
fn gen_validators( | ||
keypairs: &[ferveo_common::Keypair<EllipticCurve>], | ||
) -> Vec<ExternalValidator<EllipticCurve>> { | ||
(0..keypairs.len()) | ||
.map(|i| ExternalValidator { | ||
address: format!("validator_{}", i), | ||
public_key: keypairs[i].public(), | ||
}) | ||
.collect() | ||
} | ||
|
||
fn setup_dkg( | ||
validator: usize, | ||
shares_num: u32, | ||
) -> PubliclyVerifiableDkg<EllipticCurve> { | ||
let keypairs = gen_keypairs(shares_num); | ||
let validators = gen_validators(&keypairs); | ||
let me = validators[validator].clone(); | ||
PubliclyVerifiableDkg::new( | ||
validators, | ||
Params { | ||
tau: 0, | ||
security_threshold: shares_num / 3, | ||
shares_num, | ||
retry_after: 1, | ||
}, | ||
&me, | ||
keypairs[validator], | ||
) | ||
.expect("Setup failed") | ||
} | ||
|
||
fn setup( | ||
shares_num: u32, | ||
rng: &mut StdRng, | ||
) -> (PubliclyVerifiableDkg<Bls12_381>, Message<Bls12_381>) { | ||
let mut transcripts = vec![]; | ||
for i in 0..shares_num { | ||
let mut dkg = setup_dkg(i as usize, shares_num); | ||
transcripts.push(dkg.share(rng).expect("Test failed")); | ||
} | ||
let dkg = setup_dkg(0, shares_num); | ||
let transcript = transcripts[0].clone(); | ||
(dkg, transcript) | ||
} | ||
|
||
pub fn bench_verify_full(c: &mut Criterion) { | ||
let mut group = c.benchmark_group("PVSS VALIDITY CHECKS"); | ||
group.sample_size(10); | ||
|
||
let rng = &mut StdRng::seed_from_u64(0); | ||
|
||
for shares_num in NUM_SHARES_CASES { | ||
let (dkg, transcript) = setup(shares_num as u32, rng); | ||
let transcript = &transcript; | ||
|
||
let pvss_verify_optimistic = { | ||
move || { | ||
if let Message::Deal(ss) = transcript { | ||
black_box(ss.verify_optimistic()); | ||
} else { | ||
panic!("Expected Deal"); | ||
} | ||
} | ||
}; | ||
let pvss_verify_full = { | ||
move || { | ||
if let Message::Deal(ss) = transcript { | ||
black_box(ss.verify_full(&dkg)); | ||
} else { | ||
panic!("Expected Deal"); | ||
} | ||
} | ||
}; | ||
|
||
group.bench_function( | ||
BenchmarkId::new("pvss_verify_optimistic", shares_num), | ||
|b| b.iter(|| pvss_verify_optimistic()), | ||
); | ||
group.bench_function( | ||
BenchmarkId::new("pvss_verify_full", shares_num), | ||
|b| b.iter(|| pvss_verify_full()), | ||
); | ||
} | ||
} | ||
|
||
criterion_group!(validity_checks, bench_verify_full); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice test