-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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`](https://hexdocs.pm/enacl/enacl.html#sign-2) and [`sign_open`](https://hexdocs.pm/enacl/enacl.html#sign_open-2) 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.
- Loading branch information
1 parent
d233bbd
commit e30905a
Showing
29 changed files
with
269 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
module Juvix.Compiler.Nockma.Encoding.Ed25519 where | ||
|
||
import Data.ByteString qualified as BS | ||
import Juvix.Prelude.Base | ||
|
||
-- | Remove the Ed25519 signature from a signed message. | ||
-- The signaure of an Ed25519 message is the first 64 bytes of the signed message. | ||
removeSignature :: ByteString -> ByteString | ||
removeSignature = BS.drop 64 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.