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

[mainnet] Add signing/verifying Aleo values #38

Open
wants to merge 1 commit into
base: mainnet
Choose a base branch
from

Conversation

Meshiest
Copy link

Same as #37 but for mainnet

Description

Signing/verifying aleo values is present in the snarkOS CLI and the leo CLI. Verification is present in leo.

As Aleo does not natively support byte-encoded messages, this feature is necessary for generating signatures programmatically for Aleo/Leo programs. The original sign and verify functions have not been altered for backwards compatibility.

Features

This PR add the following functions (where 5field is a valid Aleo value

  • Account.sign_value("5field")
  • Account.verify_value(Signature, "5field")
  • Signature.sign_value(PrivateKey, "5field")
  • Signature.verify_value(Address, "5field")
  • PrivateKey.sign_value("5field")

These functions automatically convert the string value into an Aleo value, then the Aleo value into Fields, which can be signed/verified natively. This is in part to bring parity closer to the CLI implementations, but also so a Value would not need to be constructed for every sign/verify.

Docs & Testing

Docs were updated to include a copy of the sign/verify function usage, but with sign_value and verify_value. Tests were also updated to include the new functions.

Validation

Signatures produced by this code have additionally been tested against the following program on Leo Playground:

program helloworld_pq56kj9.aleo {
  transition main(public a: address, b: signature, c: field) -> bool {
      return b.verify(a, c);
  }
}

Signature generation:

>>> import aleo
>>> key = aleo.PrivateKey.from_string('APrivateKey1zkp3dQx4WASWYQVWKkq14v3RoQDfY2kbLssUj7iifi1VUQ6')
>>> str(key.sign_value('5field'))
'sign1zfmsaxvjajwje6ekk00wd0kyjc6p3j9xmkhkmc79064ge26q7ypenhsmwuel4gzx2jfpgl0lw9vqln74ljvtr00zkum0z0pe7tvd7qravkjwgtm3t90lvxdrjjl07td0k4w5sysm7w22lfhfkqgdk690pcu5an22wssu4q6d3754cljxugdnrnccneldp79m3j5drzxs0s4sxwet8kv'
$ leo run main aleo184vuwr5u7u0ha5f5k44067dd2uaqewxx6pe5ltha5pv99wvhfqxqv339h4 sign1zfmsaxvjajwje6ekk00wd0kyjc6p3j9xmkhkmc79064ge26q7ypenhsmwuel
4gzx2jfpgl0lw9vqln74ljvtr00zkum0z0pe7tvd7qravkjwgtm3t90lvxdrjjl07td0k4w5sysm7w22lfhfkqgdk690pcu5an22wssu4q6d3754cljxugdnrnccneldp79m3j5drzxs0s4s
xwet8kv 5field

image

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.

1 participant