-
Notifications
You must be signed in to change notification settings - Fork 17.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
crypto/elliptic: handle compressed formats in new MarshalCompressed, UnmarshalCompressed #34105
Comments
/cc @FiloSottile |
First byte can be 0x2 or 0x3 (compressed form). To unmarshal used formula y² = x³ - 3x + b. Reuse code from `IsOnCurve`. Closes golang#34105 issue
Change https://golang.org/cl/202819 mentions this issue: |
First byte can be 0x2 or 0x3 (compressed form). To unmarshal used formula y² = x³ - 3x + b. Reuse code from `IsOnCurve`. Closes golang#34105 issue
First byte can be 0x2 or 0x3 (compressed form). To unmarshal used formula y² = x³ - 3x + b. Reuse code from `IsOnCurve`. Closes golang#34105 issue
First byte can be 0x2 or 0x3 (compressed form). To unmarshal used formula y² = x³ - 3x + b. Reuse code from `IsOnCurve`. Closes golang#34105 issue
Can you provide some examples of projects that had to implement this? If it's indeed common, I'd support implementing it. |
|
Supporting compressed formats in
In order to support this, we could add two new functions to the
|
Adding to proposal minutes, seems headed for likely accept. |
First byte can be 0x2 or 0x3 (compressed form). To unmarshal used formula y² = x³ - 3x + b. Reuse code from `IsOnCurve`. closes golang#34105 issue
First byte can be 0x2 or 0x3 (compressed form). To unmarshal used formula y² = x³ - 3x + b. Reuse code from `IsOnCurve`. closes golang#34105 issue
@katiehockman PR updated MarshalCompressed implemented as specified in section 4.3.6 (2. compressed form) of ANSI X9.62 |
Based on the discussion above and the specific retitling of adding new functions instead of overloading the existing ones, this seems like a likely accept. |
No change in consensus, so accepted. |
Encode and Decode elliptic curve points in compressed format. This will be superceeded by golang/go#34105 in Go 1.15
* SECG1 Encode/Decode Encode and Decode elliptic curve points in compressed format. This will be superceeded by golang/go#34105 in Go 1.15
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
I think so.
What operating system and processor architecture are you using (
go env
)?play.golang.org
What did you do?
https://play.golang.org/p/ugkQeobnYRP
What did you expect to see?
Successful unmarshaling.
What did you see instead?
Failed unmarshaling.
The real problem
elliptic.Unmarshal()
only supports uncompressed format (prefix0x04
) at the moment, as can be seen in the source code, which probably is fine given that it's supposed to be a companion forelliptic.Marshal()
that only uses that format to serialize the point. But at the same time it would be very nice to have support for compressed (prefixes0x02
and0x03
) format that is being used in the wild, it doesn't cost much in terms of code (there is a nice snippet on SO) and this proposed change is certainly backwards-compatible. At the moment I see this (or similar) code being duplicated by several projects that use compressed format, thus this issue.Of course it would be very nice if
elliptic
could also serialize into this format, but that's a bit more complicated, because you can't changeMarshal()
without breaking backwards compatibility (the only option I see at the moment is introducing another function likeMarshalCompressed()
).The text was updated successfully, but these errors were encountered: