cloudflare / circl

CIRCL: Cloudflare Interoperable Reusable Cryptographic Library
http://blog.cloudflare.com/introducing-circl
Other
1.27k stars 142 forks source link

In ecc/bls12381, Pairing operations seems racy #493

Closed AnomalRoil closed 6 months ago

AnomalRoil commented 6 months ago

It seems there are internal functions in circl that are "racy", because they are passing arrays using pointers, reading from these arrays and writing to these same arrays, causing data races when multiple go routines are operating on the same points at the same time.

This was discovered in the drand/kyber repo, where we have recently accepted a PR to add circl support for BLS12-381, but sadly despite having a test for data races in pairings, we didn't catch it earlier. (we weren't using -race in CI by mistake).

To reproduce:

git clone https://github.com/drand/kyber.git
cd kyber
go test -race ./pairing/circl_bls12381/...

This should fail in the TestRacePairings test.