alpenlabs / strata

Rust implementation of the Strata protocol
https://docs.stratabtc.org
Apache License 2.0
23 stars 1 forks source link

STR-504: add sanity test for scalar generation #410

Closed AaronFeickert closed 1 month ago

AaronFeickert commented 1 month ago

Description

It wasn't clear how the library handles generation of secp256k1 scalars when provided with bytes representing a value that overflows the curve order, since simply performing modular reduction induces bias. It turns out that this case is properly rejected, even though the documentation wasn't particularly clear that this would occur.

This PR adds a sanity test demonstrating rejection cases (and a success case, just for the heck of it).

Type of Change

Checklist

Related Issues

None.

AaronFeickert commented 1 month ago

Yeah, I noted ECDSA keys only to match the underlying library structure that generates them. I've updated to make it more clear that this is really just about secp256k1 scalar ranges.