Skip to content

Commit 70482a5

Browse files
committed
Fix prev_challenges test and hex point deserialization
1 parent 9b1a5a9 commit 70482a5

4 files changed

Lines changed: 45 additions & 19 deletions

File tree

operator/mina/lib/Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

operator/mina/lib/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,4 @@ serde = "1.0.197"
2020
rmp-serde = "1.1.2"
2121
ark-serialize = "0.3.0"
2222
serde_json = "1.0.118"
23+
hex = "0.4.3"

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

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -301,30 +301,38 @@ mod tests {
301301

302302
let old_bulletproof_challenges = [bulletproof_challenges_0, bulletproof_challenges_1];
303303
let challenge_polynomial_commitments = [
304-
["1", "2"].map(str::to_string),
305-
["1", "2"].map(str::to_string),
304+
[
305+
"40000000000000000000000000000000224698FC094CF91B992D30ED00000000",
306+
"2",
307+
]
308+
.map(str::to_string),
309+
[
310+
"40000000000000000000000000000000224698FC094CF91B992D30ED00000000",
311+
"2",
312+
]
313+
.map(str::to_string),
306314
];
307315

308316
let prev_challenges =
309317
compute_prev_challenges(old_bulletproof_challenges, challenge_polynomial_commitments)
310318
.unwrap();
311319

312320
let mut ocaml_results = [
313-
"29DA5323EE2A35AFA4DF5EF02FD009F8D2FC7A2840525EBE06D519BD10DE22A9",
314-
"1D52604A0D982FD2B0E3123CDE4F801B4ED1D7159B4E5B592014F6F248742A24",
315-
"07407D5D1BF2A0345F94610AE734EBA90DA7377FF0D9F394D7ABB16A44F412B4",
316-
"0D35562107CCF36FCEE46BE6D07CACDED87E5A8134B6B6EBF37B4202419E7FC5",
317-
"08184AD059400E9C0F4BC42FE7CA928645AE2FFE06827B8FEF0A85E383129B73",
318-
"3E50BB9FA5E9622478755CD1A00FF52376E02EC668615C0ACE437A8202F2B303",
319-
"067953A48294C5A2B9D834F5F11B98D7D202A856E654E350ABEF4ECA1A32F835",
320-
"11ADB6896D03E99B915AC779FB33C67C90AB7D34CBEFC6FC7AEB6E29C9633C9F",
321-
"2F17B8300653C1CBADD031C71F53127D76A1074574BEFD64F4535B45473FE702",
322-
"2D8FC93295F902A7AAABC447ADACAFCEB4D3691742D8F6EB7691D24FA51E8D4F",
323-
"2D6B91A4A7C41007DEA2D7C55FB80FDAC61F7BBBD0A5C1036239C791147B4BA4",
324-
"28BDA221025B5B8F684CB66E6E23301C189EB2100A1AADD482C151C159CA5E34",
325-
"26D8EC29B0C0769401BFA8659E6C49563CAB16911DA6052B8F442460C5091639",
326-
"1448AB1F39A083F31B21BC22FE150BA031D8E2D9DD2D0146C73A38763B0611C6",
327-
"05BEBF5D1E8D15AF1F90E6FEA892000B8FAB1EB5BE8662E3E3CC1DBFA8C90F73",
321+
"A922DE10BD19D506BE5E5240287AFCD2F809D02FF05EDFA4AF352AEE2353DA29",
322+
"242A7448F2F61420595B4E9B15D7D14E1B804FDE3C12E3B0D22F980D4A60521D",
323+
"B412F4446AB1ABD794F3D9F07F37A70DA9EB34E70A61945F34A0F21B5D7D4007",
324+
"C57F9E4102427BF3EBB6B634815A7ED8DEAC7CD0E66BE4CE6FF3CC072156350D",
325+
"739B1283E3850AEF8F7B8206FE2FAE458692CAE72FC44B0F9C0E4059D04A1808",
326+
"03B3F202827A43CE0A5C6168C62EE07623F50FA0D15C75782462E9A59FBB503E",
327+
"35F8321ACA4EEFAB50E354E656A802D2D7981BF1F534D8B9A2C59482A4537906",
328+
"9F3C63C9296EEB7AFCC6EFCB347DAB907CC633FB79C75A919BE9036D89B6AD11",
329+
"02E73F47455B53F464FDBE744507A1767D12531FC731D0ADCBC1530630B8172F",
330+
"4F8D1EA54FD29176EBF6D8421769D3B4CEAFACAD47C4ABAAA702F99532C98F2D",
331+
"A44B7B1491C7396203C1A5D0BB7B1FC6DA0FB85FC5D7A2DE0710C4A7A4916B2D",
332+
"345ECA59C151C182D4AD1A0A10B29E181C30236E6EB64C688F5B5B0221A2BD28",
333+
"391609C56024448F2B05A61D9116AB3C56496C9E65A8BF019476C0B029ECD826",
334+
"C611063B76383AC746012DDDD9E2D831A00B15FE22BC211BF383A0391FAB4814",
335+
"730FC9A8BF1DCCE3E36286BEB51EAB8F0B0092A8FEE6901FAF158D1E5DBFBE05",
328336
]
329337
.map(|hex| Fq::from_hex(hex).unwrap());
330338
ocaml_results.reverse();

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

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
use std::char;
2+
3+
use ark_ff::PrimeField;
14
use kimchi::{
25
mina_curves::pasta::{Fp, Fq, Pallas},
36
proof::PointEvaluations,
@@ -137,8 +140,21 @@ impl TryFrom<HexPointCoordinates> for WrapECPoint {
137140

138141
fn try_from(value: HexPointCoordinates) -> Result<Self, Self::Error> {
139142
// TODO: Handle point at infinity.
140-
let x = Fp::from_hex(&value[0]).map_err(|err| err.to_string())?;
141-
let y = Fp::from_hex(&value[1]).map_err(|err| err.to_string())?;
143+
let [x, y] = value.map(|mut hex| {
144+
if hex.chars().count() % 2 != 0 {
145+
hex.insert(0, '0');
146+
}
147+
let mut bytes: Vec<u8> = hex::decode(hex)
148+
.map_err(|err| err.to_string())?
149+
.into_iter()
150+
.rev()
151+
.collect();
152+
bytes.resize(32, 0);
153+
Fp::from_bytes(&bytes).map_err(|err| err.to_string())
154+
});
155+
let x = x?;
156+
let y = y?;
157+
142158
let point = Pallas::new(x, y, false);
143159
if !point.is_on_curve() {
144160
return Err("Deserialized point is not on curve.".to_string());

0 commit comments

Comments
 (0)