From cc7637b833bb66cd8715d466e615a23ec0f05c92 Mon Sep 17 00:00:00 2001 From: Clawd Date: Sun, 8 Mar 2026 16:32:53 -0700 Subject: feat: NIP-04 encrypt/decrypt using internal secp256k1 --- internal/secp256k1/point.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'internal/secp256k1/point.go') 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 { return &Point{x: p.x.Clone(), y: negY, infinity: false} } +// XBytes returns the x-coordinate as a 32-byte big-endian slice. +// Returns nil for the point at infinity. +func (p *Point) XBytes() []byte { + if p.infinity { + return nil + } + b := p.x.value.Bytes() + out := make([]byte, 32) + copy(out[32-len(b):], b) + return out +} + // String returns a readable representation func (p *Point) String() string { if p.infinity { -- cgit v1.2.3