Structure
P256K.Signing.PrivateKey
secp256k1 ECDSA private key for deterministically signing messages and producing P256K.Signing.ECDSASignature values using the secp256k1 curve.
- iOS 13.0+
- macCatalyst 13.0+
- macOS 10.15+
- tvOS 13.0+
- visionOS 1.0+
- watchOS 6.0+
struct PrivateKey
Mentioned In
Overview
Create a key by generating fresh randomness or by deserializing an existing raw, PEM, or DER representation. The 32-byte secret scalar must pass secp256k1_ec_seckey_verify (declared in Vendor/secp256k1/include/secp256k1.h) to be accepted. Keep dataRepresentation confidential; exposing it compromises all signatures produced by this key.
The format parameter controls whether the public key companion is serialized as compressed (33 bytes, default) or uncompressed (65 bytes). The private key itself is always 32 bytes regardless of format.
Signing
ECDSA signing uses secp256k1_ecdsa_sign with RFC 6979 deterministic nonce generation. All signatures produced by this key are automatically normalized to lower-S form per BIP-146, which is the only form accepted by secp256k1_ecdsa_verify. Pass a Digest or raw Data to the signature(for:) overloads on this type; the data overload hashes with SHA-256 before signing.
Topics
Construction
Inspection
Operators
Initializers
Instance Methods