What version of Go are you using (go version)?
$ go version
go version go1.12.9 linux/amd64
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 (prefix 0x04) at the moment, as can be seen in the source code, which probably is fine given that it's supposed to be a companion for elliptic.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 (prefixes 0x02 and 0x03) 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 change Marshal() without breaking backwards compatibility (the only option I see at the moment is introducing another function like MarshalCompressed()).
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 (prefixes0x02and0x03) 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
ellipticcould 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()).