mirror of
https://github.com/anoma/juvix.git
synced 2024-11-30 14:13:27 +03:00
8d03ac2b6c
The `anoma-bytearray-{to, from}-anoma-contents` are intended to be used to convert to/from atoms representing `ByteArrays`. These builtins are required temporarily until Anoma Node makes ByteArray representation uniform across all of its APIs. We represent ByteArrays in nock as a cell: ``` [size contents] ``` Where `size` is the size of the ByteArray and `contents` is an Atom representing the bytes in LSB ordering. The `size` is required in general because the encoding of ByteArrays to Atoms is ambiguous. For example the ByteArrays [0x01; 0x00] and [0x01] are represented by `1`. Some Anoma ByteArrays like keys and signatures are represented using on the `contents` atom because the size is constant. Users of Anoma APIs have to strip / add size information from ByteArrays depending on where the data is used. The new builtins provide this facility. These builtins are temporary because it's been agreed with Anoma engineering team to change the Anoma APIs to make the ByteArray representation uniform, i.e always represent ByteArrays using `[size content]`. When this is implemented in Anoma Node we can remove these builtins. ``` builtin anoma-bytearray-to-anoma-contents axiom toAnomaContents : ByteArray -> Nat; builtin anoma-bytearray-from-anoma-contents axiom fromAnomaContents : -- | The size of the ByteArray Nat -- | The contents of the ByteArray -> Nat -- | The resulting ByteArray -> ByteArray; ``` |
||
---|---|---|
.. | ||
negative | ||
positive |