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 sign-detached API #2798

Merged
merged 1 commit into from
Jun 3, 2024
Merged

Conversation

paulcadman
Copy link
Collaborator

@paulcadman paulcadman commented Jun 3, 2024

This PR adds support for the Anoma stdlib sign-detached API.

builtin anoma-sign-detached
axiom anomaSignDetached : {A : Type}
  -- message to sign
  -> A
  -- private key
  -> Nat
 -- signature
  -> Nat;

This corresponds to the sign_detached libsodium API.

This is requried to support to new Anoma nullifier format:

anoma/anoma@d6a6145

Previously resource nullifiers were defined using anomaSign:

nullifier (r : Resource) (secretKey : Nat) : Nat :=
  anomaSign (anomaEncode (nullifierHeader, r)) secretKey;

They are now defined using anomaSignDetached:

nullifier (r : Resource) (secretKey : Nat) : Nat :=
  let encodedResource : Nat := anomaEncode (nullifierHeader, r) in
  anomaEncode (encodedResource , anomaSignDetached encodedResource secretKey);

This is so that a logic function can access the nullified resources directly from the nullifier field.

Evaluator Note

When decoding a public key, private key or signature from an integer atom to a bytestring it's important to pad the bytestring to the appropriate number of bytes. For example a private key must be 64 bytes but the corresponding encoded integer may fit into 63 bytes or fewer bytes (depending on leading zeros). This PR also fixes this issue by adding a atomToByteStringLen function with also accepts the expected size of the resulting bytestring.

@paulcadman paulcadman self-assigned this Jun 3, 2024
@paulcadman paulcadman force-pushed the anoma-sign-detached branch 2 times, most recently from 9b7b754 to 17f4acc Compare June 3, 2024 13:51
This is requried to support to new Anoma nullifier format:

anoma/anoma@d6a6145
@paulcadman paulcadman force-pushed the anoma-sign-detached branch from 17f4acc to a8e1251 Compare June 3, 2024 14:05
@paulcadman paulcadman requested a review from janmasrovira June 3, 2024 14:06
@paulcadman paulcadman merged commit 371f8f2 into main Jun 3, 2024
4 checks passed
@paulcadman paulcadman deleted the anoma-sign-detached branch June 3, 2024 17:07
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