From f8af43ada841473072b36e5e51b606ec33f608e8 Mon Sep 17 00:00:00 2001 From: turuslan Date: Thu, 18 Dec 2025 18:04:44 +0500 Subject: [PATCH 1/2] serde derive --- crates/rec_aggregation/src/xmss_aggregate.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/crates/rec_aggregation/src/xmss_aggregate.rs b/crates/rec_aggregation/src/xmss_aggregate.rs index b81a0edc..3107859a 100644 --- a/crates/rec_aggregation/src/xmss_aggregate.rs +++ b/crates/rec_aggregation/src/xmss_aggregate.rs @@ -7,6 +7,7 @@ use leansig::symmetric::message_hash::MessageHash; use leansig::symmetric::tweak_hash::poseidon::PoseidonTweak; use multilinear_toolkit::prelude::*; use rand::{Rng, SeedableRng, rngs::StdRng}; +use serde::{Deserialize, Serialize}; use std::sync::OnceLock; use std::time::Instant; use std::{mem::transmute, path::Path}; @@ -218,7 +219,7 @@ pub fn xmss_aggregate_signatures( Ok(xmss_aggregate_signatures_helper(pub_keys, signatures, message, epoch)?.0) } -#[derive(Debug, Clone)] +#[derive(Debug, Clone, Serialize, Deserialize)] pub struct Devnet2XmssAggregateSignature { pub proof_bytes: Vec, pub encoding_randomness: Vec<[F; RAND_LEN_FE]>, From b4c9b376c5858eaf21e38186f54c6e0360de2971 Mon Sep 17 00:00:00 2001 From: turuslan Date: Mon, 12 Jan 2026 11:11:05 +0500 Subject: [PATCH 2/2] ssz derive --- Cargo.lock | 428 +++++++++++-------- Cargo.toml | 4 +- crates/rec_aggregation/Cargo.toml | 2 + crates/rec_aggregation/src/xmss_aggregate.rs | 18 +- 4 files changed, 267 insertions(+), 185 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 1b223bae..767d2959 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -16,8 +16,8 @@ name = "air" version = "0.1.0" dependencies = [ "multilinear-toolkit", - "p3-koala-bear 0.3.0 (git+https://github.com/TomWambsgans/Plonky3.git?branch=lean-vm-simple)", - "p3-util 0.3.0 (git+https://github.com/TomWambsgans/Plonky3.git?branch=lean-vm-simple)", + "p3-koala-bear 0.3.0", + "p3-util 0.3.0", "rand 0.9.2", "tracing", "utils", @@ -28,7 +28,7 @@ name = "air" version = "0.3.0" source = "git+https://github.com/leanEthereum/multilinear-toolkit.git?branch=lean-vm-simple#e06cba2e214879c00c7fbc0e5b12908ddfcba588" dependencies = [ - "p3-field 0.3.0 (git+https://github.com/TomWambsgans/Plonky3.git?branch=lean-vm-simple)", + "p3-field 0.3.0", ] [[package]] @@ -346,8 +346,8 @@ source = "git+https://github.com/leanEthereum/multilinear-toolkit.git?branch=lea dependencies = [ "fiat-shamir", "itertools 0.14.0", - "p3-field 0.3.0 (git+https://github.com/TomWambsgans/Plonky3.git?branch=lean-vm-simple)", - "p3-util 0.3.0 (git+https://github.com/TomWambsgans/Plonky3.git?branch=lean-vm-simple)", + "p3-field 0.3.0", + "p3-util 0.3.0", "rand 0.9.2", "rayon", "tracing", @@ -553,7 +553,7 @@ source = "git+https://github.com/leanEthereum/multilinear-toolkit.git?branch=lea dependencies = [ "air 0.3.0", "fiat-shamir", - "p3-field 0.3.0 (git+https://github.com/TomWambsgans/Plonky3.git?branch=lean-vm-simple)", + "p3-field 0.3.0", ] [[package]] @@ -627,6 +627,41 @@ dependencies = [ "typenum", ] +[[package]] +name = "darling" +version = "0.20.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc7f46116c46ff9ab3eb1597a45688b6715c6e628b5c133e288e709a29bcb4ee" +dependencies = [ + "darling_core", + "darling_macro", +] + +[[package]] +name = "darling_core" +version = "0.20.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d00b9596d185e565c2207a0b01f8bd1a135483d02d9b7b0a54b11da8d53412e" +dependencies = [ + "fnv", + "ident_case", + "proc-macro2", + "quote", + "strsim", + "syn 2.0.111", +] + +[[package]] +name = "darling_macro" +version = "0.20.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc34b93ccb385b40dc71c6fceac4b2ad23662c7eeb248cf10d529b7e055b6ead" +dependencies = [ + "darling_core", + "quote", + "syn 2.0.111", +] + [[package]] name = "dashmap" version = "6.1.0" @@ -790,7 +825,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb" dependencies = [ "libc", - "windows-sys 0.59.0", + "windows-sys 0.61.2", ] [[package]] @@ -821,6 +856,18 @@ dependencies = [ "typenum", ] +[[package]] +name = "ethereum_ssz_derive" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78d247bc40823c365a62e572441a8f8b12df03f171713f06bc76180fcd56ab71" +dependencies = [ + "darling", + "proc-macro2", + "quote", + "syn 2.0.111", +] + [[package]] name = "fastrand" version = "2.3.0" @@ -864,9 +911,9 @@ name = "fiat-shamir" version = "0.1.0" source = "git+https://github.com/leanEthereum/fiat-shamir.git?branch=lean-vm-simple#9d4dc22f06cfa65f15bf5f1b07912a64c7feff0f" dependencies = [ - "p3-challenger", - "p3-field 0.3.0 (git+https://github.com/TomWambsgans/Plonky3.git?branch=lean-vm-simple)", - "p3-koala-bear 0.3.0 (git+https://github.com/TomWambsgans/Plonky3.git?branch=lean-vm-simple)", + "p3-challenger 0.3.0", + "p3-field 0.3.0", + "p3-koala-bear 0.3.0", "serde", ] @@ -989,6 +1036,12 @@ dependencies = [ "digest 0.10.7", ] +[[package]] +name = "ident_case" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" + [[package]] name = "impl-codec" version = "0.6.0" @@ -1105,7 +1158,7 @@ dependencies = [ "clap", "lean_vm", "multilinear-toolkit", - "p3-koala-bear 0.3.0 (git+https://github.com/TomWambsgans/Plonky3.git?branch=lean-vm-simple)", + "p3-koala-bear 0.3.0", "rec_aggregation", "whir-p3", ] @@ -1118,11 +1171,11 @@ dependencies = [ "lean_vm", "lookup", "multilinear-toolkit", - "p3-challenger", - "p3-koala-bear 0.3.0 (git+https://github.com/TomWambsgans/Plonky3.git?branch=lean-vm-simple)", - "p3-poseidon2 0.3.0 (git+https://github.com/TomWambsgans/Plonky3.git?branch=lean-vm-simple)", - "p3-symmetric 0.3.0 (git+https://github.com/TomWambsgans/Plonky3.git?branch=lean-vm-simple)", - "p3-util 0.3.0 (git+https://github.com/TomWambsgans/Plonky3.git?branch=lean-vm-simple)", + "p3-challenger 0.3.0", + "p3-koala-bear 0.3.0", + "p3-poseidon2 0.3.0", + "p3-symmetric 0.3.0", + "p3-util 0.3.0", "pest", "pest_derive", "rand 0.9.2", @@ -1142,11 +1195,11 @@ dependencies = [ "lean_vm", "lookup", "multilinear-toolkit", - "p3-challenger", - "p3-koala-bear 0.3.0 (git+https://github.com/TomWambsgans/Plonky3.git?branch=lean-vm-simple)", - "p3-poseidon2 0.3.0 (git+https://github.com/TomWambsgans/Plonky3.git?branch=lean-vm-simple)", - "p3-symmetric 0.3.0 (git+https://github.com/TomWambsgans/Plonky3.git?branch=lean-vm-simple)", - "p3-util 0.3.0 (git+https://github.com/TomWambsgans/Plonky3.git?branch=lean-vm-simple)", + "p3-challenger 0.3.0", + "p3-koala-bear 0.3.0", + "p3-poseidon2 0.3.0", + "p3-symmetric 0.3.0", + "p3-util 0.3.0", "pest", "pest_derive", "rand 0.9.2", @@ -1168,11 +1221,11 @@ dependencies = [ "lookup", "multilinear-toolkit", "num_enum", - "p3-challenger", - "p3-koala-bear 0.3.0 (git+https://github.com/TomWambsgans/Plonky3.git?branch=lean-vm-simple)", - "p3-poseidon2 0.3.0 (git+https://github.com/TomWambsgans/Plonky3.git?branch=lean-vm-simple)", - "p3-symmetric 0.3.0 (git+https://github.com/TomWambsgans/Plonky3.git?branch=lean-vm-simple)", - "p3-util 0.3.0 (git+https://github.com/TomWambsgans/Plonky3.git?branch=lean-vm-simple)", + "p3-challenger 0.3.0", + "p3-koala-bear 0.3.0", + "p3-poseidon2 0.3.0", + "p3-symmetric 0.3.0", + "p3-util 0.3.0", "pest", "pest_derive", "rand 0.9.2", @@ -1186,16 +1239,16 @@ dependencies = [ [[package]] name = "leansig" version = "0.1.0" -source = "git+https://github.com/leanEthereum/leansig.git#5ca0dabb31006db873b4e97ca6a3d5230b6aab33" +source = "git+https://github.com/qdrvm/leanSig.git?rev=6db3422006d353ac93fcc2eb933651f9dd311a3e#6db3422006d353ac93fcc2eb933651f9dd311a3e" dependencies = [ "dashmap", "ethereum_ssz", "num-bigint", "num-traits", - "p3-baby-bear 0.3.0 (git+https://github.com/Plonky3/Plonky3.git?rev=a33a312)", - "p3-field 0.3.0 (git+https://github.com/Plonky3/Plonky3.git?rev=a33a312)", - "p3-koala-bear 0.3.0 (git+https://github.com/Plonky3/Plonky3.git?rev=a33a312)", - "p3-symmetric 0.3.0 (git+https://github.com/Plonky3/Plonky3.git?rev=a33a312)", + "p3-baby-bear 0.4.1", + "p3-field 0.4.1", + "p3-koala-bear 0.4.1", + "p3-symmetric 0.4.1", "rand 0.9.2", "rayon", "serde", @@ -1241,9 +1294,9 @@ name = "lookup" version = "0.1.0" dependencies = [ "multilinear-toolkit", - "p3-challenger", - "p3-koala-bear 0.3.0 (git+https://github.com/TomWambsgans/Plonky3.git?branch=lean-vm-simple)", - "p3-util 0.3.0 (git+https://github.com/TomWambsgans/Plonky3.git?branch=lean-vm-simple)", + "p3-challenger 0.3.0", + "p3-koala-bear 0.3.0", + "p3-util 0.3.0", "rand 0.9.2", "tracing", "utils", @@ -1274,8 +1327,8 @@ dependencies = [ "backend", "constraints-folder", "fiat-shamir", - "p3-field 0.3.0 (git+https://github.com/TomWambsgans/Plonky3.git?branch=lean-vm-simple)", - "p3-util 0.3.0 (git+https://github.com/TomWambsgans/Plonky3.git?branch=lean-vm-simple)", + "p3-field 0.3.0", + "p3-util 0.3.0", "rayon", "sumcheck", "tracing", @@ -1358,24 +1411,25 @@ name = "p3-baby-bear" version = "0.3.0" source = "git+https://github.com/TomWambsgans/Plonky3.git?branch=lean-vm-simple#4897086b6f460b969dc0baad5c4dff91a4eb1d67" dependencies = [ - "p3-field 0.3.0 (git+https://github.com/TomWambsgans/Plonky3.git?branch=lean-vm-simple)", - "p3-mds 0.3.0 (git+https://github.com/TomWambsgans/Plonky3.git?branch=lean-vm-simple)", - "p3-monty-31 0.3.0 (git+https://github.com/TomWambsgans/Plonky3.git?branch=lean-vm-simple)", - "p3-poseidon2 0.3.0 (git+https://github.com/TomWambsgans/Plonky3.git?branch=lean-vm-simple)", - "p3-symmetric 0.3.0 (git+https://github.com/TomWambsgans/Plonky3.git?branch=lean-vm-simple)", + "p3-field 0.3.0", + "p3-mds 0.3.0", + "p3-monty-31 0.3.0", + "p3-poseidon2 0.3.0", + "p3-symmetric 0.3.0", "rand 0.9.2", ] [[package]] name = "p3-baby-bear" -version = "0.3.0" -source = "git+https://github.com/Plonky3/Plonky3.git?rev=a33a312#a33a31274a5e78bb5fbe3f82ffd2c294e17fa830" -dependencies = [ - "p3-field 0.3.0 (git+https://github.com/Plonky3/Plonky3.git?rev=a33a312)", - "p3-mds 0.3.0 (git+https://github.com/Plonky3/Plonky3.git?rev=a33a312)", - "p3-monty-31 0.3.0 (git+https://github.com/Plonky3/Plonky3.git?rev=a33a312)", - "p3-poseidon2 0.3.0 (git+https://github.com/Plonky3/Plonky3.git?rev=a33a312)", - "p3-symmetric 0.3.0 (git+https://github.com/Plonky3/Plonky3.git?rev=a33a312)", +version = "0.4.1" +source = "git+https://github.com/Plonky3/Plonky3.git?rev=d421e32#d421e32d3821174ae1f7e528d4bb92b7b18ab295" +dependencies = [ + "p3-challenger 0.4.1", + "p3-field 0.4.1", + "p3-mds 0.4.1", + "p3-monty-31 0.4.1", + "p3-poseidon2 0.4.1", + "p3-symmetric 0.4.1", "rand 0.9.2", ] @@ -1384,10 +1438,23 @@ name = "p3-challenger" version = "0.3.0" source = "git+https://github.com/TomWambsgans/Plonky3.git?branch=lean-vm-simple#4897086b6f460b969dc0baad5c4dff91a4eb1d67" dependencies = [ - "p3-field 0.3.0 (git+https://github.com/TomWambsgans/Plonky3.git?branch=lean-vm-simple)", - "p3-maybe-rayon 0.3.0 (git+https://github.com/TomWambsgans/Plonky3.git?branch=lean-vm-simple)", - "p3-symmetric 0.3.0 (git+https://github.com/TomWambsgans/Plonky3.git?branch=lean-vm-simple)", - "p3-util 0.3.0 (git+https://github.com/TomWambsgans/Plonky3.git?branch=lean-vm-simple)", + "p3-field 0.3.0", + "p3-maybe-rayon 0.3.0", + "p3-symmetric 0.3.0", + "p3-util 0.3.0", + "tracing", +] + +[[package]] +name = "p3-challenger" +version = "0.4.1" +source = "git+https://github.com/Plonky3/Plonky3.git?rev=d421e32#d421e32d3821174ae1f7e528d4bb92b7b18ab295" +dependencies = [ + "p3-field 0.4.1", + "p3-maybe-rayon 0.4.1", + "p3-monty-31 0.4.1", + "p3-symmetric 0.4.1", + "p3-util 0.4.1", "tracing", ] @@ -1397,11 +1464,11 @@ version = "0.3.0" source = "git+https://github.com/TomWambsgans/Plonky3.git?branch=lean-vm-simple#4897086b6f460b969dc0baad5c4dff91a4eb1d67" dependencies = [ "itertools 0.14.0", - "p3-challenger", - "p3-dft 0.3.0 (git+https://github.com/TomWambsgans/Plonky3.git?branch=lean-vm-simple)", - "p3-field 0.3.0 (git+https://github.com/TomWambsgans/Plonky3.git?branch=lean-vm-simple)", - "p3-matrix 0.3.0 (git+https://github.com/TomWambsgans/Plonky3.git?branch=lean-vm-simple)", - "p3-util 0.3.0 (git+https://github.com/TomWambsgans/Plonky3.git?branch=lean-vm-simple)", + "p3-challenger 0.3.0", + "p3-dft 0.3.0", + "p3-field 0.3.0", + "p3-matrix 0.3.0", + "p3-util 0.3.0", "serde", ] @@ -1411,23 +1478,23 @@ version = "0.3.0" source = "git+https://github.com/TomWambsgans/Plonky3.git?branch=lean-vm-simple#4897086b6f460b969dc0baad5c4dff91a4eb1d67" dependencies = [ "itertools 0.14.0", - "p3-field 0.3.0 (git+https://github.com/TomWambsgans/Plonky3.git?branch=lean-vm-simple)", - "p3-matrix 0.3.0 (git+https://github.com/TomWambsgans/Plonky3.git?branch=lean-vm-simple)", - "p3-maybe-rayon 0.3.0 (git+https://github.com/TomWambsgans/Plonky3.git?branch=lean-vm-simple)", - "p3-util 0.3.0 (git+https://github.com/TomWambsgans/Plonky3.git?branch=lean-vm-simple)", + "p3-field 0.3.0", + "p3-matrix 0.3.0", + "p3-maybe-rayon 0.3.0", + "p3-util 0.3.0", "tracing", ] [[package]] name = "p3-dft" -version = "0.3.0" -source = "git+https://github.com/Plonky3/Plonky3.git?rev=a33a312#a33a31274a5e78bb5fbe3f82ffd2c294e17fa830" +version = "0.4.1" +source = "git+https://github.com/Plonky3/Plonky3.git?rev=d421e32#d421e32d3821174ae1f7e528d4bb92b7b18ab295" dependencies = [ "itertools 0.14.0", - "p3-field 0.3.0 (git+https://github.com/Plonky3/Plonky3.git?rev=a33a312)", - "p3-matrix 0.3.0 (git+https://github.com/Plonky3/Plonky3.git?rev=a33a312)", - "p3-maybe-rayon 0.3.0 (git+https://github.com/Plonky3/Plonky3.git?rev=a33a312)", - "p3-util 0.3.0 (git+https://github.com/Plonky3/Plonky3.git?rev=a33a312)", + "p3-field 0.4.1", + "p3-matrix 0.4.1", + "p3-maybe-rayon 0.4.1", + "p3-util 0.4.1", "spin", "tracing", ] @@ -1439,8 +1506,8 @@ source = "git+https://github.com/TomWambsgans/Plonky3.git?branch=lean-vm-simple# dependencies = [ "itertools 0.14.0", "num-bigint", - "p3-maybe-rayon 0.3.0 (git+https://github.com/TomWambsgans/Plonky3.git?branch=lean-vm-simple)", - "p3-util 0.3.0 (git+https://github.com/TomWambsgans/Plonky3.git?branch=lean-vm-simple)", + "p3-maybe-rayon 0.3.0", + "p3-util 0.3.0", "paste", "rand 0.9.2", "serde", @@ -1449,13 +1516,13 @@ dependencies = [ [[package]] name = "p3-field" -version = "0.3.0" -source = "git+https://github.com/Plonky3/Plonky3.git?rev=a33a312#a33a31274a5e78bb5fbe3f82ffd2c294e17fa830" +version = "0.4.1" +source = "git+https://github.com/Plonky3/Plonky3.git?rev=d421e32#d421e32d3821174ae1f7e528d4bb92b7b18ab295" dependencies = [ "itertools 0.14.0", "num-bigint", - "p3-maybe-rayon 0.3.0 (git+https://github.com/Plonky3/Plonky3.git?rev=a33a312)", - "p3-util 0.3.0 (git+https://github.com/Plonky3/Plonky3.git?rev=a33a312)", + "p3-maybe-rayon 0.4.1", + "p3-util 0.4.1", "paste", "rand 0.9.2", "serde", @@ -1467,10 +1534,10 @@ name = "p3-interpolation" version = "0.3.0" source = "git+https://github.com/TomWambsgans/Plonky3.git?branch=lean-vm-simple#4897086b6f460b969dc0baad5c4dff91a4eb1d67" dependencies = [ - "p3-field 0.3.0 (git+https://github.com/TomWambsgans/Plonky3.git?branch=lean-vm-simple)", - "p3-matrix 0.3.0 (git+https://github.com/TomWambsgans/Plonky3.git?branch=lean-vm-simple)", - "p3-maybe-rayon 0.3.0 (git+https://github.com/TomWambsgans/Plonky3.git?branch=lean-vm-simple)", - "p3-util 0.3.0 (git+https://github.com/TomWambsgans/Plonky3.git?branch=lean-vm-simple)", + "p3-field 0.3.0", + "p3-matrix 0.3.0", + "p3-maybe-rayon 0.3.0", + "p3-util 0.3.0", ] [[package]] @@ -1480,24 +1547,25 @@ source = "git+https://github.com/TomWambsgans/Plonky3.git?branch=lean-vm-simple# dependencies = [ "itertools 0.14.0", "num-bigint", - "p3-field 0.3.0 (git+https://github.com/TomWambsgans/Plonky3.git?branch=lean-vm-simple)", - "p3-monty-31 0.3.0 (git+https://github.com/TomWambsgans/Plonky3.git?branch=lean-vm-simple)", - "p3-poseidon2 0.3.0 (git+https://github.com/TomWambsgans/Plonky3.git?branch=lean-vm-simple)", - "p3-symmetric 0.3.0 (git+https://github.com/TomWambsgans/Plonky3.git?branch=lean-vm-simple)", - "p3-util 0.3.0 (git+https://github.com/TomWambsgans/Plonky3.git?branch=lean-vm-simple)", + "p3-field 0.3.0", + "p3-monty-31 0.3.0", + "p3-poseidon2 0.3.0", + "p3-symmetric 0.3.0", + "p3-util 0.3.0", "rand 0.9.2", "serde", ] [[package]] name = "p3-koala-bear" -version = "0.3.0" -source = "git+https://github.com/Plonky3/Plonky3.git?rev=a33a312#a33a31274a5e78bb5fbe3f82ffd2c294e17fa830" +version = "0.4.1" +source = "git+https://github.com/Plonky3/Plonky3.git?rev=d421e32#d421e32d3821174ae1f7e528d4bb92b7b18ab295" dependencies = [ - "p3-field 0.3.0 (git+https://github.com/Plonky3/Plonky3.git?rev=a33a312)", - "p3-monty-31 0.3.0 (git+https://github.com/Plonky3/Plonky3.git?rev=a33a312)", - "p3-poseidon2 0.3.0 (git+https://github.com/Plonky3/Plonky3.git?rev=a33a312)", - "p3-symmetric 0.3.0 (git+https://github.com/Plonky3/Plonky3.git?rev=a33a312)", + "p3-challenger 0.4.1", + "p3-field 0.4.1", + "p3-monty-31 0.4.1", + "p3-poseidon2 0.4.1", + "p3-symmetric 0.4.1", "rand 0.9.2", ] @@ -1507,9 +1575,9 @@ version = "0.3.0" source = "git+https://github.com/TomWambsgans/Plonky3.git?branch=lean-vm-simple#4897086b6f460b969dc0baad5c4dff91a4eb1d67" dependencies = [ "itertools 0.14.0", - "p3-field 0.3.0 (git+https://github.com/TomWambsgans/Plonky3.git?branch=lean-vm-simple)", - "p3-maybe-rayon 0.3.0 (git+https://github.com/TomWambsgans/Plonky3.git?branch=lean-vm-simple)", - "p3-util 0.3.0 (git+https://github.com/TomWambsgans/Plonky3.git?branch=lean-vm-simple)", + "p3-field 0.3.0", + "p3-maybe-rayon 0.3.0", + "p3-util 0.3.0", "rand 0.9.2", "serde", "tracing", @@ -1518,13 +1586,13 @@ dependencies = [ [[package]] name = "p3-matrix" -version = "0.3.0" -source = "git+https://github.com/Plonky3/Plonky3.git?rev=a33a312#a33a31274a5e78bb5fbe3f82ffd2c294e17fa830" +version = "0.4.1" +source = "git+https://github.com/Plonky3/Plonky3.git?rev=d421e32#d421e32d3821174ae1f7e528d4bb92b7b18ab295" dependencies = [ "itertools 0.14.0", - "p3-field 0.3.0 (git+https://github.com/Plonky3/Plonky3.git?rev=a33a312)", - "p3-maybe-rayon 0.3.0 (git+https://github.com/Plonky3/Plonky3.git?rev=a33a312)", - "p3-util 0.3.0 (git+https://github.com/Plonky3/Plonky3.git?rev=a33a312)", + "p3-field 0.4.1", + "p3-maybe-rayon 0.4.1", + "p3-util 0.4.1", "rand 0.9.2", "serde", "tracing", @@ -1541,30 +1609,30 @@ dependencies = [ [[package]] name = "p3-maybe-rayon" -version = "0.3.0" -source = "git+https://github.com/Plonky3/Plonky3.git?rev=a33a312#a33a31274a5e78bb5fbe3f82ffd2c294e17fa830" +version = "0.4.1" +source = "git+https://github.com/Plonky3/Plonky3.git?rev=d421e32#d421e32d3821174ae1f7e528d4bb92b7b18ab295" [[package]] name = "p3-mds" version = "0.3.0" source = "git+https://github.com/TomWambsgans/Plonky3.git?branch=lean-vm-simple#4897086b6f460b969dc0baad5c4dff91a4eb1d67" dependencies = [ - "p3-dft 0.3.0 (git+https://github.com/TomWambsgans/Plonky3.git?branch=lean-vm-simple)", - "p3-field 0.3.0 (git+https://github.com/TomWambsgans/Plonky3.git?branch=lean-vm-simple)", - "p3-symmetric 0.3.0 (git+https://github.com/TomWambsgans/Plonky3.git?branch=lean-vm-simple)", - "p3-util 0.3.0 (git+https://github.com/TomWambsgans/Plonky3.git?branch=lean-vm-simple)", + "p3-dft 0.3.0", + "p3-field 0.3.0", + "p3-symmetric 0.3.0", + "p3-util 0.3.0", "rand 0.9.2", ] [[package]] name = "p3-mds" -version = "0.3.0" -source = "git+https://github.com/Plonky3/Plonky3.git?rev=a33a312#a33a31274a5e78bb5fbe3f82ffd2c294e17fa830" +version = "0.4.1" +source = "git+https://github.com/Plonky3/Plonky3.git?rev=d421e32#d421e32d3821174ae1f7e528d4bb92b7b18ab295" dependencies = [ - "p3-dft 0.3.0 (git+https://github.com/Plonky3/Plonky3.git?rev=a33a312)", - "p3-field 0.3.0 (git+https://github.com/Plonky3/Plonky3.git?rev=a33a312)", - "p3-symmetric 0.3.0 (git+https://github.com/Plonky3/Plonky3.git?rev=a33a312)", - "p3-util 0.3.0 (git+https://github.com/Plonky3/Plonky3.git?rev=a33a312)", + "p3-dft 0.4.1", + "p3-field 0.4.1", + "p3-symmetric 0.4.1", + "p3-util 0.4.1", "rand 0.9.2", ] @@ -1575,11 +1643,11 @@ source = "git+https://github.com/TomWambsgans/Plonky3.git?branch=lean-vm-simple# dependencies = [ "itertools 0.14.0", "p3-commit", - "p3-field 0.3.0 (git+https://github.com/TomWambsgans/Plonky3.git?branch=lean-vm-simple)", - "p3-matrix 0.3.0 (git+https://github.com/TomWambsgans/Plonky3.git?branch=lean-vm-simple)", - "p3-maybe-rayon 0.3.0 (git+https://github.com/TomWambsgans/Plonky3.git?branch=lean-vm-simple)", - "p3-symmetric 0.3.0 (git+https://github.com/TomWambsgans/Plonky3.git?branch=lean-vm-simple)", - "p3-util 0.3.0 (git+https://github.com/TomWambsgans/Plonky3.git?branch=lean-vm-simple)", + "p3-field 0.3.0", + "p3-matrix 0.3.0", + "p3-maybe-rayon 0.3.0", + "p3-symmetric 0.3.0", + "p3-util 0.3.0", "rand 0.9.2", "serde", "tracing", @@ -1592,14 +1660,14 @@ source = "git+https://github.com/TomWambsgans/Plonky3.git?branch=lean-vm-simple# dependencies = [ "itertools 0.14.0", "num-bigint", - "p3-dft 0.3.0 (git+https://github.com/TomWambsgans/Plonky3.git?branch=lean-vm-simple)", - "p3-field 0.3.0 (git+https://github.com/TomWambsgans/Plonky3.git?branch=lean-vm-simple)", - "p3-matrix 0.3.0 (git+https://github.com/TomWambsgans/Plonky3.git?branch=lean-vm-simple)", - "p3-maybe-rayon 0.3.0 (git+https://github.com/TomWambsgans/Plonky3.git?branch=lean-vm-simple)", - "p3-mds 0.3.0 (git+https://github.com/TomWambsgans/Plonky3.git?branch=lean-vm-simple)", - "p3-poseidon2 0.3.0 (git+https://github.com/TomWambsgans/Plonky3.git?branch=lean-vm-simple)", - "p3-symmetric 0.3.0 (git+https://github.com/TomWambsgans/Plonky3.git?branch=lean-vm-simple)", - "p3-util 0.3.0 (git+https://github.com/TomWambsgans/Plonky3.git?branch=lean-vm-simple)", + "p3-dft 0.3.0", + "p3-field 0.3.0", + "p3-matrix 0.3.0", + "p3-maybe-rayon 0.3.0", + "p3-mds 0.3.0", + "p3-poseidon2 0.3.0", + "p3-symmetric 0.3.0", + "p3-util 0.3.0", "paste", "rand 0.9.2", "serde", @@ -1609,19 +1677,19 @@ dependencies = [ [[package]] name = "p3-monty-31" -version = "0.3.0" -source = "git+https://github.com/Plonky3/Plonky3.git?rev=a33a312#a33a31274a5e78bb5fbe3f82ffd2c294e17fa830" +version = "0.4.1" +source = "git+https://github.com/Plonky3/Plonky3.git?rev=d421e32#d421e32d3821174ae1f7e528d4bb92b7b18ab295" dependencies = [ "itertools 0.14.0", "num-bigint", - "p3-dft 0.3.0 (git+https://github.com/Plonky3/Plonky3.git?rev=a33a312)", - "p3-field 0.3.0 (git+https://github.com/Plonky3/Plonky3.git?rev=a33a312)", - "p3-matrix 0.3.0 (git+https://github.com/Plonky3/Plonky3.git?rev=a33a312)", - "p3-maybe-rayon 0.3.0 (git+https://github.com/Plonky3/Plonky3.git?rev=a33a312)", - "p3-mds 0.3.0 (git+https://github.com/Plonky3/Plonky3.git?rev=a33a312)", - "p3-poseidon2 0.3.0 (git+https://github.com/Plonky3/Plonky3.git?rev=a33a312)", - "p3-symmetric 0.3.0 (git+https://github.com/Plonky3/Plonky3.git?rev=a33a312)", - "p3-util 0.3.0 (git+https://github.com/Plonky3/Plonky3.git?rev=a33a312)", + "p3-dft 0.4.1", + "p3-field 0.4.1", + "p3-matrix 0.4.1", + "p3-maybe-rayon 0.4.1", + "p3-mds 0.4.1", + "p3-poseidon2 0.4.1", + "p3-symmetric 0.4.1", + "p3-util 0.4.1", "paste", "rand 0.9.2", "serde", @@ -1635,22 +1703,22 @@ name = "p3-poseidon2" version = "0.3.0" source = "git+https://github.com/TomWambsgans/Plonky3.git?branch=lean-vm-simple#4897086b6f460b969dc0baad5c4dff91a4eb1d67" dependencies = [ - "p3-field 0.3.0 (git+https://github.com/TomWambsgans/Plonky3.git?branch=lean-vm-simple)", - "p3-mds 0.3.0 (git+https://github.com/TomWambsgans/Plonky3.git?branch=lean-vm-simple)", - "p3-symmetric 0.3.0 (git+https://github.com/TomWambsgans/Plonky3.git?branch=lean-vm-simple)", - "p3-util 0.3.0 (git+https://github.com/TomWambsgans/Plonky3.git?branch=lean-vm-simple)", + "p3-field 0.3.0", + "p3-mds 0.3.0", + "p3-symmetric 0.3.0", + "p3-util 0.3.0", "rand 0.9.2", ] [[package]] name = "p3-poseidon2" -version = "0.3.0" -source = "git+https://github.com/Plonky3/Plonky3.git?rev=a33a312#a33a31274a5e78bb5fbe3f82ffd2c294e17fa830" +version = "0.4.1" +source = "git+https://github.com/Plonky3/Plonky3.git?rev=d421e32#d421e32d3821174ae1f7e528d4bb92b7b18ab295" dependencies = [ - "p3-field 0.3.0 (git+https://github.com/Plonky3/Plonky3.git?rev=a33a312)", - "p3-mds 0.3.0 (git+https://github.com/Plonky3/Plonky3.git?rev=a33a312)", - "p3-symmetric 0.3.0 (git+https://github.com/Plonky3/Plonky3.git?rev=a33a312)", - "p3-util 0.3.0 (git+https://github.com/Plonky3/Plonky3.git?rev=a33a312)", + "p3-field 0.4.1", + "p3-mds 0.4.1", + "p3-symmetric 0.4.1", + "p3-util 0.4.1", "rand 0.9.2", ] @@ -1660,17 +1728,17 @@ version = "0.3.0" source = "git+https://github.com/TomWambsgans/Plonky3.git?branch=lean-vm-simple#4897086b6f460b969dc0baad5c4dff91a4eb1d67" dependencies = [ "itertools 0.14.0", - "p3-field 0.3.0 (git+https://github.com/TomWambsgans/Plonky3.git?branch=lean-vm-simple)", + "p3-field 0.3.0", "serde", ] [[package]] name = "p3-symmetric" -version = "0.3.0" -source = "git+https://github.com/Plonky3/Plonky3.git?rev=a33a312#a33a31274a5e78bb5fbe3f82ffd2c294e17fa830" +version = "0.4.1" +source = "git+https://github.com/Plonky3/Plonky3.git?rev=d421e32#d421e32d3821174ae1f7e528d4bb92b7b18ab295" dependencies = [ "itertools 0.14.0", - "p3-field 0.3.0 (git+https://github.com/Plonky3/Plonky3.git?rev=a33a312)", + "p3-field 0.4.1", "serde", ] @@ -1685,8 +1753,8 @@ dependencies = [ [[package]] name = "p3-util" -version = "0.3.0" -source = "git+https://github.com/Plonky3/Plonky3.git?rev=a33a312#a33a31274a5e78bb5fbe3f82ffd2c294e17fa830" +version = "0.4.1" +source = "git+https://github.com/Plonky3/Plonky3.git?rev=d421e32#d421e32d3821174ae1f7e528d4bb92b7b18ab295" dependencies = [ "serde", ] @@ -1977,6 +2045,8 @@ version = "0.1.0" dependencies = [ "air 0.1.0", "bincode", + "ethereum_ssz", + "ethereum_ssz_derive", "hex", "lean_compiler", "lean_prover", @@ -1984,11 +2054,11 @@ dependencies = [ "leansig", "lookup", "multilinear-toolkit", - "p3-challenger", - "p3-koala-bear 0.3.0 (git+https://github.com/TomWambsgans/Plonky3.git?branch=lean-vm-simple)", - "p3-poseidon2 0.3.0 (git+https://github.com/TomWambsgans/Plonky3.git?branch=lean-vm-simple)", - "p3-symmetric 0.3.0 (git+https://github.com/TomWambsgans/Plonky3.git?branch=lean-vm-simple)", - "p3-util 0.3.0 (git+https://github.com/TomWambsgans/Plonky3.git?branch=lean-vm-simple)", + "p3-challenger 0.3.0", + "p3-koala-bear 0.3.0", + "p3-poseidon2 0.3.0", + "p3-symmetric 0.3.0", + "p3-util 0.3.0", "rand 0.9.2", "serde", "serde_json", @@ -2118,7 +2188,7 @@ dependencies = [ "errno", "libc", "linux-raw-sys", - "windows-sys 0.59.0", + "windows-sys 0.61.2", ] [[package]] @@ -2338,8 +2408,8 @@ dependencies = [ "derive_more", "lookup", "multilinear-toolkit", - "p3-koala-bear 0.3.0 (git+https://github.com/TomWambsgans/Plonky3.git?branch=lean-vm-simple)", - "p3-util 0.3.0 (git+https://github.com/TomWambsgans/Plonky3.git?branch=lean-vm-simple)", + "p3-koala-bear 0.3.0", + "p3-util 0.3.0", "rand 0.9.2", "tracing", "utils", @@ -2361,8 +2431,8 @@ dependencies = [ "backend", "constraints-folder", "fiat-shamir", - "p3-field 0.3.0 (git+https://github.com/TomWambsgans/Plonky3.git?branch=lean-vm-simple)", - "p3-util 0.3.0 (git+https://github.com/TomWambsgans/Plonky3.git?branch=lean-vm-simple)", + "p3-field 0.3.0", + "p3-util 0.3.0", "rayon", ] @@ -2404,7 +2474,7 @@ dependencies = [ "getrandom 0.3.4", "once_cell", "rustix", - "windows-sys 0.59.0", + "windows-sys 0.61.2", ] [[package]] @@ -2630,11 +2700,11 @@ name = "utils" version = "0.1.0" dependencies = [ "multilinear-toolkit", - "p3-challenger", - "p3-koala-bear 0.3.0 (git+https://github.com/TomWambsgans/Plonky3.git?branch=lean-vm-simple)", - "p3-poseidon2 0.3.0 (git+https://github.com/TomWambsgans/Plonky3.git?branch=lean-vm-simple)", - "p3-symmetric 0.3.0 (git+https://github.com/TomWambsgans/Plonky3.git?branch=lean-vm-simple)", - "p3-util 0.3.0 (git+https://github.com/TomWambsgans/Plonky3.git?branch=lean-vm-simple)", + "p3-challenger 0.3.0", + "p3-koala-bear 0.3.0", + "p3-poseidon2 0.3.0", + "p3-symmetric 0.3.0", + "p3-util 0.3.0", "rand 0.9.2", "tracing", "tracing-forest 0.3.0", @@ -2684,18 +2754,18 @@ source = "git+https://github.com/TomWambsgans/whir-p3?branch=lean-vm-simple#f74b dependencies = [ "itertools 0.14.0", "multilinear-toolkit", - "p3-baby-bear 0.3.0 (git+https://github.com/TomWambsgans/Plonky3.git?branch=lean-vm-simple)", - "p3-challenger", + "p3-baby-bear 0.3.0", + "p3-challenger 0.3.0", "p3-commit", - "p3-dft 0.3.0 (git+https://github.com/TomWambsgans/Plonky3.git?branch=lean-vm-simple)", - "p3-field 0.3.0 (git+https://github.com/TomWambsgans/Plonky3.git?branch=lean-vm-simple)", + "p3-dft 0.3.0", + "p3-field 0.3.0", "p3-interpolation", - "p3-koala-bear 0.3.0 (git+https://github.com/TomWambsgans/Plonky3.git?branch=lean-vm-simple)", - "p3-matrix 0.3.0 (git+https://github.com/TomWambsgans/Plonky3.git?branch=lean-vm-simple)", - "p3-maybe-rayon 0.3.0 (git+https://github.com/TomWambsgans/Plonky3.git?branch=lean-vm-simple)", + "p3-koala-bear 0.3.0", + "p3-matrix 0.3.0", + "p3-maybe-rayon 0.3.0", "p3-merkle-tree", - "p3-symmetric 0.3.0 (git+https://github.com/TomWambsgans/Plonky3.git?branch=lean-vm-simple)", - "p3-util 0.3.0 (git+https://github.com/TomWambsgans/Plonky3.git?branch=lean-vm-simple)", + "p3-symmetric 0.3.0", + "p3-util 0.3.0", "rand 0.9.2", "rayon", "thiserror", @@ -2839,12 +2909,12 @@ dependencies = [ "lean_vm", "lookup", "multilinear-toolkit", - "p3-challenger", - "p3-koala-bear 0.3.0 (git+https://github.com/TomWambsgans/Plonky3.git?branch=lean-vm-simple)", - "p3-monty-31 0.3.0 (git+https://github.com/TomWambsgans/Plonky3.git?branch=lean-vm-simple)", - "p3-poseidon2 0.3.0 (git+https://github.com/TomWambsgans/Plonky3.git?branch=lean-vm-simple)", - "p3-symmetric 0.3.0 (git+https://github.com/TomWambsgans/Plonky3.git?branch=lean-vm-simple)", - "p3-util 0.3.0 (git+https://github.com/TomWambsgans/Plonky3.git?branch=lean-vm-simple)", + "p3-challenger 0.3.0", + "p3-koala-bear 0.3.0", + "p3-monty-31 0.3.0", + "p3-poseidon2 0.3.0", + "p3-symmetric 0.3.0", + "p3-util 0.3.0", "pest", "pest_derive", "rand 0.9.2", diff --git a/Cargo.toml b/Cargo.toml index 37d515a9..cec45a5e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -82,7 +82,9 @@ p3-monty-31 = { git = "https://github.com/TomWambsgans/Plonky3.git", branch = "l whir-p3 = { git = "https://github.com/TomWambsgans/whir-p3", branch = "lean-vm-simple" } multilinear-toolkit = { git = "https://github.com/leanEthereum/multilinear-toolkit.git", branch = "lean-vm-simple" } -leansig = { git = "https://github.com/leanEthereum/leansig.git" } +leansig = { git = "https://github.com/qdrvm/leanSig.git", rev = "6db3422006d353ac93fcc2eb933651f9dd311a3e" } +ssz = { package = "ethereum_ssz", version = "0.10.0" } +ssz_derive = { package = "ethereum_ssz_derive", version = "0.10.0" } [dependencies] clap.workspace = true diff --git a/crates/rec_aggregation/Cargo.toml b/crates/rec_aggregation/Cargo.toml index 52f9da7e..252686d9 100644 --- a/crates/rec_aggregation/Cargo.toml +++ b/crates/rec_aggregation/Cargo.toml @@ -28,6 +28,8 @@ multilinear-toolkit.workspace = true bincode.workspace = true serde.workspace = true leansig.workspace = true +ssz.workspace = true +ssz_derive.workspace = true [features] test_config = [] \ No newline at end of file diff --git a/crates/rec_aggregation/src/xmss_aggregate.rs b/crates/rec_aggregation/src/xmss_aggregate.rs index 3107859a..94dd79c5 100644 --- a/crates/rec_aggregation/src/xmss_aggregate.rs +++ b/crates/rec_aggregation/src/xmss_aggregate.rs @@ -1,6 +1,8 @@ use lean_compiler::*; use lean_prover::{prove_execution::prove_execution, verify_execution::verify_execution}; use lean_vm::*; +use leansig::array::FieldArray; +use leansig::serialization::Serializable; use leansig::signature::SignatureScheme; use leansig::signature::SignatureSchemeSecretKey; use leansig::symmetric::message_hash::MessageHash; @@ -8,6 +10,7 @@ use leansig::symmetric::tweak_hash::poseidon::PoseidonTweak; use multilinear_toolkit::prelude::*; use rand::{Rng, SeedableRng, rngs::StdRng}; use serde::{Deserialize, Serialize}; +use ssz_derive::{Decode, Encode}; use std::sync::OnceLock; use std::time::Instant; use std::{mem::transmute, path::Path}; @@ -25,6 +28,9 @@ use config::{ LeanSigSignature, MH, PARAMETER_LEN, RAND_LEN_FE, TWEAK_LEN_FE, }; +type ProofBytes = Vec; +type EncodingRandomnessElement = FieldArray; + static XMSS_AGGREGATION_PROGRAM: OnceLock = OnceLock::new(); fn get_xmss_aggregation_program() -> &'static Bytecode { @@ -37,7 +43,7 @@ pub fn xmss_setup_aggregation_program() { fn build_public_input( pub_keys: &[LeanSigPubKey], - encoding_randomness: &[[F; RAND_LEN_FE]], + encoding_randomness: &[EncodingRandomnessElement], message: &[u8; 32], epoch: u32, ) -> Vec { @@ -219,12 +225,14 @@ pub fn xmss_aggregate_signatures( Ok(xmss_aggregate_signatures_helper(pub_keys, signatures, message, epoch)?.0) } -#[derive(Debug, Clone, Serialize, Deserialize)] +#[derive(Debug, Clone, Serialize, Deserialize, Encode, Decode)] pub struct Devnet2XmssAggregateSignature { pub proof_bytes: Vec, - pub encoding_randomness: Vec<[F; RAND_LEN_FE]>, + pub encoding_randomness: Vec, } +impl Serializable for Devnet2XmssAggregateSignature {} + fn xmss_aggregate_signatures_helper( pub_keys: &[LeanSigPubKey], signatures: &[LeanSigSignature], @@ -241,9 +249,9 @@ fn xmss_aggregate_signatures_helper( // .ok_or(XmssAggregateError::InvalidSigature)?; tracing::warn!("TODO precompute poseidons in parallel + SIMD"); - let encoding_randomness: Vec<[F; RAND_LEN_FE]> = signatures + let encoding_randomness: Vec = signatures .iter() - .map(|sig| unsafe { transmute::<_, [F; RAND_LEN_FE]>(*sig.rho()) }) + .map(|sig| unsafe { transmute(*sig.rho()) }) .collect(); let public_input = build_public_input(pub_keys, &encoding_randomness, message, epoch); let private_input = build_private_input(signatures);