Skip to content

Commit 40ef465

Browse files
authored
Merge pull request #216 from jonas-lj/main
Add regression test for Fr serialization
2 parents 99d9774 + 981822a commit 40ef465

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

test/bls12-381.test.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -975,6 +975,14 @@ describe('bls12-381 encoding', () => {
975975
);
976976
});
977977

978+
979+
should('Fr toBytes + fromBytes roundtrip', () => {
980+
const scalar = 42n;
981+
const bytes = bls12_381.fields.Fr.toBytes(scalar);
982+
eql(bytes, hexToBytes('000000000000000000000000000000000000000000000000000000000000002a'));
983+
eql(bls12_381.fields.Fr.fromBytes(bytes), 42n);
984+
});
985+
978986
should('G1 toBytes + fromBytes roundtrip', () => {
979987
const priv = G1Point.BASE.multiply(42n);
980988
const publicKey = priv.toBytes(true);

0 commit comments

Comments
 (0)