secp256kfun icon indicating copy to clipboard operation
secp256kfun copied to clipboard

chore: Nonce::from_bytes() returns Self instead of Option<Self>

Open tvolk131 opened this issue 10 months ago • 1 comments

Point::from_slice() only returns None if it is passed a byte slice that isn't exactly 33 bytes long. Since Nonce::from_bytes() always passes in 33 bytes, we can guarantee to the caller that this never fails.

tvolk131 avatar Feb 09 '25 19:02 tvolk131

Hey @tvolk131, I asked Lloyd about this one and it due to the fact that not every 33 byte array will render a valid Point, see Point::from_bytes. For example, the first byte must be either 0x02 or 0x03 to indicate that the y-coordinate is even/odd.

nickfarrow avatar Feb 20 '25 02:02 nickfarrow

Yes it's very important that not all 33 byte arrays are valid points because not all 32 byte arrays are valid x-coordinates on secp256k1 (around half are not!).

LLFourn avatar May 20 '25 06:05 LLFourn