anoma / juvix

A language for intent-centric and declarative decentralised applications
https://docs.juvix.org
GNU General Public License v3.0
442 stars 54 forks source link

Add support for anoma specific functions to the Core evaluator #2851

Closed paulcadman closed 5 days ago

paulcadman commented 1 week ago

This PR adds support for the anoma{encode, decode, sign, verify, signDetached, verifyDetached} functions to the Core evaluator.

Encoding / Decoding

The serialization of values to ByteString for anomaEncode reuses the Stored Core serialization.

Anoma expects encoding of bytes as little-endian integers. In general ByteString -> Integer is ambiguous because two ByteStrings that differ only by zero padding will map to the same integer. So we must encode the length of the ByteString in the encoded integer alongside the ByteString data so when it is decoded we can pad appropriately. We use the same length encoding scheme that is used by Nockma jam.

Verify

The Core evaluator implementation of anomaVerify crashes if the verification fails. This matches the behaviour of Anoma node.

jvc Support

You can now use anoma-* functions within .jvc core files.