Skip to content

Commit aa8e52f

Browse files
committed
feat: add PCS assist Dory opening formulas
1 parent 289808a commit aa8e52f

80 files changed

Lines changed: 23566 additions & 3776 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
//! Public artifact slots exposed by the Dory-assist checked-input relation.
2+
3+
pub const GT_ARTIFACT_COEFFS: usize = 16;
4+
pub const G1_ARTIFACT_COORDS: usize = 3;
5+
pub const G2_ARTIFACT_COORDS: usize = 5;
6+
7+
pub const DORY_PROOF_DIGEST_INDEX: usize = 0;
8+
pub const DORY_VMV_C_START: usize = DORY_PROOF_DIGEST_INDEX + 1;
9+
pub const DORY_VMV_D2_START: usize = DORY_VMV_C_START + GT_ARTIFACT_COEFFS;
10+
pub const DORY_VMV_E1_START: usize = DORY_VMV_D2_START + GT_ARTIFACT_COEFFS;
11+
pub const DORY_ZK_E2_START: usize = DORY_VMV_E1_START + G1_ARTIFACT_COORDS;
12+
pub const DORY_ZK_Y_COM_START: usize = DORY_ZK_E2_START + G2_ARTIFACT_COORDS;
13+
pub const DORY_SCALAR_PRODUCT_P1_START: usize = DORY_ZK_Y_COM_START + G1_ARTIFACT_COORDS;
14+
pub const DORY_SCALAR_PRODUCT_P2_START: usize = DORY_SCALAR_PRODUCT_P1_START + GT_ARTIFACT_COEFFS;
15+
pub const DORY_SCALAR_PRODUCT_Q_START: usize = DORY_SCALAR_PRODUCT_P2_START + GT_ARTIFACT_COEFFS;
16+
pub const DORY_SCALAR_PRODUCT_R_START: usize = DORY_SCALAR_PRODUCT_Q_START + GT_ARTIFACT_COEFFS;
17+
pub const DORY_SCALAR_PRODUCT_E1_START: usize = DORY_SCALAR_PRODUCT_R_START + GT_ARTIFACT_COEFFS;
18+
pub const DORY_SCALAR_PRODUCT_E2_START: usize = DORY_SCALAR_PRODUCT_E1_START + G1_ARTIFACT_COORDS;
19+
pub const DORY_SCALAR_PRODUCT_R1_INDEX: usize = DORY_SCALAR_PRODUCT_E2_START + G2_ARTIFACT_COORDS;
20+
pub const DORY_SCALAR_PRODUCT_R2_INDEX: usize = DORY_SCALAR_PRODUCT_R1_INDEX + 1;
21+
pub const DORY_SCALAR_PRODUCT_R3_INDEX: usize = DORY_SCALAR_PRODUCT_R2_INDEX + 1;
22+
pub const DORY_REDUCE_ROUNDS_START: usize = DORY_SCALAR_PRODUCT_R3_INDEX + 1;
23+
24+
pub const FIRST_REDUCE_ARTIFACT_COORDS: usize =
25+
4 * GT_ARTIFACT_COEFFS + G1_ARTIFACT_COORDS + G2_ARTIFACT_COORDS;
26+
pub const SECOND_REDUCE_ARTIFACT_COORDS: usize =
27+
2 * GT_ARTIFACT_COEFFS + 2 * G1_ARTIFACT_COORDS + 2 * G2_ARTIFACT_COORDS;
28+
pub const REDUCE_ROUND_ARTIFACT_COORDS: usize =
29+
FIRST_REDUCE_ARTIFACT_COORDS + SECOND_REDUCE_ARTIFACT_COORDS;
30+
31+
pub const fn reduce_round_start(round: usize) -> usize {
32+
DORY_REDUCE_ROUNDS_START + round * REDUCE_ROUND_ARTIFACT_COORDS
33+
}
34+
35+
pub const fn reduce_first_d1_left_start(round: usize) -> usize {
36+
reduce_round_start(round)
37+
}
38+
39+
pub const fn reduce_first_d1_right_start(round: usize) -> usize {
40+
reduce_first_d1_left_start(round) + GT_ARTIFACT_COEFFS
41+
}
42+
43+
pub const fn reduce_first_d2_left_start(round: usize) -> usize {
44+
reduce_first_d1_right_start(round) + GT_ARTIFACT_COEFFS
45+
}
46+
47+
pub const fn reduce_first_d2_right_start(round: usize) -> usize {
48+
reduce_first_d2_left_start(round) + GT_ARTIFACT_COEFFS
49+
}
50+
51+
pub const fn reduce_first_e1_beta_start(round: usize) -> usize {
52+
reduce_first_d2_right_start(round) + GT_ARTIFACT_COEFFS
53+
}
54+
55+
pub const fn reduce_first_e2_beta_start(round: usize) -> usize {
56+
reduce_first_e1_beta_start(round) + G1_ARTIFACT_COORDS
57+
}
58+
59+
pub const fn reduce_second_c_plus_start(round: usize) -> usize {
60+
reduce_first_e2_beta_start(round) + G2_ARTIFACT_COORDS
61+
}
62+
63+
pub const fn reduce_second_c_minus_start(round: usize) -> usize {
64+
reduce_second_c_plus_start(round) + GT_ARTIFACT_COEFFS
65+
}
66+
67+
pub const fn reduce_second_e1_plus_start(round: usize) -> usize {
68+
reduce_second_c_minus_start(round) + GT_ARTIFACT_COEFFS
69+
}
70+
71+
pub const fn reduce_second_e1_minus_start(round: usize) -> usize {
72+
reduce_second_e1_plus_start(round) + G1_ARTIFACT_COORDS
73+
}
74+
75+
pub const fn reduce_second_e2_plus_start(round: usize) -> usize {
76+
reduce_second_e1_minus_start(round) + G1_ARTIFACT_COORDS
77+
}
78+
79+
pub const fn reduce_second_e2_minus_start(round: usize) -> usize {
80+
reduce_second_e2_plus_start(round) + G2_ARTIFACT_COORDS
81+
}
82+
83+
pub const fn final_e1_start(reduce_rounds: usize) -> usize {
84+
DORY_REDUCE_ROUNDS_START + reduce_rounds * REDUCE_ROUND_ARTIFACT_COORDS
85+
}
86+
87+
pub const fn final_e2_start(reduce_rounds: usize) -> usize {
88+
final_e1_start(reduce_rounds) + G1_ARTIFACT_COORDS
89+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
//! Claim-reduction helpers for G1 operation-family claims.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
//! Claim-reduction helpers for G2 operation-family claims.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
//! Claim-reduction helpers for GT operation-family claims.
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
use crate::util::extend_unique;
2+
3+
use super::super::super::DoryAssistOpeningId;
4+
use super::super::miller_loop::{
5+
accumulator_input_openings, accumulator_output_openings, boundary_output_openings,
6+
line_evaluation_output_openings, line_step_output_openings, pair_product_output_openings,
7+
};
8+
9+
pub fn prefix_packing_openings() -> Vec<DoryAssistOpeningId> {
10+
let mut openings = Vec::new();
11+
extend_unique(&mut openings, &line_step_output_openings());
12+
extend_unique(&mut openings, &line_evaluation_output_openings());
13+
extend_unique(&mut openings, &pair_product_output_openings());
14+
extend_unique(&mut openings, &accumulator_input_openings());
15+
extend_unique(&mut openings, &accumulator_output_openings());
16+
extend_unique(&mut openings, &boundary_output_openings());
17+
openings
18+
}
19+
20+
#[cfg(test)]
21+
mod tests {
22+
use super::super::super::super::{
23+
DoryAssistRelationId, DoryAssistVirtualPolynomial, MillerLoopPolynomial,
24+
};
25+
use super::*;
26+
27+
#[test]
28+
fn prefix_packing_openings_include_all_miller_loop_subrelations() {
29+
let openings = prefix_packing_openings();
30+
31+
assert!(openings.iter().any(|opening| matches!(
32+
opening,
33+
DoryAssistOpeningId::Polynomial { relation, .. }
34+
if *relation == DoryAssistRelationId::MillerLoopLineStep
35+
)));
36+
assert!(openings.iter().any(|opening| matches!(
37+
opening,
38+
DoryAssistOpeningId::Polynomial { relation, .. }
39+
if *relation == DoryAssistRelationId::MillerLoopLineEvaluation
40+
)));
41+
assert!(openings.iter().any(|opening| matches!(
42+
opening,
43+
DoryAssistOpeningId::Polynomial { relation, .. }
44+
if *relation == DoryAssistRelationId::MillerLoopPairProduct
45+
)));
46+
assert!(openings.iter().any(|opening| matches!(
47+
opening,
48+
DoryAssistOpeningId::Polynomial { relation, .. }
49+
if *relation == DoryAssistRelationId::MillerLoopAccumulator
50+
)));
51+
assert!(openings.iter().any(|opening| matches!(
52+
opening,
53+
DoryAssistOpeningId::Polynomial { relation, .. }
54+
if *relation == DoryAssistRelationId::MillerLoopBoundary
55+
)));
56+
assert!(openings.iter().any(|opening| matches!(
57+
opening,
58+
DoryAssistOpeningId::Polynomial {
59+
polynomial: super::super::super::super::DoryAssistPolynomialId::Virtual(
60+
DoryAssistVirtualPolynomial::MillerLoop(
61+
MillerLoopPolynomial::PairLineProductCoeff(0)
62+
)
63+
),
64+
relation: DoryAssistRelationId::MillerLoopPairProduct,
65+
}
66+
)));
67+
}
68+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
pub mod g1;
2+
pub mod g2;
3+
pub mod gt;
4+
pub mod miller_loop;
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
//! Dory-assist committed-polynomial opening order used by the Hyrax check.
2+
3+
use super::super::{DoryAssistCommittedPolynomial, DoryAssistOpeningId, DoryAssistRelationId};
4+
5+
pub fn final_opening_polynomial_order() -> [DoryAssistCommittedPolynomial; 1] {
6+
[DoryAssistCommittedPolynomial::DenseWitness]
7+
}
8+
9+
pub fn final_opening_ids() -> [DoryAssistOpeningId; 1] {
10+
[DoryAssistOpeningId::dense_witness(
11+
DoryAssistRelationId::PrefixPacking,
12+
)]
13+
}
14+
15+
#[cfg(test)]
16+
mod tests {
17+
use super::*;
18+
19+
#[test]
20+
fn final_opening_order_is_single_dense_witness() {
21+
assert_eq!(
22+
final_opening_polynomial_order(),
23+
[DoryAssistCommittedPolynomial::DenseWitness]
24+
);
25+
assert_eq!(
26+
final_opening_ids(),
27+
[DoryAssistOpeningId::dense_witness(
28+
DoryAssistRelationId::PrefixPacking
29+
)]
30+
);
31+
}
32+
}

0 commit comments

Comments
 (0)