benbierens
ff6e7589ac
Adds test for preserving field element after conversion
2023-12-22 12:49:08 -06:00
benbierens
1d12c38584
Adds check to ensure value fits in prime field.
2023-12-22 12:49:08 -06:00
benbierens
fbf95e21b8
Adds method for converting 32 bytes to field element
2023-12-22 12:49:07 -06:00
Mark Spanbroek
ddff11d4f0
Convert all types of integers to field element
2023-11-23 17:07:17 +01:00
Mark Spanbroek
c4b4936e26
Handle merkleRoot of empty sequence
...
Co-Authored-By: Balazs Komuves <bkomuves@gmail.com>
2023-11-20 11:40:56 +01:00
Mark Spanbroek
d8a176930d
Pad byte sequences with 0x1
...
To ensure unique field elements for sequences that
end with 0x0.
2023-11-13 11:46:45 +01:00
Mark Spanbroek
ce1d79a59b
Streaming API for converting bytes to field elements
2023-11-13 11:46:45 +01:00
Mark Spanbroek
dbe3d8a692
Rename marshal -> toBytes, unmarshal -> fromBytes
...
For two reasons:
- to distinguish them from the marshalling functions
from constantine
- they do not follow the convention that something
that is marshalled can be unmarshalled, because
they take in 31 bytes but produce 32 bytes
2023-11-08 11:13:45 +01:00
Mark Spanbroek
1c7c5d4ec4
Conversion of field elements into bytes
2023-11-08 11:13:45 +01:00
Mark Spanbroek
03ed357ca4
Only support unmarshalling of little-endian bytes
...
Big-endian bytes had weird padding; 0's to the right,
then a single 0 to the left.
2023-11-02 09:31:10 +01:00
Mark Spanbroek
10b4a3659a
Pad big endian bytes with 0's to the right
2023-11-02 09:31:10 +01:00
Mark Spanbroek
43c2aab913
move unmarshal into its own module called 'io'
...
Includes separate tests for unmarshalling that
were previously tested as part of the merkleRoot
calculation.
Includes tests for unmarshalling little endian
and big endian byte arrays.
2023-11-02 09:31:10 +01:00