1
1
mirror of https://github.com/anoma/juvix.git synced 2024-12-27 17:43:55 +03:00
juvix/test/Tree/Transformation
Paul Cadman 371f8f2258
Support Anoma stdlib sign-detached API (#2798)
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](https://hexdocs.pm/enacl/enacl.html#sign_detached-2)
libsodium API.

This is requried to support to new Anoma nullifier format:


d6a61451ae

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`](c68c7187b1/src/Juvix/Compiler/Nockma/Encoding/ByteString.hs (L14))
function with also accepts the expected size of the resulting
bytestring.
2024-06-03 19:07:56 +02:00
..
Apply.hs JuvixTree "apply" transformation (#2595) 2024-01-30 15:46:10 +00:00
Base.hs JuvixTree recursors and transformation framework (#2594) 2024-01-29 16:43:08 +00:00
CheckNoAnoma.hs Support Anoma stdlib sign-detached API (#2798) 2024-06-03 19:07:56 +02:00
Identity.hs JuvixTree recursors and transformation framework (#2594) 2024-01-29 16:43:08 +00:00
Reachability.hs Filter out unreachable functions in JuvixTree (#2597) 2024-01-30 20:01:07 +00:00