-
Notifications
You must be signed in to change notification settings - Fork 65
chore(do not merge): aggregate API #267
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
kevaundray
wants to merge
13
commits into
leanEthereum:main
Choose a base branch
from
kevaundray:feat/lean-sig
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
cea9fe7
fix(poly): drop wrong packing-width assert on the middle eval slice
kevaundray 245fcab
feat(lean_multisig_api): opinionated facade over XMSS and aggregation
kevaundray 8abd87b
refactor(lean_multisig_api): cleanup pass over the facade
kevaundray 4941250
docs: drop the plan documents, folding their live content into the code
kevaundray 0568584
refactor(lean_multisig_api): hide signature representations
kevaundray ba27911
refactor(lean_multisig_api): type public key bytes
kevaundray e33f66e
feat(lean_multisig_api): add multi-claim signatures
kevaundray 02dcdb1
add example for multiclaimSignature
kevaundray 7a6964c
remove locks (zk-alloc is not enabled)
kevaundray b0ee642
rename multi-claim signature to proof
kevaundray 317d9be
require explicit aggregation setup
kevaundray eaaf5a4
Merge remote-tracking branch 'upstream/main' into feat/lean-sig
kevaundray aed6462
use externally resolved proof context
kevaundray File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,4 +3,5 @@ | |
| /docs/benchmark_graphs/.venv | ||
| minimal_zkVM.synctex.gz | ||
| .claude | ||
| misc/.build | ||
| misc/.build | ||
| /.worktrees | ||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| [package] | ||
| name = "lean_multisig_api" | ||
| version.workspace = true | ||
| edition.workspace = true | ||
|
|
||
| [lints] | ||
| workspace = true | ||
|
|
||
| [dependencies] | ||
| # `lean_vm` is here only for the compile-time assertion in `plan.rs` that the crate's | ||
| # `log_inv_rate` choices sit inside the band `lean_prover::default_whir_config` accepts. | ||
| lean_vm.workspace = true | ||
| xmss.workspace = true | ||
| rec_aggregation.workspace = true | ||
| backend.workspace = true | ||
| ssz.workspace = true | ||
| postcard.workspace = true | ||
| rand.workspace = true | ||
| sha2.workspace = true | ||
|
|
||
| [dev-dependencies] | ||
| # `round_trip.rs`'s `#[ignore]`d LEAF_TARGET tests need 1501 real signatures, which | ||
| # `xmss::signers_cache` has pre-generated and cached on disk. The feature is already on in any | ||
| # workspace build because `rec_aggregation` enables it, so this line changes nothing today — it | ||
| # states the dependency this crate's own tests have, rather than borrowing another crate's. | ||
| xmss = { workspace = true, features = ["test-utils"] } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,114 @@ | ||
| use std::fmt::{Display, Formatter}; | ||
|
|
||
| /// Every way a `lean_multisig_api` operation can fail. | ||
| #[non_exhaustive] | ||
| #[derive(Debug)] | ||
| pub enum Error { | ||
| /// [`crate::setup`] must be called before operations involving recursive proofs. | ||
| NotInitialized, | ||
| KeyGen(xmss::XmssKeyGenError), | ||
| Sign(xmss::XmssSignatureError), | ||
| /// A raw signature did not verify. The index refers to the input of [`crate::aggregate`], | ||
| /// or is zero when verifying one standalone [`crate::Signature`]. | ||
| InvalidSignature { | ||
| index: usize, | ||
| source: xmss::XmssVerifyError, | ||
| }, | ||
| Aggregation(rec_aggregation::AggregationError), | ||
| Proof(backend::ProofError), | ||
| /// A serialized [`crate::Signature`] envelope was malformed or unsupported. | ||
| MalformedSignature, | ||
| /// A serialized [`crate::MultiClaimProof`] envelope was malformed or unsupported. | ||
| MalformedMultiClaimProof, | ||
| /// A caller-supplied public key was not canonically encoded. | ||
| MalformedPublicKey, | ||
| /// Secret-key bytes failed their format or integrity checks. | ||
| MalformedSecretKey, | ||
| TooManySigners { | ||
| got: usize, | ||
| max: usize, | ||
| }, | ||
| TooManyClaims { | ||
| got: usize, | ||
| max: usize, | ||
| }, | ||
| Empty, | ||
| MessageMismatch, | ||
| SignerSetMismatch, | ||
| ClaimSetMismatch, | ||
| } | ||
|
|
||
| impl From<xmss::XmssKeyGenError> for Error { | ||
| fn from(err: xmss::XmssKeyGenError) -> Self { | ||
| Self::KeyGen(err) | ||
| } | ||
| } | ||
|
|
||
| impl From<xmss::XmssSignatureError> for Error { | ||
| fn from(err: xmss::XmssSignatureError) -> Self { | ||
| Self::Sign(err) | ||
| } | ||
| } | ||
|
|
||
| impl From<rec_aggregation::AggregationError> for Error { | ||
| fn from(err: rec_aggregation::AggregationError) -> Self { | ||
| match err { | ||
| rec_aggregation::AggregationError::InvalidChildProof(err) => Self::Proof(err), | ||
| err => Self::Aggregation(err), | ||
| } | ||
| } | ||
| } | ||
|
|
||
| impl From<backend::ProofError> for Error { | ||
| fn from(err: backend::ProofError) -> Self { | ||
| Self::Proof(err) | ||
| } | ||
| } | ||
|
|
||
| impl Display for Error { | ||
| fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { | ||
| match self { | ||
| Self::NotInitialized => write!(f, "Call lean_multisig_api::setup() before using recursive proofs"), | ||
| Self::KeyGen(_) => write!(f, "Key generation failed"), | ||
| Self::Sign(_) => write!(f, "XMSS signing operation failed"), | ||
| Self::InvalidSignature { index, .. } => write!(f, "Signature {index} is invalid"), | ||
| Self::Aggregation(_) => write!(f, "Aggregation failed"), | ||
| Self::Proof(_) => write!(f, "Proof error"), | ||
| Self::MalformedSignature => write!(f, "The supplied bytes are not a well-formed signature"), | ||
| Self::MalformedMultiClaimProof => { | ||
| write!(f, "The supplied bytes are not a well-formed multi-claim proof") | ||
| } | ||
| Self::MalformedPublicKey => write!(f, "A supplied public key is not canonically encoded"), | ||
| Self::MalformedSecretKey => write!(f, "Secret key bytes failed validation"), | ||
| Self::TooManySigners { got, max } => write!(f, "Too many signers: {got} (max {max})"), | ||
| Self::TooManyClaims { got, max } => write!(f, "Too many distinct claims: {got} (max {max})"), | ||
| Self::Empty => write!(f, "Nothing to aggregate: no signatures were supplied"), | ||
| Self::MessageMismatch => write!(f, "The signature proves a different claim than the one supplied"), | ||
| Self::SignerSetMismatch => write!(f, "The proved signer set differs from the expected one"), | ||
| Self::ClaimSetMismatch => write!(f, "The proved claims or signer sets differ from the expected ones"), | ||
| } | ||
| } | ||
| } | ||
|
|
||
| impl std::error::Error for Error { | ||
| fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { | ||
| match self { | ||
| Self::NotInitialized => None, | ||
| Self::KeyGen(err) => Some(err), | ||
| Self::Sign(err) => Some(err), | ||
| Self::InvalidSignature { source, .. } => Some(source), | ||
| Self::Aggregation(err) => Some(err), | ||
| Self::Proof(err) => Some(err), | ||
| Self::MalformedSignature | ||
| | Self::MalformedMultiClaimProof | ||
| | Self::MalformedPublicKey | ||
| | Self::MalformedSecretKey | ||
| | Self::TooManySigners { .. } | ||
| | Self::TooManyClaims { .. } | ||
| | Self::Empty | ||
| | Self::MessageMismatch | ||
| | Self::SignerSetMismatch | ||
| | Self::ClaimSetMismatch => None, | ||
| } | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This has been pulled into a separate PR