status-im / nim-blscurve

Nim implementation of BLS signature scheme (Boneh-Lynn-Shacham) over Barreto-Lynn-Scott (BLS) curve BLS12-381
Apache License 2.0
26 stars 11 forks source link

Tests for fromBytes/FromHex into unitialized buffer #45

Closed mratsim closed 2 years ago

mratsim commented 4 years ago

43 and #44 required almost a day of investigation for what was initializing a BigInt by iterative sum, except that the result was not properly zero-initialized and so if the sum didn't reach all the limbs the last limbs stayed uninitialized.

We need tests to ensure that:

mratsim commented 2 years ago

All tests are using {.noInit.} buffers: https://github.com/status-im/nim-blscurve/blob/02d4848d8444b12d6935aa57fbbb31988ba0a0b8/tests/serialization.nim#L69-L96

https://github.com/status-im/nim-blscurve/blob/02d4848d8444b12d6935aa57fbbb31988ba0a0b8/tests/eth2_vectors.nim#L49-L52