Skip to content

Commit 9c7acbf

Browse files
committed
Started deserialization of state proof
1 parent 0831be5 commit 9c7acbf

3 files changed

Lines changed: 59 additions & 16 deletions

File tree

operator/mina/lib/src/pickles_preproc/preprocess.rs

Lines changed: 49 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,53 @@
1-
use super::type_aliases::{WrapProverProof, WrapVerifierIndex};
1+
use kimchi::{circuits::wires::COLUMNS, mina_curves::pasta::Pallas, poly_commitment::PolyComm};
22

3-
pub fn preprocess_state_proof(//state_proof_json: StateProof,
4-
) -> (WrapVerifierIndex, WrapProverProof) {
5-
/*
6-
let commitments = WrapProverCommitments {};
3+
use crate::pickles_preproc::type_aliases::{WrapECPoint, WrapProverCommitments};
4+
5+
use super::{
6+
state_proof::StateProof,
7+
type_aliases::{WrapProverProof, WrapVerifierIndex},
8+
};
9+
10+
pub fn deserialize_state_proof(
11+
state_proof: StateProof,
12+
) -> Result<(WrapVerifierIndex, WrapProverProof), String> {
13+
// w_comm are single-point commitments
14+
let mut w_comm: [PolyComm<Pallas>; COLUMNS] = std::array::from_fn(|_| PolyComm {
15+
elems: Vec::with_capacity(1),
16+
});
17+
for (hex_comm, comm) in state_proof
18+
.proof
19+
.commitments
20+
.w_comm
21+
.into_iter()
22+
.zip(w_comm.iter_mut())
23+
{
24+
comm.elems.push(WrapECPoint::try_from(hex_comm)?.0);
25+
}
26+
27+
// z_comm is a single-point commitment
28+
let z_comm = PolyComm {
29+
elems: vec![WrapECPoint::try_from(state_proof.proof.commitments.z_comm)?.0],
30+
};
31+
// t_comm is a multi-point commitment
32+
let t_comm = PolyComm {
33+
elems: state_proof
34+
.proof
35+
.commitments
36+
.t_comm
37+
.into_iter()
38+
.map(|hex_point| WrapECPoint::try_from(hex_point).map(|point| point.0))
39+
.collect::<Result<_, _>>()?,
40+
};
41+
let lookup = None;
742

43+
let _commitments = WrapProverCommitments {
44+
w_comm,
45+
z_comm,
46+
t_comm,
47+
lookup,
48+
};
49+
50+
/*
851
let prover_proof = WrapProverProof {
952
commitments,
1053
proof,
@@ -13,6 +56,7 @@ pub fn preprocess_state_proof(//state_proof_json: StateProof,
1356
prev_challenges,
1457
};
1558
*/
59+
1660
todo!()
1761
}
1862

operator/mina/lib/src/pickles_preproc/state_proof.rs

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
1-
use kimchi::{
2-
mina_curves::pasta::{Fp, Fq, Pallas},
3-
poly_commitment::PolyComm,
4-
};
1+
use kimchi::mina_curves::pasta::{Fp, Fq, Pallas};
52
use o1_utils::FieldHelpers;
63
use serde::Deserialize;
74

8-
use super::type_aliases::{WrapPolyComm, WrapScalar};
5+
use super::type_aliases::{WrapECPoint, WrapScalar};
96

107
type DecimalSigned = String;
118
type HexPointCoordinates = [String; 2];
@@ -19,6 +16,9 @@ pub struct StateProof {
1916

2017
#[derive(Deserialize)]
2118
pub struct Proof {
19+
pub commitments: Commitments,
20+
pub evaluations: Evaluations,
21+
pub ft_eval1: HexScalar,
2222
pub bulletproof: Bulletproof,
2323
}
2424

@@ -33,9 +33,9 @@ pub struct Bulletproof {
3333

3434
#[derive(Deserialize)]
3535
pub struct Commitments {
36-
pub t_comm: [HexPointCoordinates; 7],
3736
pub w_comm: [HexPointCoordinates; 15],
3837
pub z_comm: HexPointCoordinates,
38+
pub t_comm: Vec<HexPointCoordinates>,
3939
}
4040

4141
#[derive(Deserialize)]
@@ -50,7 +50,6 @@ pub struct Evaluations {
5050
pub s: [HexPointCoordinates; 6],
5151
pub w: [HexPointCoordinates; 15],
5252
pub z: HexPointCoordinates,
53-
pub ft_eval1: HexScalar,
5453
}
5554

5655
#[derive(Deserialize)]
@@ -124,14 +123,13 @@ pub struct MessagesForNextWrapProof {
124123
pub old_bulletproof_challenges: [[BulletproofChallenge; 16]; 2],
125124
}
126125

127-
impl TryFrom<HexPointCoordinates> for WrapPolyComm {
126+
impl TryFrom<HexPointCoordinates> for WrapECPoint {
128127
type Error = String;
129128

130129
fn try_from(value: HexPointCoordinates) -> Result<Self, Self::Error> {
131130
let x = Fp::from_hex(&value[0]).map_err(|err| err.to_string())?;
132131
let y = Fp::from_hex(&value[1]).map_err(|err| err.to_string())?;
133-
let p = Pallas::new(x, y, false);
134-
Ok(WrapPolyComm(PolyComm { elems: vec![p] }))
132+
Ok(WrapECPoint(Pallas::new(x, y, false)))
135133
}
136134
}
137135

operator/mina/lib/src/pickles_preproc/type_aliases.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@ use kimchi::{
66
};
77

88
// Wrap circuit specific types
9-
pub struct WrapPolyComm(pub PolyComm<Pallas>);
9+
pub struct WrapECPoint(pub Pallas);
1010
pub struct WrapScalar(pub Fq);
11+
pub struct WrapPolyComm(pub PolyComm<Pallas>);
1112
pub type WrapVerifierIndex = VerifierIndex<Pallas, WrapOpeningProof>;
1213
pub type WrapProverProof = ProverProof<Pallas, WrapOpeningProof>;
1314
pub type WrapProverCommitments = ProverCommitments<Pallas>;

0 commit comments

Comments
 (0)