UnmarshalText decodes a point from a hex-encoded buffer.
(b []byte)
| 68 | |
| 69 | // UnmarshalText decodes a point from a hex-encoded buffer. |
| 70 | func (p *Point) UnmarshalText(b []byte) error { |
| 71 | var buf [32]byte |
| 72 | if len(b) != hex.EncodedLen(len(buf)) { |
| 73 | return fmt.Errorf("ecmath.Point.UnmarshalText got input with wrong length %d", len(b)) |
| 74 | } |
| 75 | _, err := hex.Decode(buf[:], b) |
| 76 | if err != nil { |
| 77 | return err |
| 78 | } |
| 79 | if !(*edwards25519.ExtendedGroupElement)(p).FromBytes(&buf) { |
| 80 | return fmt.Errorf("invalid ecmath.Point encoding") |
| 81 | } |
| 82 | return nil |
| 83 | } |