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

feat: FFLONK #58

Merged
merged 10 commits into from
Dec 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
24 changes: 12 additions & 12 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ resolver = "2"

[workspace.package]
# All the packages in the workspace should have the same version
version = "0.30.11"
version = "0.30.9"
edition = "2021"
authors = ["The Matter Labs Team <[email protected]>"]
homepage = "https://zksync.io/"
Expand All @@ -17,17 +17,17 @@ categories = ["cryptography"]

[workspace.dependencies]
# Local dependencies
bellman = { version = "=0.30.11", path = "crates/bellman", package = "zksync_bellman" }
boojum = { version = "=0.30.11", path = "crates/boojum" }
zksync_solidity_vk_codegen = { version = "=0.30.11", path = "crates/codegen" }
codegen-bin = { version = "=0.30.11", path = "crates/codegen-bin" }
cs_derive = { version = "=0.30.11", path = "crates/cs_derive", package = "zksync_cs_derive" }
ff = { version = "=0.30.11", path = "crates/ff", package = "zksync_ff" }
ff_derive = { version = "=0.30.11", path = "crates/ff_derive", package = "zksync_ff_derive" }
franklin-crypto = { version = "=0.30.11", path = "crates/franklin-crypto" }
pairing = { version = "=0.30.11", path = "crates/pairing", package = "zksync_pairing" }
rescue_poseidon = { version = "=0.30.11", path = "crates/rescue-poseidon" }
snark_wrapper = { version = "=0.30.11", path = "crates/snark-wrapper" }
bellman = { version = "=0.30.9", path = "crates/bellman", package = "zksync_bellman" }
boojum = { version = "=0.30.9", path = "crates/boojum" }
zksync_solidity_vk_codegen = { version = "=0.30.9", path = "crates/codegen" }
codegen-bin = { version = "=0.30.9", path = "crates/codegen-bin" }
cs_derive = { version = "=0.30.9", path = "crates/cs_derive", package = "zksync_cs_derive" }
ff = { version = "=0.30.9", path = "crates/ff", package = "zksync_ff" }
ff_derive = { version = "=0.30.9", path = "crates/ff_derive", package = "zksync_ff_derive" }
franklin-crypto = { version = "=0.30.9", path = "crates/franklin-crypto" }
pairing = { version = "=0.30.9", path = "crates/pairing", package = "zksync_pairing" }
rescue_poseidon = { version = "=0.30.9", path = "crates/rescue-poseidon" }
snark_wrapper = { version = "=0.30.9", path = "crates/snark-wrapper" }

[profile.release]
debug = true
Expand Down
6 changes: 2 additions & 4 deletions crates/boojum/src/cs/implementations/prover.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2111,11 +2111,9 @@ impl<

let now = std::time::Instant::now();

const SEED_BITS: usize = 256;
// pull enough challenges from the transcript
let mut num_challenges = 256 / F::CHAR_BITS;
if num_challenges % F::CHAR_BITS != 0 {
num_challenges += 1;
}
let num_challenges = SEED_BITS.next_multiple_of(F::CHAR_BITS) / F::CHAR_BITS;
let challenges = transcript.get_multiple_challenges(num_challenges);
let pow_challenge = POW::run_from_field_elements(challenges, new_pow_bits, worker);

Expand Down
6 changes: 2 additions & 4 deletions crates/boojum/src/cs/implementations/verifier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1958,11 +1958,9 @@ impl<F: SmallField, EXT: FieldExtension<2, BaseField = F>> Verifier<F, EXT> {
log!("Doing PoW verification for {} bits", new_pow_bits);
log!("Prover gave challenge 0x{:016x}", proof.pow_challenge);

const SEED_BITS: usize = 256;
// pull enough challenges from the transcript
let mut num_challenges = 256 / F::CHAR_BITS;
if num_challenges % F::CHAR_BITS != 0 {
num_challenges += 1;
}
let num_challenges = SEED_BITS.next_multiple_of(F::CHAR_BITS) / F::CHAR_BITS;
let challenges = transcript.get_multiple_challenges(num_challenges);
let pow_challenge = proof.pow_challenge;

Expand Down
6 changes: 2 additions & 4 deletions crates/boojum/src/gadgets/recursion/recursive_verifier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1493,11 +1493,9 @@ impl<F: SmallField, EXT: FieldExtension<2, BaseField = F>, CS: ConstraintSystem<
log!("Doing PoW verification for {} bits", new_pow_bits);
// log!("Prover gave challenge 0x{:016x}", proof.pow_challenge);

const SEED_BITS: usize = 256;
// pull enough challenges from the transcript
let mut num_challenges = 256 / F::CHAR_BITS;
if num_challenges % F::CHAR_BITS != 0 {
num_challenges += 1;
}
let num_challenges = SEED_BITS.next_multiple_of(F::CHAR_BITS) / F::CHAR_BITS;
let _challenges: Vec<_> = transcript.get_multiple_challenges(cs, num_challenges);

todo!()
Expand Down
2 changes: 0 additions & 2 deletions crates/franklin-crypto/src/plonk/circuit/goldilocks/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@ impl<E: Engine> Hash for GoldilocksField<E> {
}

pub fn range_check_for_num_bits<E: Engine, CS: ConstraintSystem<E>>(cs: &mut CS, num: &Num<E>, num_bits: usize) -> Result<(), SynthesisError> {
assert!(num_bits % 16 == 0);

if let Num::Constant(value) = num {
for el in value.into_repr().as_ref().iter().skip(1) {
assert_eq!(0, *el)
Expand Down
6 changes: 2 additions & 4 deletions crates/snark-wrapper/src/verifier/fri.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,9 @@ pub(crate) fn verify_fri_part<
transcript.witness_field_elements(cs, &proof.final_fri_monomials[1])?;

if constants.new_pow_bits != 0 {
const SEED_BITS: usize = 256;
// pull enough challenges from the transcript
let mut num_challenges = 256 / GL::CHAR_BITS;
if num_challenges % GL::CHAR_BITS != 0 {
num_challenges += 1;
}
let num_challenges = SEED_BITS.next_multiple_of(GL::CHAR_BITS) / GL::CHAR_BITS;
let challenges: Vec<_> = transcript.get_multiple_challenges(cs, num_challenges as usize)?;
let (is_valid, pow_challenge_limbs) = POW::verify_from_field_elements(cs, challenges, proof.pow_challenge_le, constants.new_pow_bits)?;
match is_valid.get_value() {
Expand Down
Loading