diff options
| author | Clawd <ai@clawd.bot> | 2026-03-08 16:32:53 -0700 |
|---|---|---|
| committer | Clawd <ai@clawd.bot> | 2026-03-08 16:32:53 -0700 |
| commit | cc7637b833bb66cd8715d466e615a23ec0f05c92 (patch) | |
| tree | 7c242a3c3be0ad122f5d74f8a8c04f80a85c4c98 /internal/secp256k1 | |
| parent | 0dcf191e7f63f35efe85afb60bcb57f4934a0acb (diff) | |
Diffstat (limited to 'internal/secp256k1')
| -rw-r--r-- | internal/secp256k1/point.go | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/internal/secp256k1/point.go b/internal/secp256k1/point.go index 1def176..5215590 100644 --- a/internal/secp256k1/point.go +++ b/internal/secp256k1/point.go | |||
| @@ -162,6 +162,18 @@ func (p *Point) Negate() *Point { | |||
| 162 | return &Point{x: p.x.Clone(), y: negY, infinity: false} | 162 | return &Point{x: p.x.Clone(), y: negY, infinity: false} |
| 163 | } | 163 | } |
| 164 | 164 | ||
| 165 | // XBytes returns the x-coordinate as a 32-byte big-endian slice. | ||
| 166 | // Returns nil for the point at infinity. | ||
| 167 | func (p *Point) XBytes() []byte { | ||
| 168 | if p.infinity { | ||
| 169 | return nil | ||
| 170 | } | ||
| 171 | b := p.x.value.Bytes() | ||
| 172 | out := make([]byte, 32) | ||
| 173 | copy(out[32-len(b):], b) | ||
| 174 | return out | ||
| 175 | } | ||
| 176 | |||
| 165 | // String returns a readable representation | 177 | // String returns a readable representation |
| 166 | func (p *Point) String() string { | 178 | func (p *Point) String() string { |
| 167 | if p.infinity { | 179 | if p.infinity { |
