Skip to content

Commit

Permalink
Proof recursion 8, redux
Browse files Browse the repository at this point in the history
  • Loading branch information
andyleiserson committed Nov 16, 2024
1 parent aca8ca5 commit 0a76a9e
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 14 deletions.
4 changes: 2 additions & 2 deletions ipa-core/src/protocol/context/dzkp_validator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ const BIT_ARRAY_SHIFT: usize = BIT_ARRAY_LEN.ilog2() as usize;
#[cfg(test)]
pub const TARGET_PROOF_SIZE: usize = 8192;
#[cfg(not(test))]
pub const TARGET_PROOF_SIZE: usize = 50_000_000;
pub const TARGET_PROOF_SIZE: usize = 28_000_000;

/// Returns the largest power of two less than or equal to `self`.
///
Expand Down Expand Up @@ -84,7 +84,7 @@ pub const fn prev_power_of_two(value: usize) -> usize {
// to blocks of 256), leaving some margin is advised.
//
// The implementation requires that MAX_PROOF_RECURSION is at least 2.
pub const MAX_PROOF_RECURSION: usize = 14;
pub const MAX_PROOF_RECURSION: usize = 9;

/// `MultiplicationInputsBlock` is a block of fixed size of intermediate values
/// that occur duringa multiplication.
Expand Down
2 changes: 1 addition & 1 deletion ipa-core/src/protocol/ipa_prf/malicious_security/prover.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ pub struct ProofGenerator<F: PrimeField, const L: usize, const P: usize, const M
// P, Proof size is 2*L - 1
// M, the number of interpolated points is L - 1
// The reason we need these is that Rust doesn't support basic math operations on const generics
pub type SmallProofGenerator = ProofGenerator<Fp61BitPrime, 4, 7, 3>;
pub type SmallProofGenerator = ProofGenerator<Fp61BitPrime, 8, 15, 7>;

impl<F: PrimeField, const L: usize, const P: usize, const M: usize> ProofGenerator<F, L, P, M> {
// define constants such that they can be used externally
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ impl ProofBatch {
#[allow(clippy::len_without_is_empty)]
#[must_use]
pub fn len(&self) -> usize {
FirstProofGenerator::PROOF_LENGTH + self.proofs.len() * CompressedProofGenerator::PROOF_LENGTH
FirstProofGenerator::PROOF_LENGTH
+ self.proofs.len() * CompressedProofGenerator::PROOF_LENGTH
}

#[allow(clippy::unnecessary_box_returns)] // clippy bug? `Array` exceeds unnecessary-box-size
Expand Down
19 changes: 9 additions & 10 deletions ipa-core/src/protocol/ipa_prf/validation_protocol/validation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use std::{
};

use futures_util::future::{try_join, try_join4};
use typenum::{Unsigned, U120, U448};
use typenum::{Unsigned, U288, U80};

use crate::{
const_assert_eq,
Expand Down Expand Up @@ -372,12 +372,12 @@ impl ProofHashes {

const_assert_eq!(
MAX_PROOF_RECURSION,
14,
"following impl valid only for MAX_PROOF_RECURSION = 14"
9,
"following impl valid only for MAX_PROOF_RECURSION = 9"
);

impl Serializable for [Hash; MAX_PROOF_RECURSION] {
type Size = U448;
type Size = U288;

type DeserializationError = <Hash as Serializable>::DeserializationError;

Expand Down Expand Up @@ -406,14 +406,14 @@ impl MpcMessage for [Hash; MAX_PROOF_RECURSION] {}

const_assert_eq!(
MAX_PROOF_RECURSION,
14,
"following impl valid only for MAX_PROOF_RECURSION = 14"
9,
"following impl valid only for MAX_PROOF_RECURSION = 9"
);

type ProofDiff = [Fp61BitPrime; MAX_PROOF_RECURSION + 1];

impl Serializable for ProofDiff {
type Size = U120;
type Size = U80;

type DeserializationError = <Fp61BitPrime as Serializable>::DeserializationError;

Expand Down Expand Up @@ -990,9 +990,8 @@ pub mod test {
// `verify_batch` to generate test data, generates `len` chunks of u/v values of
// length `BLOCK_SIZE`. We want the input u/v values to compress to exactly one
// u/v pair after some number of proof steps.
let num_inputs = FirstProofGenerator::RECURSION_FACTOR
* CompressedProofGenerator::RECURSION_FACTOR
* CompressedProofGenerator::RECURSION_FACTOR;
let num_inputs =
FirstProofGenerator::RECURSION_FACTOR * CompressedProofGenerator::RECURSION_FACTOR;
assert!(num_inputs % BLOCK_SIZE == 0);
verify_batch(num_inputs / BLOCK_SIZE);
}
Expand Down

0 comments on commit 0a76a9e

Please sign in to comment.