1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
use crate::{air::TransitionConstraintDegree, ProofOptions, TraceInfo};
use math::{log2, StarkField};
use utils::collections::Vec;
#[derive(Clone, PartialEq, Eq)]
pub struct AirContext<B: StarkField> {
pub(super) options: ProofOptions,
pub(super) trace_info: TraceInfo,
pub(super) transition_constraint_degrees: Vec<TransitionConstraintDegree>,
pub(super) ce_blowup_factor: usize,
pub(super) trace_domain_generator: B,
pub(super) lde_domain_generator: B,
}
impl<B: StarkField> AirContext<B> {
pub fn new(
trace_info: TraceInfo,
transition_constraint_degrees: Vec<TransitionConstraintDegree>,
options: ProofOptions,
) -> Self {
assert!(
!transition_constraint_degrees.is_empty(),
"at least one transition constraint degree must be specified"
);
let mut ce_blowup_factor = 0;
for degree in transition_constraint_degrees.iter() {
if degree.min_blowup_factor() > ce_blowup_factor {
ce_blowup_factor = degree.min_blowup_factor();
}
}
assert!(
options.blowup_factor() >= ce_blowup_factor,
"blowup factor too small; expected at least {}, but was {}",
ce_blowup_factor,
options.blowup_factor()
);
let trace_length = trace_info.length();
let lde_domain_size = trace_length * options.blowup_factor();
AirContext {
options,
trace_info,
transition_constraint_degrees,
ce_blowup_factor,
trace_domain_generator: B::get_root_of_unity(log2(trace_length)),
lde_domain_generator: B::get_root_of_unity(log2(lde_domain_size)),
}
}
}