Unmarshal converts a point, serialised by Marshal, into an x, y pair. On error, x = nil.
(data []byte)
| 295 | // Unmarshal converts a point, serialised by Marshal, into an x, y pair. On |
| 296 | // error, x = nil. |
| 297 | func (BitCurve *BitCurve) Unmarshal(data []byte) (x, y *big.Int) { |
| 298 | byteLen := (BitCurve.BitSize + 7) >> 3 |
| 299 | if len(data) != 1+2*byteLen { |
| 300 | return |
| 301 | } |
| 302 | if data[0] != 4 { // uncompressed form |
| 303 | return |
| 304 | } |
| 305 | x = new(big.Int).SetBytes(data[1 : 1+byteLen]) |
| 306 | y = new(big.Int).SetBytes(data[1+byteLen:]) |
| 307 | return |
| 308 | } |
| 309 | |
| 310 | var theCurve = new(BitCurve) |
| 311 |