Add anoma-bytearray-{to, from}-anoma-contents
builtins
#2960
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The
anoma-bytearray-{to, from}-anoma-contents
are intended to be used to convert to/from atoms representingByteArrays
. 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:
Where
size
is the size of the ByteArray andcontents
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 by1
.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.