Skip to content

Commit 1329599

Browse files
autquisAntonio95mmagicianPratyushCesar199999
authored
Add Brakedown multilinear PCS (#131)
* added hyrax PCS * Add univariate and multilinear Ligero PCS Co-authored-by: Hossein Moghaddas <[email protected]> Co-authored-by: Antonio Mejías Gil <[email protected]> * Add Brakedown * adapt the scheme to arkworks-rs/algebra#691 * move tests shared across univariate and ML ligero to utils * adapt the scheme to arkworks-rs/algebra#691 * move tests shared across schemes to utils * remove unused no-std import * adapt the scheme to arkworks-rs/algebra#691 * remove unused code in hyrax * Improve the choice of dimensions for polynomial matrix * Update comments * parallelised row encoding and col-to-leaf hashing; significant performance gains * parallelised row encoding and col-to-leaf hashing; significant performance gains * expanded on Future Optimisations section * fixed GH action failures: formatted and added feature flag * fixed GH action failures: formatted and added feature flag * remove Prepared data types from `PolynomialCommitment` trait * remove Prepared data types from `PolynomialCommitment` trait * Remove Prepared data types from `PolynomialCommitment` trait impl * added necessary dependencies overwritten by previous merge commit * fixed hashbrown version * Add back the cfg dependency for no-std build * fixed hashbrown version * pulled * created separate benchmark files * fixed duplicate dependency to match other branches * patched bn254 dep * restructured benchmark macros to accept ML schemes; benches working * moved hashing structures to bench-templates crate, started ligero bench coding * completed ligero benchmarks * added ligero benchmark file * adapted to new crate structure and created benchmark for ML brakedown * Hyrax fix bench (#42) * fix bench call * set num vars from 12-20 * Brakedown fix bench (#41) * fix bench call * set num vars from 12-20 * Ligero fix benches (#40) * fix bench call * set num vars from 12-20 * Hyrax parallel `commit` (#39) * Enable parallel commitment in hyrax amend * make `rand` optional * remove dead code * Make Hyrax hiding again (#43) * removed evaluation randomness from proof and ignored claimed value in check to make scheme hiding * fmt * removed unnecessary usage of argument in check, added _ * remove cfg(benches) attributes as that feature is no longer used * Fix tests: sponge config for univariate ligero * Fix the comment Co-authored-by: Marcin <[email protected]> * Delete `IOPTranscript`, update with master (#44) (aka Brakedown++) * Add the trait bounds * Add `CommitmentState` * Update benches for the new type * Fix the name of local variable * Merge `PCCommitmentState` with `PCRandomness` * Update `README.md` * Fix a bug * Complete the merge * Simplify `hash_column` * Delete comments * Add `CommitmentState` * Make `fmt` happy * Refactor, remove `hash_columns` * Rename all params * remove cfg(benches) attributes as that feature is no longer used * Brakedown+++ (#46) * conversion to `into_iter` is a no-op * remove explicit casts to vecs * rename to use singular of `labeled_commitment` * simplify the iterators even further by zipping two iters * Apply suggestions from code review * Maybe `empty` not return `Self` * Make `empty` return `Self` * Rename `rand` to `state` * Add the type `Randomness` * Rename nonnative to emulated, as in `r1cs-std` (#137) * Rename nonnative to emulated, as in `r1cs-std` * Run `fmt` * Temporarily change `Cargo.toml` * Revert `Cargo.toml` * Refactor `FoldedPolynomialStream` partially * Substitute `ChallengeGenerator` by the generic sponge (#139) * Rename nonnative to emulated, as in `r1cs-std` * Run `fmt` * Temporarily change `Cargo.toml` * Substitute `ChallengeGenerator` with the generic sponge * Run `fmt` * Remove the extra file * Update modules * Delete the unnecessary loop * Revert `Cargo.toml` * Refactor `FoldedPolynomialStream` partially * Update README * Make the diff more readable * Bring the whitespace back * Make diff more readable, 2 * Fix according to breaking changes in `ark-ec` (#141) * Fix for KZG10 * Fix the breaking changes in `ark-ec` * Remove the extra loop * Fix the loop range * re-use the preprocessing table * also re-use the preprocessing table for multilinear_pc --------- Co-authored-by: mmagician <[email protected]> * Auxiliary opening data (#134) * Add the trait bounds * Add `CommitmentState` * Update benches for the new type * Fix the name of local variable * Merge `PCCommitmentState` with `PCRandomness` * Update `README.md` * Fix a bug * Put `Randomness` in `CommitmentState` * Add a comment * Remove the extra loop * Update the comment for `CommitmentState` Co-authored-by: Marcin <[email protected]> * cargo fmt --------- Co-authored-by: Marcin <[email protected]> * `batch_mul_with_preprocessing` no longer takes `self` as argument (#142) * batch_mul_with_preprocessing no longer takes `self` as argument * Apply suggestions from code review Co-authored-by: Pratyush Mishra <[email protected]> * fix variable name --------- Co-authored-by: Pratyush Mishra <[email protected]> * Remove `ChallengeGenerator` for Brakedown (#53) * Squash and merge `delete-chalgen` onto here * Fix Brakedown for `ChallengeGenerator` and `AsRef` for Merkle tree * Remove `IOPTranscript` (#52) * Replace the `IOPTranscript` with `CryptographicSponge` * Delete extra comments * Delete TODOs and do not absorb what you just squeezed * Remove the extra loop * Revert the incorrect changes in `bench-tamplates` --------- Co-authored-by: mmagician <[email protected]> Co-authored-by: Pratyush Mishra <[email protected]> * Update a comment * Delete `IOPTranscript`, update with master (#50) (aka Hyrax++) * Add the trait bounds * Add `CommitmentState` * Update benches for the new type * Fix the name of local variable * Merge `PCCommitmentState` with `PCRandomness` * Update `README.md` * Fix a bug * Change `Randomness` to `CommitmentState` * Maybe `empty` not return `Self` * Make `empty` return `Self` * Rename `rand` to `state` * Partially integrate the new design into Hyrax * Update Hyrax with the shared state * Rename nonnative to emulated, as in `r1cs-std` (#137) * Rename nonnative to emulated, as in `r1cs-std` * Run `fmt` * Temporarily change `Cargo.toml` * Revert `Cargo.toml` * Refactor `FoldedPolynomialStream` partially * Substitute `ChallengeGenerator` by the generic sponge (#139) * Rename nonnative to emulated, as in `r1cs-std` * Run `fmt` * Temporarily change `Cargo.toml` * Substitute `ChallengeGenerator` with the generic sponge * Run `fmt` * Remove the extra file * Update modules * Delete the unnecessary loop * Revert `Cargo.toml` * Refactor `FoldedPolynomialStream` partially * Update README * Make the diff more readable * Bring the whitespace back * Make diff more readable, 2 * Fix according to breaking changes in `ark-ec` (#141) * Fix for KZG10 * Fix the breaking changes in `ark-ec` * Remove the extra loop * Fix the loop range * re-use the preprocessing table * also re-use the preprocessing table for multilinear_pc --------- Co-authored-by: mmagician <[email protected]> * Auxiliary opening data (#134) * Add the trait bounds * Add `CommitmentState` * Update benches for the new type * Fix the name of local variable * Merge `PCCommitmentState` with `PCRandomness` * Update `README.md` * Fix a bug * Put `Randomness` in `CommitmentState` * Add a comment * Remove the extra loop * Update the comment for `CommitmentState` Co-authored-by: Marcin <[email protected]> * cargo fmt --------- Co-authored-by: Marcin <[email protected]> * `batch_mul_with_preprocessing` no longer takes `self` as argument (#142) * batch_mul_with_preprocessing no longer takes `self` as argument * Apply suggestions from code review Co-authored-by: Pratyush Mishra <[email protected]> * fix variable name --------- Co-authored-by: Pratyush Mishra <[email protected]> * Remove ChallengeGenerator for Ligero (#56) * Squash and merge `delete-chalgen` onto here * Fix for `ChallengeGenerator` * Delete `IOPTranscript` for Hyrax (#55) * Use the sponge generic and rearrange `use`s * Use sponge instead of `IOPTransript` * Fix benches * Remove the extra loop --------- Co-authored-by: mmagician <[email protected]> Co-authored-by: Pratyush Mishra <[email protected]> * Delete `merlin` from dependencies * Delete `IOPTranscript`, update with master (#51) (aka Ligero++) * Add the trait bounds * Add `CommitmentState` * Update benches for the new type * Fix the name of local variable * Merge `PCCommitmentState` with `PCRandomness` * Update `README.md` * Fix a bug * Simplify `hash_column` * Delete comments * Add `CommitmentState` * Make `fmt` happy * Refactor, remove `hash_columns` * Rename all params * Maybe `empty` not return `Self` * Make `empty` return `Self` * Rename `rand` to `state` * Add type `Randomness` * Ligero+++ (#46) * conversion to `into_iter` is a no-op * remove explicit casts to vecs * rename to use singular of `labeled_commitment` * simplify the iterators even further by zipping two iters * Apply suggestions from code review * Fix tests: sponge config for univariate ligero * Rename nonnative to emulated, as in `r1cs-std` (#137) * Rename nonnative to emulated, as in `r1cs-std` * Run `fmt` * Temporarily change `Cargo.toml` * Revert `Cargo.toml` * Refactor `FoldedPolynomialStream` partially * Substitute `ChallengeGenerator` by the generic sponge (#139) * Rename nonnative to emulated, as in `r1cs-std` * Run `fmt` * Temporarily change `Cargo.toml` * Substitute `ChallengeGenerator` with the generic sponge * Run `fmt` * Remove the extra file * Update modules * Delete the unnecessary loop * Revert `Cargo.toml` * Refactor `FoldedPolynomialStream` partially * Update README * Make the diff more readable * Bring the whitespace back * Make diff more readable, 2 * Fix according to breaking changes in `ark-ec` (#141) * Fix for KZG10 * Fix the breaking changes in `ark-ec` * Remove the extra loop * Fix the loop range * re-use the preprocessing table * also re-use the preprocessing table for multilinear_pc --------- Co-authored-by: mmagician <[email protected]> * Auxiliary opening data (#134) * Add the trait bounds * Add `CommitmentState` * Update benches for the new type * Fix the name of local variable * Merge `PCCommitmentState` with `PCRandomness` * Update `README.md` * Fix a bug * Put `Randomness` in `CommitmentState` * Add a comment * Remove the extra loop * Update the comment for `CommitmentState` Co-authored-by: Marcin <[email protected]> * cargo fmt --------- Co-authored-by: Marcin <[email protected]> * `batch_mul_with_preprocessing` no longer takes `self` as argument (#142) * batch_mul_with_preprocessing no longer takes `self` as argument * Apply suggestions from code review Co-authored-by: Pratyush Mishra <[email protected]> * fix variable name --------- Co-authored-by: Pratyush Mishra <[email protected]> * Remove `ChallengeGenerator` and `IOPTranscript` for Ligero (#57) * Squash and merge `delete-chalgen` onto here * Fix Ligero for `ChallengeGenerator` and `AsRef` for Merkle tree * Fix tests: sponge config for univariate ligero * Delete `IOPTranscript` for Ligero (#54) * Replace the `IOPTranscript` with `CryptographicSponge` * Delete extra comments * Run fmt * Fix tests: sponge config for univariate ligero * Delete TODOs and do not absorb what you just squeezed * Fix unused import * Revert "Fix unused import" This reverts commit e85af90. * Try to fix * Remove the extra loop --------- Co-authored-by: mmagician <[email protected]> Co-authored-by: Pratyush Mishra <[email protected]> * Add a few comments and update `Cargo.toml` * Remove extra `cfg_iter!` Co-authored-by: Pratyush Mishra <[email protected]> * Change `pedersen_commit` and add `cfg_into_iter!` * Hash and absorb * BrakedownPCSParams need to be exported publicly * only enable num-traits on aarch (#58) * added Sync trait bound Co-authored-by: Cesar Descalzo <[email protected]> * removed TODO * Fixed error whereby boolean value returned by path.verify was neglected Co-authored-by: Cesar Descalzo <[email protected]> Co-authored-by: mmagician <[email protected]> * removed unnecessary qualification which linter didn't like * changed potential panic to returning Err, stopping early Co-authored-by: Cesar Descalzo <[email protected]> * removed unnecessary function defined inside check() Co-authored-by: Cesar Descalzo <[email protected]> * various minor fixes * Add `ark-std` to patch * Reorder Hyrax checks Co-authored-by: Antonio Mejías Gil <[email protected]> * Add `ark-std` to patch * Downgrade `hashbrown` * Fix breaking change from algebra/poly (#72) * Reorder deps * Add dummy doc for nightly * Fix `hashbrown` + Replace Blake2 by Blake3 * Revert to Blake2 * Fix merging issues * Test if CI is happy * Revert and cleanup * Delete dummy doc * Bring back `num_traits` * Fix merge conflict for README.md Co-authored-by: Pratyush Mishra <[email protected]> * Add `/` to Cargo.toml --------- Co-authored-by: Antonio Mejías Gil <[email protected]> Co-authored-by: mmagician <[email protected]> Co-authored-by: Pratyush Mishra <[email protected]> Co-authored-by: Cesar Descalzo <[email protected]> Co-authored-by: Cesar199999 <[email protected]>
1 parent 78aa1d7 commit 1329599

File tree

15 files changed

+1146
-58
lines changed

15 files changed

+1146
-58
lines changed

README.md

+5
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,7 @@ Unless you explicitly state otherwise, any contribution that you submit to this
183183
[aurora-light]: https://ia.cr/2019/601
184184
[pcd-acc]: https://ia.cr/2020/499
185185
[pst]: https://ia.cr/2011/587
186+
[brakedown]: https://ia.cr/2021/1043
186187
[ligero]: https://ia.cr/2022/1608
187188
[hyrax]: https://eprint.iacr.org/2017/1132
188189

@@ -220,6 +221,10 @@ CCS 2017
220221
Riad S. Wahby, Ioanna Tzialla, abhi shelat, Justin Thaler, Michael Walfish
221222
2018 IEEE Symposium on Security and Privacy
222223

224+
[Brakedown: Linear-time and field-agnostic SNARKs for R1CS][brakedown]
225+
Alexander Golovnev, Jonathan Lee, Srinath Setty, Justin Thaler, Riad S. Wahby
226+
CRYPTO 2023
227+
223228
## Acknowledgements
224229

225230
This work was supported by: an Engineering and Physical Sciences Research Council grant; a Google Faculty Award; the RISELab at UC Berkeley; and donations from the Ethereum Foundation and the Interchain Foundation.

poly-commit/Cargo.toml

+5-1
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,16 @@ name = "ipa_times"
3333
path = "benches/ipa_times.rs"
3434
harness = false
3535

36+
[[bench]]
37+
name = "brakedown_times"
38+
path = "benches/brakedown_ml_times.rs"
39+
harness = false
40+
3641
[[bench]]
3742
name = "ligero_ml_times"
3843
path = "benches/ligero_ml_times.rs"
3944
harness = false
4045

41-
4246
[[bench]]
4347
name = "hyrax_times"
4448
path = "benches/hyrax_times.rs"
+59
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
use ark_crypto_primitives::{
2+
crh::{sha256::Sha256, CRHScheme, TwoToOneCRHScheme},
3+
merkle_tree::{ByteDigestConverter, Config},
4+
};
5+
use ark_pcs_bench_templates::*;
6+
use ark_poly::{DenseMultilinearExtension, MultilinearExtension};
7+
8+
use ark_bn254::Fr;
9+
use ark_ff::PrimeField;
10+
11+
use ark_poly_commit::linear_codes::{LinearCodePCS, MultilinearBrakedown};
12+
use blake2::Blake2s256;
13+
use rand_chacha::ChaCha20Rng;
14+
15+
// Brakedown PCS over BN254
16+
struct MerkleTreeParams;
17+
type LeafH = LeafIdentityHasher;
18+
type CompressH = Sha256;
19+
impl Config for MerkleTreeParams {
20+
type Leaf = Vec<u8>;
21+
22+
type LeafDigest = <LeafH as CRHScheme>::Output;
23+
type LeafInnerDigestConverter = ByteDigestConverter<Self::LeafDigest>;
24+
type InnerDigest = <CompressH as TwoToOneCRHScheme>::Output;
25+
26+
type LeafHash = LeafH;
27+
type TwoToOneHash = CompressH;
28+
}
29+
30+
pub type MLE<F> = DenseMultilinearExtension<F>;
31+
type MTConfig = MerkleTreeParams;
32+
type ColHasher<F> = FieldToBytesColHasher<F, Blake2s256>;
33+
type Brakedown<F> = LinearCodePCS<
34+
MultilinearBrakedown<F, MTConfig, MLE<F>, ColHasher<F>>,
35+
F,
36+
MLE<F>,
37+
MTConfig,
38+
ColHasher<F>,
39+
>;
40+
41+
fn rand_poly_brakedown_ml<F: PrimeField>(
42+
num_vars: usize,
43+
rng: &mut ChaCha20Rng,
44+
) -> DenseMultilinearExtension<F> {
45+
DenseMultilinearExtension::rand(num_vars, rng)
46+
}
47+
48+
fn rand_point_brakedown_ml<F: PrimeField>(num_vars: usize, rng: &mut ChaCha20Rng) -> Vec<F> {
49+
(0..num_vars).map(|_| F::rand(rng)).collect()
50+
}
51+
52+
const MIN_NUM_VARS: usize = 12;
53+
const MAX_NUM_VARS: usize = 22;
54+
55+
bench!(
56+
Brakedown<Fr>,
57+
rand_poly_brakedown_ml,
58+
rand_point_brakedown_ml
59+
);

poly-commit/src/error.rs

+4
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,9 @@ pub enum Error {
119119
/// Error resulting from hashing in linear code - based PCS.
120120
HashingError,
121121

122+
/// Shows that encoding is not feasible
123+
EncodingError,
124+
122125
/// This means a commitment with a certain label was matched with a
123126
/// a polynomial which has a different label - which shouldn't happen
124127
MismatchedLabels {
@@ -235,6 +238,7 @@ impl core::fmt::Display for Error {
235238
Error::TranscriptError => write!(f, "Incorrect transcript manipulation"),
236239
Error::InvalidParameters(err) => write!(f, "{}", err),
237240
Error::HashingError => write!(f, "Error resulting from hashing"),
241+
Error::EncodingError => write!(f, "Encoding failed"),
238242
Error::MismatchedLabels { commitment_label, polynomial_label } =>
239243
write!(f, "Mismatched labels: commitment label: {}, polynomial label: {}",
240244
commitment_label,

poly-commit/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ pub mod streaming_kzg;
131131
/// Scheme based on the Ligero construction in [[Ligero]][ligero].
132132
///
133133
/// [ligero]: https://eprint.iacr.org/2022/1608
134+
/// [brakedown]: https://eprint.iacr.org/2021/1043.pdf
134135
pub mod linear_codes;
135136

136137
/// A polynomial commitment scheme based on the hardness of the

0 commit comments

Comments
 (0)