elliptic-curves icon indicating copy to clipboard operation
elliptic-curves copied to clipboard

fix: Use CurveWithScalar::to_repr in serde for Scalar and read full ReprSize

Open Forostovec opened this issue 3 months ago • 1 comments

Switch Scalar serde to use the curve-specific canonical representation by serializing C::to_repr(self) and deserializing into the full ScalarBytes buffer instead of a hardcoded 56-byte slice. This aligns serde with PrimeField::to_repr, LowerHex/UpperHex, and Vec conversions, and fixes the Ed448 case where the canonical representation is 57 bytes per RFC 8032. The Edwards serde_bare test is adjusted to expect 58 bytes due to the 57-byte payload plus the slice length prefix, while Decaf remains unchanged.

Forostovec avatar Nov 25 '25 21:11 Forostovec

I'd like to get #1471 merged first before we do anything else with scalars.

There's also #1463.

cc @daxpedda

tarcieri avatar Nov 25 '25 21:11 tarcieri