Skip to content

Commit

Permalink
test: add 96 bits test and extension degree sanity test
Browse files Browse the repository at this point in the history
  • Loading branch information
Al-Kindi-0 committed Jan 30, 2024
1 parent f1f822b commit 4ea64bf
Showing 1 changed file with 84 additions and 0 deletions.
84 changes: 84 additions & 0 deletions air/src/proof/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,48 @@ mod prove_security_tests {
use crate::{proof::get_proven_security, FieldExtension};
use math::{fields::f64::BaseElement, StarkField};

#[test]
fn get_96_bits_security() {
let field_extension = FieldExtension::Cubic;
let base_field_bits = BaseElement::MODULUS_BITS;
let fri_folding_factor = 8;
let fri_remainder_max_degree = 127;
let grinding_factor = 20;
let mut blowup_factor = 4;
let mut num_queries = 80;
let collision_resistance = 128;
let trace_length = 1 << 18;

let mut options = ProofOptions::new(
num_queries,
blowup_factor,
grinding_factor,
field_extension,
fri_folding_factor as usize,
fri_remainder_max_degree as usize,
);
let security_1 =
get_proven_security(&options, base_field_bits, trace_length, collision_resistance);

assert_eq!(security_1, 97);

// increasing the blowup factor should increase the bits of security gained per query
blowup_factor <<= 1;
num_queries -= 27;
options = ProofOptions::new(
num_queries,
blowup_factor,
grinding_factor,
field_extension,
fri_folding_factor as usize,
fri_remainder_max_degree as usize,
);
let security_2 =
get_proven_security(&options, base_field_bits, trace_length, collision_resistance);

assert_eq!(security_2, 97);
}

#[test]
fn get_128_bits_security() {
let field_extension = FieldExtension::Cubic;
Expand Down Expand Up @@ -455,6 +497,48 @@ mod prove_security_tests {
assert_eq!(security_2, 128);
}

#[test]
fn extension_degree() {
let mut field_extension = FieldExtension::Quadratic;
let base_field_bits = BaseElement::MODULUS_BITS;
let fri_folding_factor = 8;
let fri_remainder_max_degree = 127;
let grinding_factor = 20;
let blowup_factor = 8;
let num_queries = 85;
let collision_resistance = 128;
let trace_length = 1 << 18;

let mut options = ProofOptions::new(
num_queries,
blowup_factor,
grinding_factor,
field_extension,
fri_folding_factor as usize,
fri_remainder_max_degree as usize,
);
let security_1 =
get_proven_security(&options, base_field_bits, trace_length, collision_resistance);

assert_eq!(security_1, 67);

// increasing the extension degree improves the FRI commit phase soundness error and permits
// reaching 128 bits security
field_extension = FieldExtension::Cubic;
options = ProofOptions::new(
num_queries,
blowup_factor,
grinding_factor,
field_extension,
fri_folding_factor as usize,
fri_remainder_max_degree as usize,
);
let security_2 =
get_proven_security(&options, base_field_bits, trace_length, collision_resistance);

assert_eq!(security_2, 128);
}

#[test]
fn trace_length() {
let field_extension = FieldExtension::Cubic;
Expand Down

0 comments on commit 4ea64bf

Please sign in to comment.