Skip to content

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

Open
Forostovec wants to merge 1 commit intoRustCrypto:masterfrom
Forostovec:fix/serde-scalar-canonical-repr
Open

fix: Use CurveWithScalar::to_repr in serde for Scalar and read full ReprSize#1537
Forostovec wants to merge 1 commit intoRustCrypto:masterfrom
Forostovec:fix/serde-scalar-canonical-repr

Conversation

@Forostovec
Copy link

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.

@tarcieri
Copy link
Member

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

There's also #1463.

cc @daxpedda

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants