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
Remove powers-of-2 restriction on cohort size #134
Merged
piotr-roslaniec
merged 6 commits into
nucypher:development
from
piotr-roslaniec:remove-ftt-opt
Jul 6, 2023
Merged
Changes from 4 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
9d3cb63
benchmarks evaluation domains
piotr-roslaniec aa78183
replace radix2 eval domain to mixed radix eval domain in ferveo
piotr-roslaniec 27c55d0
remove enforcement on number of shares
piotr-roslaniec 8f45430
precomputed variant fails for non-power-of-two number of shares
piotr-roslaniec d5ec5e0
fix using bad number of domain points
piotr-roslaniec 2c20efb
use general evaluation domain
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 |
---|---|---|
@@ -0,0 +1,57 @@ | ||
#![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}; | ||
use digest::crypto_common::rand_core::SeedableRng; | ||
use ferveo_pre_release::*; | ||
use rand::prelude::StdRng; | ||
|
||
const NUM_SHARES_CASES: [usize; 6] = [2, 4, 8, 16, 32, 64]; | ||
|
||
pub fn bench_eval_domain(c: &mut Criterion) { | ||
let mut group = c.benchmark_group("EVAL DOMAIN"); | ||
group.sample_size(10); | ||
|
||
let rng = &mut StdRng::seed_from_u64(0); | ||
let s = ark_bls12_381::Fr::from_random_bytes(&[0u8; 32]).unwrap(); | ||
|
||
for shares_num in NUM_SHARES_CASES { | ||
let eval_radix2_eval_domain = { | ||
let domain = | ||
ark_poly::MixedRadixEvaluationDomain::new(shares_num).unwrap(); | ||
let phi = SecretPolynomial::<ark_bls12_381::Bls12_381>::new( | ||
&s, shares_num, rng, | ||
); | ||
|
||
move || { | ||
black_box(phi.0.evaluate_over_domain_by_ref(domain)); | ||
} | ||
}; | ||
|
||
let eval_mixed_eval_domain = { | ||
let domain = | ||
ark_poly::MixedRadixEvaluationDomain::new(shares_num).unwrap(); | ||
let phi = SecretPolynomial::<ark_bls12_381::Bls12_381>::new( | ||
&s, shares_num, rng, | ||
); | ||
|
||
move || { | ||
black_box(phi.0.evaluate_over_domain_by_ref(domain)); | ||
} | ||
}; | ||
|
||
group.bench_function( | ||
BenchmarkId::new("eval_radix2_eval_domain", shares_num), | ||
|b| b.iter(|| eval_radix2_eval_domain()), | ||
); | ||
group.bench_function( | ||
BenchmarkId::new("eval_mixed_eval_domain", shares_num), | ||
|b| b.iter(|| eval_mixed_eval_domain()), | ||
); | ||
} | ||
} | ||
|
||
criterion_group!(eval_domain, bench_eval_domain); |
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,3 +1,4 @@ | ||
//pub mod block_proposer; | ||
// pub mod pairing; | ||
pub mod eval_domain; | ||
pub mod validity_checks; |
Oops, something went wrong.
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.
So this is benchmarking the speed of num shares that are powers of 2 for Radix2 vs MixedRadix? Cool.
As an aside. Do we have a test somewhere for a non-power of 2 number of shares? Basically, a test that confirms that the non-powers of 2 work appropriately.
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.
I didn't consider this kind of test to be interesting before. I did a manual test (in REPL) before submitting the PR and that lulled me into a false sense of correctness. Now that I followed up on your suggestion, it turns out only the simple variant works for a non-power-of-two number of shares.
I will post the changes here and investigate the issue with the precomputed variant.
Thanks for catching this.
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.
The bug has been found and fixed. Please see my comment below.