doc.go raw
1 // Package ecdsa provides ECDSA (Elliptic Curve Digital Signature Algorithm)
2 // operations on the secp256k1 curve.
3 //
4 // This package is a domain-focused wrapper around the core p256k1 primitives,
5 // providing a clean API for ECDSA signature creation and verification.
6 //
7 // # Bounded Context: Digital Signatures (ECDSA)
8 //
9 // This bounded context encompasses:
10 // - Signature creation from message hash and private key
11 // - Signature verification against public key
12 // - Signature serialization (compact and DER formats)
13 // - Public key recovery from signatures
14 //
15 // # Value Objects
16 //
17 // - Signature: An ECDSA signature (r, s components)
18 // - CompactSignature: 64-byte compact format (r || s)
19 // - RecoverableSignature: Signature with recovery ID
20 //
21 // # Domain Services
22 //
23 // - Sign: Create a signature
24 // - Verify: Verify a signature
25 // - Recover: Recover public key from signature
26 //
27 // # Usage
28 //
29 // import "next.orly.dev/pkg/p256k1/ecdsa"
30 //
31 // // Sign a message hash
32 // sig, err := ecdsa.Sign(messageHash, privateKey)
33 // if err != nil {
34 // // handle error
35 // }
36 //
37 // // Verify the signature
38 // valid := ecdsa.Verify(sig, messageHash, publicKey)
39 //
40 // # Thread Safety
41 //
42 // All functions in this package are safe for concurrent use.
43 //
44 // # Security Notes
45 //
46 // - Uses RFC 6979 for deterministic nonce generation
47 // - Automatically normalizes to low-S form (BIP-146)
48 // - Message must be a 32-byte hash (use crypto/sha256 or similar)
49 package ecdsa
50