diff --git a/Cargo.lock b/Cargo.lock index 68b5c6ed..764d89b0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -652,7 +652,7 @@ dependencies = [ [[package]] name = "backend" version = "0.1.0" -source = "git+https://github.com/leanEthereum/leanVM.git?rev=8fcbd779#8fcbd77958a58666e828315de2d6ce7c93297117" +source = "git+https://github.com/leanEthereum/leanVM.git?rev=e2592df#e2592df4e30fdddbbf8ae26a333116c68cec7026" dependencies = [ "mt-air", "mt-fiat-shamir", @@ -663,8 +663,9 @@ dependencies = [ "mt-symetric", "mt-utils", "mt-whir", - "rayon", + "parallel", "tracing", + "zk-alloc", ] [[package]] @@ -3665,12 +3666,13 @@ checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" [[package]] name = "lean-multisig" version = "0.1.0" -source = "git+https://github.com/leanEthereum/leanVM.git?rev=8fcbd779#8fcbd77958a58666e828315de2d6ce7c93297117" +source = "git+https://github.com/leanEthereum/leanVM.git?rev=e2592df#e2592df4e30fdddbbf8ae26a333116c68cec7026" dependencies = [ "backend", "clap", "lean_vm", "leansig_wrapper", + "libc", "rand 0.10.1", "rec_aggregation", "serde_json", @@ -3683,7 +3685,7 @@ dependencies = [ [[package]] name = "lean_compiler" version = "0.1.0" -source = "git+https://github.com/leanEthereum/leanVM.git?rev=8fcbd779#8fcbd77958a58666e828315de2d6ce7c93297117" +source = "git+https://github.com/leanEthereum/leanVM.git?rev=e2592df#e2592df4e30fdddbbf8ae26a333116c68cec7026" dependencies = [ "backend", "include_dir", @@ -3699,7 +3701,7 @@ dependencies = [ [[package]] name = "lean_prover" version = "0.1.0" -source = "git+https://github.com/leanEthereum/leanVM.git?rev=8fcbd779#8fcbd77958a58666e828315de2d6ce7c93297117" +source = "git+https://github.com/leanEthereum/leanVM.git?rev=e2592df#e2592df4e30fdddbbf8ae26a333116c68cec7026" dependencies = [ "backend", "itertools 0.14.0", @@ -3717,7 +3719,7 @@ dependencies = [ [[package]] name = "lean_vm" version = "0.1.0" -source = "git+https://github.com/leanEthereum/leanVM.git?rev=8fcbd779#8fcbd77958a58666e828315de2d6ce7c93297117" +source = "git+https://github.com/leanEthereum/leanVM.git?rev=e2592df#e2592df4e30fdddbbf8ae26a333116c68cec7026" dependencies = [ "backend", "itertools 0.14.0", @@ -3773,7 +3775,7 @@ dependencies = [ [[package]] name = "leansig_wrapper" version = "0.1.0" -source = "git+https://github.com/leanEthereum/leanVM.git?rev=8fcbd779#8fcbd77958a58666e828315de2d6ce7c93297117" +source = "git+https://github.com/leanEthereum/leanVM.git?rev=e2592df#e2592df4e30fdddbbf8ae26a333116c68cec7026" dependencies = [ "backend", "ethereum_ssz", @@ -4808,7 +4810,7 @@ dependencies = [ [[package]] name = "mt-air" version = "0.1.0" -source = "git+https://github.com/leanEthereum/leanVM.git?rev=8fcbd779#8fcbd77958a58666e828315de2d6ce7c93297117" +source = "git+https://github.com/leanEthereum/leanVM.git?rev=e2592df#e2592df4e30fdddbbf8ae26a333116c68cec7026" dependencies = [ "mt-field", "mt-poly", @@ -4817,13 +4819,13 @@ dependencies = [ [[package]] name = "mt-fiat-shamir" version = "0.1.0" -source = "git+https://github.com/leanEthereum/leanVM.git?rev=8fcbd779#8fcbd77958a58666e828315de2d6ce7c93297117" +source = "git+https://github.com/leanEthereum/leanVM.git?rev=e2592df#e2592df4e30fdddbbf8ae26a333116c68cec7026" dependencies = [ "mt-field", "mt-koala-bear", "mt-symetric", "mt-utils", - "rayon", + "parallel", "serde", "tracing", ] @@ -4831,14 +4833,14 @@ dependencies = [ [[package]] name = "mt-field" version = "0.1.0" -source = "git+https://github.com/leanEthereum/leanVM.git?rev=8fcbd779#8fcbd77958a58666e828315de2d6ce7c93297117" +source = "git+https://github.com/leanEthereum/leanVM.git?rev=e2592df#e2592df4e30fdddbbf8ae26a333116c68cec7026" dependencies = [ "itertools 0.14.0", "mt-utils", "num-bigint 0.3.3", + "parallel", "paste", "rand 0.10.1", - "rayon", "serde", "tracing", ] @@ -4846,7 +4848,7 @@ dependencies = [ [[package]] name = "mt-koala-bear" version = "0.1.0" -source = "git+https://github.com/leanEthereum/leanVM.git?rev=8fcbd779#8fcbd77958a58666e828315de2d6ce7c93297117" +source = "git+https://github.com/leanEthereum/leanVM.git?rev=e2592df#e2592df4e30fdddbbf8ae26a333116c68cec7026" dependencies = [ "itertools 0.14.0", "mt-field", @@ -4854,7 +4856,6 @@ dependencies = [ "num-bigint 0.3.3", "paste", "rand 0.10.1", - "rayon", "serde", "tracing", ] @@ -4862,44 +4863,47 @@ dependencies = [ [[package]] name = "mt-poly" version = "0.1.0" -source = "git+https://github.com/leanEthereum/leanVM.git?rev=8fcbd779#8fcbd77958a58666e828315de2d6ce7c93297117" +source = "git+https://github.com/leanEthereum/leanVM.git?rev=e2592df#e2592df4e30fdddbbf8ae26a333116c68cec7026" dependencies = [ "itertools 0.14.0", "mt-field", "mt-utils", + "parallel", "rand 0.10.1", - "rayon", "serde", "system-info", + "zk-alloc", ] [[package]] name = "mt-sumcheck" version = "0.1.0" -source = "git+https://github.com/leanEthereum/leanVM.git?rev=8fcbd779#8fcbd77958a58666e828315de2d6ce7c93297117" +source = "git+https://github.com/leanEthereum/leanVM.git?rev=e2592df#e2592df4e30fdddbbf8ae26a333116c68cec7026" dependencies = [ "mt-air", "mt-fiat-shamir", "mt-field", "mt-poly", - "rayon", + "parallel", "tracing", + "zk-alloc", ] [[package]] name = "mt-symetric" version = "0.1.0" -source = "git+https://github.com/leanEthereum/leanVM.git?rev=8fcbd779#8fcbd77958a58666e828315de2d6ce7c93297117" +source = "git+https://github.com/leanEthereum/leanVM.git?rev=e2592df#e2592df4e30fdddbbf8ae26a333116c68cec7026" dependencies = [ "mt-field", "mt-koala-bear", - "rayon", + "parallel", + "zk-alloc", ] [[package]] name = "mt-utils" version = "0.1.0" -source = "git+https://github.com/leanEthereum/leanVM.git?rev=8fcbd779#8fcbd77958a58666e828315de2d6ce7c93297117" +source = "git+https://github.com/leanEthereum/leanVM.git?rev=e2592df#e2592df4e30fdddbbf8ae26a333116c68cec7026" dependencies = [ "serde", ] @@ -4907,7 +4911,7 @@ dependencies = [ [[package]] name = "mt-whir" version = "0.1.0" -source = "git+https://github.com/leanEthereum/leanVM.git?rev=8fcbd779#8fcbd77958a58666e828315de2d6ce7c93297117" +source = "git+https://github.com/leanEthereum/leanVM.git?rev=e2592df#e2592df4e30fdddbbf8ae26a333116c68cec7026" dependencies = [ "itertools 0.14.0", "mt-fiat-shamir", @@ -4917,10 +4921,11 @@ dependencies = [ "mt-sumcheck", "mt-symetric", "mt-utils", + "parallel", "rand 0.10.1", - "rayon", "system-info", "tracing", + "zk-alloc", ] [[package]] @@ -5620,6 +5625,14 @@ dependencies = [ "group", ] +[[package]] +name = "parallel" +version = "0.1.0" +source = "git+https://github.com/leanEthereum/leanVM.git?rev=e2592df#e2592df4e30fdddbbf8ae26a333116c68cec7026" +dependencies = [ + "system-info", +] + [[package]] name = "parity-scale-codec" version = "3.7.5" @@ -6379,7 +6392,7 @@ dependencies = [ [[package]] name = "rec_aggregation" version = "0.1.0" -source = "git+https://github.com/leanEthereum/leanVM.git?rev=8fcbd779#8fcbd77958a58666e828315de2d6ce7c93297117" +source = "git+https://github.com/leanEthereum/leanVM.git?rev=e2592df#e2592df4e30fdddbbf8ae26a333116c68cec7026" dependencies = [ "backend", "include_dir", @@ -7428,7 +7441,7 @@ dependencies = [ [[package]] name = "sub_protocols" version = "0.1.0" -source = "git+https://github.com/leanEthereum/leanVM.git?rev=8fcbd779#8fcbd77958a58666e828315de2d6ce7c93297117" +source = "git+https://github.com/leanEthereum/leanVM.git?rev=e2592df#e2592df4e30fdddbbf8ae26a333116c68cec7026" dependencies = [ "backend", "lean_vm", @@ -7522,10 +7535,9 @@ dependencies = [ [[package]] name = "system-info" version = "0.1.0" -source = "git+https://github.com/leanEthereum/leanVM.git?rev=8fcbd779#8fcbd77958a58666e828315de2d6ce7c93297117" +source = "git+https://github.com/leanEthereum/leanVM.git?rev=e2592df#e2592df4e30fdddbbf8ae26a333116c68cec7026" dependencies = [ "libc", - "rayon", ] [[package]] @@ -8072,7 +8084,7 @@ checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" [[package]] name = "utils" version = "0.1.0" -source = "git+https://github.com/leanEthereum/leanVM.git?rev=8fcbd779#8fcbd77958a58666e828315de2d6ce7c93297117" +source = "git+https://github.com/leanEthereum/leanVM.git?rev=e2592df#e2592df4e30fdddbbf8ae26a333116c68cec7026" dependencies = [ "backend", "tracing", @@ -9038,9 +9050,10 @@ dependencies = [ [[package]] name = "zk-alloc" version = "0.1.0" -source = "git+https://github.com/leanEthereum/leanVM.git?rev=8fcbd779#8fcbd77958a58666e828315de2d6ce7c93297117" +source = "git+https://github.com/leanEthereum/leanVM.git?rev=e2592df#e2592df4e30fdddbbf8ae26a333116c68cec7026" dependencies = [ "libc", + "parallel", "system-info", ] diff --git a/crates/common/crypto/Cargo.toml b/crates/common/crypto/Cargo.toml index a4981cf9..83f5c696 100644 --- a/crates/common/crypto/Cargo.toml +++ b/crates/common/crypto/Cargo.toml @@ -13,9 +13,9 @@ version.workspace = true ethlambda-types.workspace = true -lean-multisig = { git = "https://github.com/leanEthereum/leanVM.git", rev = "8fcbd779" } +lean-multisig = { git = "https://github.com/leanEthereum/leanVM.git", rev = "e2592df" } # leansig_wrapper provides XmssPublicKey/XmssSignature types used by lean-multisig's public API -leansig_wrapper = { git = "https://github.com/leanEthereum/leanVM.git", rev = "8fcbd779" } +leansig_wrapper = { git = "https://github.com/leanEthereum/leanVM.git", rev = "e2592df" } leansig.workspace = true thiserror.workspace = true diff --git a/crates/common/crypto/src/lib.rs b/crates/common/crypto/src/lib.rs index 953fc7a8..fd6d4ea8 100644 --- a/crates/common/crypto/src/lib.rs +++ b/crates/common/crypto/src/lib.rs @@ -6,9 +6,10 @@ use ethlambda_types::{ signature::{ValidatorPublicKey, ValidatorSignature}, }; use lean_multisig::{ - ProofError, TypeOneMultiSignature as LMType1, TypeTwoMultiSignature as LMType2, - aggregate_type_1, merge_many_type_1, setup_prover, setup_verifier, split_type_2, verify_type_1, - verify_type_2, + MultiMessageAggregateSignature as LMType2, ProofError, + SingleMessageAggregateSignature as LMType1, aggregate_single_message_signatures, + merge_single_message_aggregates, setup_prover, setup_verifier, split_multi_message_aggregate, + verify_multi_message_aggregate, verify_single_message_aggregate, }; use leansig_wrapper::{XmssPublicKey as LeanSigPubKey, XmssSignature as LeanSigSignature}; use thiserror::Error; @@ -113,7 +114,7 @@ fn into_lean_pubkeys(pubkeys: Vec) -> Vec { } /// Decompress a stored Type-1 proof (without-pubkeys form) into a native -/// `TypeOneMultiSignature` by attaching the resolved validator pubkeys. +/// `SingleMessageAggregateSignature` by attaching the resolved validator pubkeys. fn decompress_type1( pubkeys: Vec, proof_bytes: &ByteList512KiB, @@ -142,11 +143,11 @@ fn compress_type2_to_byte_list(sig: &LMType2) -> Result, @@ -172,7 +173,7 @@ pub fn aggregate_signatures( .map(|(pk, sig)| (pk.into_inner(), sig.into_inner())) .collect(); - let proof = aggregate_type_1(&[], raw_xmss, message.0, slot, LOG_INV_RATE) + let proof = aggregate_single_message_signatures(&[], raw_xmss, message.0, slot, LOG_INV_RATE) .map_err(|err| AggregationError::ProverFailure(err.to_string()))?; compress_type1_to_byte_list(&proof) @@ -216,8 +217,14 @@ pub fn aggregate_mixed( .map(|(pk, sig)| (pk.into_inner(), sig.into_inner())) .collect(); - let proof = aggregate_type_1(&children_native, raw_xmss, message.0, slot, LOG_INV_RATE) - .map_err(|err| AggregationError::ProverFailure(err.to_string()))?; + let proof = aggregate_single_message_signatures( + &children_native, + raw_xmss, + message.0, + slot, + LOG_INV_RATE, + ) + .map_err(|err| AggregationError::ProverFailure(err.to_string()))?; compress_type1_to_byte_list(&proof) } @@ -243,8 +250,14 @@ pub fn aggregate_proofs( .map(|(i, (pubkeys, proof_bytes))| decompress_type1(pubkeys, &proof_bytes, i)) .collect::>()?; - let proof = aggregate_type_1(&children_native, vec![], message.0, slot, LOG_INV_RATE) - .map_err(|err| AggregationError::ProverFailure(err.to_string()))?; + let proof = aggregate_single_message_signatures( + &children_native, + vec![], + message.0, + slot, + LOG_INV_RATE, + ) + .map_err(|err| AggregationError::ProverFailure(err.to_string()))?; compress_type1_to_byte_list(&proof) } @@ -276,7 +289,7 @@ pub fn verify_aggregated_signature( }); } - verify_type_1(&sig)?; + verify_single_message_aggregate(&sig)?; Ok(()) } @@ -287,10 +300,10 @@ pub fn verify_aggregated_signature( /// Merge many independent Type-1 multi-signatures into a single Type-2 proof. /// /// Each input is `(participant_pubkeys, type_1_proof_bytes)` where the bytes -/// are the `compress_without_pubkeys()` form of a `TypeOneMultiSignature`. +/// are the `compress_without_pubkeys()` form of a `SingleMessageAggregateSignature`. /// /// The returned blob is the `compress_without_pubkeys()` form of the resulting -/// `TypeTwoMultiSignature`. A verifier decoding it back needs the per-component +/// `MultiMessageAggregateSignature`. A verifier decoding it back needs the per-component /// pubkey sets in the same order. pub fn merge_type_1s_into_type_2( type_1s: Vec<(Vec, ByteList512KiB)>, @@ -307,7 +320,7 @@ pub fn merge_type_1s_into_type_2( .map(|(i, (pubkeys, proof_bytes))| decompress_type1(pubkeys, &proof_bytes, i)) .collect::>()?; - let merged = merge_many_type_1(type_1s_native, LOG_INV_RATE) + let merged = merge_single_message_aggregates(type_1s_native, LOG_INV_RATE) .map_err(|err| AggregationError::ProverFailure(err.to_string()))?; compress_type2_to_byte_list(&merged) @@ -363,14 +376,14 @@ pub fn verify_type_2_signature( let _ = idx; // index reserved for richer diagnostics if needed } - verify_type_2(&sig)?; + verify_multi_message_aggregate(&sig)?; Ok(()) } /// Split (disaggregate) a Type-2 merged proof into a single Type-1 proof for /// the component bound to `message`. Generates a fresh SNARK; expensive. /// -/// Mirrors leanSpec PR #717 `TypeTwoMultiSignature.split_by_msg`: the caller +/// Mirrors leanSpec PR #717 `split_multi_message_aggregate_by_message`: the caller /// supplies the expected message (an attestation data root or the block /// root) and the wrapper locates the unique matching component inside the /// decompressed proof. Returns the `compress_without_pubkeys()` form of the @@ -402,7 +415,7 @@ pub fn split_type_2_by_message( _ => return Err(AggregationError::MultipleMessages), }; - let component = split_type_2(type_2, index, LOG_INV_RATE) + let component = split_multi_message_aggregate(type_2, index, LOG_INV_RATE) .map_err(|err| AggregationError::ProverFailure(err.to_string()))?; compress_type1_to_byte_list(&component)