feat(cli): add sign and verify to the account subcommand #27627
Merged
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.
Motivation
Signatures can be created/verified programmatically both from AleoHQ/sdk (web-ui via aleo.tools) and within leo but not from the official leo or snarkOS CLIs.
This PR creates two straightforward commands for working with Aleo signatures:
leo account sign [--private-key-file <privateKeyFile>|--private-key <privateKey>] -m <message> -s [seed] [--raw]
outputs an Aleo signature of the message, signed with the private key.
leo account verify -s <signature> -m <message> -a <address> [--raw]
outputs
The signature is valid
orThe signature is invalid
if the signature is verified or invalid respectfully.By default, all messages are snarkVM values so signatures are compatible with the
signature::verify
leo operator. If the--raw
flag is passed, the message will be parsed as bytes, which is compatible with the [AleoHQ/sdk].If a private key is not specified from arguments, the CLI will attempt to load it from environment, then from a
.env
file.Test Plan
No code outside of the new features were changed and test coverage is as follows:
Related PRs
.env
support)Screenshots
Signing raw messages
Generating a signature of an Aleo value (
5field
)Verifying a signed Aleo value in leo playground.