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

Support Anoma stdlib APIs sign and verify #2788

Merged
merged 3 commits into from
May 28, 2024
Merged

Support Anoma stdlib APIs sign and verify #2788

merged 3 commits into from
May 28, 2024

Conversation

paulcadman
Copy link
Collaborator

@paulcadman paulcadman commented May 24, 2024

This PR adds support for the Anoma stdlib sign and verify APIs.

builtin anoma-sign
axiom anomaSign : {A : Type}
  -- message to sign
  -> A
  -- secret key
  -> Nat
  -- signed message
  -> Nat;

builtin anoma-verify
axiom anomaVerify : {A : Type}
  -- signed message to verify 
  -> Nat 
  -- public key
  -> Nat 
  -- message with signature removed
  -> A;

These correspond to the sign and sign_open APIs from libsodium respectively.

If signature verification fails in anomaVerify, the Anoma program exits. We copy this behaviour in the evaluator by throwing an error in this case.

Notes

The Haskell Ed25519 library does not support sign_open. Its verification function returns Bool, i.e it checks that the signature is valid. The signed message is simply the concatenation of the signature (64 bytes) and the original message so I added a function to remove the signature from a signed message.

@paulcadman paulcadman added this to the 0.6.2 milestone May 24, 2024
@paulcadman paulcadman self-assigned this May 24, 2024
@paulcadman paulcadman merged commit e30905a into main May 28, 2024
4 checks passed
@paulcadman paulcadman deleted the anoma-sign branch May 28, 2024 08:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants