1
1
mirror of https://github.com/anoma/juvix.git synced 2024-12-27 01:23:32 +03:00
juvix/test/Tree
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
..
Asm Use prettyString instead of show . pretty (#2711) 2024-04-12 10:26:54 +02:00
Eval Use prettyString instead of show . pretty (#2711) 2024-04-12 10:26:54 +02:00
Transformation Support Anoma stdlib sign-detached API (#2798) 2024-06-03 19:07:56 +02:00
Asm.hs JuvixTree tests (#2587) 2024-01-25 18:02:06 +00:00
Eval.hs JuvixTree negative evaluation tests (#2601) 2024-02-01 12:58:38 +00:00
Transformation.hs Support nockma scry (#2678) 2024-03-21 16:44:14 +01:00