Enumeration
P256K
secp256k1 elliptic curve namespace providing ECDSA signing, Schnorr signatures (BIP-340), MuSig2 multi-signatures, ECDH key agreement, and key recovery.
- iOS 13.0+
- macCatalyst 13.0+
- macOS 10.15+
- tvOS 13.0+
- visionOS 1.0+
- watchOS 6.0+
enum P256K
Overview
P256K is the top-level Swift namespace for cryptographic operations on the secp256k1 elliptic curve, which is used in Bitcoin, Lightning Network, and Nostr. The namespace enum itself holds no state; it exists to group cryptographic sub-types (P256K.Signing, P256K.Schnorr, P256K.MuSig, P256K.KeyAgreement, P256K.Recovery) under a single import-friendly prefix that matches the curve name used throughout the Bitcoin ecosystem.
Every operation requires a secp256k1 context managed by P256K.Context. The library provides a shared, pre-randomized instance via rawRepresentation that is suitable for all standard operations; applications do not need to create or manage contexts directly unless they have unusual side-channel or multi-threading requirements.
Side-Channel Protection
Context randomization seeds a blinding factor applied to base-point multiplications during ECDSA / Schnorr signing and public-key derivation, mitigating timing and power-analysis attacks. ECDH (P256K.KeyAgreement) uses a different primitive (variable-point multiplication) and does not benefit from context blinding — consumers needing side-channel-hardened ECDH should perform it on an air-gapped device or with platform-specific mitigations.
Concurrency
P256K conforms to Sendable. The shared context is thread-safe for all const-qualified upstream functions, which covers every public API in this library. No locking is required.
Topics
Sub-Namespaces
Serialization