Skip to content
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

feat(cli): add sign and verify to the account subcommand #27627

Merged
merged 1 commit into from
Feb 7, 2024

Conversation

Meshiest
Copy link
Contributor

@Meshiest Meshiest commented Feb 7, 2024

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 or The 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:

  • Signature creation (unseeded)
  • Seeded signature creation
  • Valid signature verification
  • Invalid signature verification (message is incorrect)
  • Invalid signature verification (address is incorrect)
  • All of the above using plaintext messages (rather than aleo values)

Related PRs

Screenshots

Signing raw messages
CLI sign and verify commands on --raw messages

Generating a signature of an Aleo value (5field)
image

Verifying a signed Aleo value in leo playground.
A screenshot of leo playground with code that verifies a signature on the left, and a valid and invalid run of the code on the right

program helloworld_unk5cko.aleo {
  transition main(public s: signature, a: address, m: field) -> bool {
      return s.verify(a, m);
  }
}

Copy link
Collaborator

@d0cd d0cd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@d0cd d0cd merged commit 9938195 into ProvableHQ:testnet3 Feb 7, 2024
13 checks passed
@Meshiest Meshiest deleted the feat-cli-sign branch February 7, 2024 19:01
@Meshiest
Copy link
Contributor Author

Meshiest commented Feb 7, 2024

documentation for this branch is available in this PR: ProvableHQ/welcome#334

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants