Initializer
init(dataRepresentation:keyParity:)
Creates a P256K.Signing.XonlyKey from a 32-byte X-coordinate and its Y-coordinate parity.
- iOS 13.0+
- macCatalyst 13.0+
- macOS 10.15+
- tvOS 13.0+
- visionOS 1.0+
- watchOS 6.0+
init<D>(dataRepresentation data: D, keyParity: Bool = false) throws where D : ContiguousBytes
Parameters
-
data
-
The 32-byte X coordinate of the x-only public key.
-
keyParity
-
The Y-coordinate parity of the full public key: false = even (the canonical BIP-340 representative — the only honest value when parity was never persisted, since it cannot be recovered from the X coordinate alone), true = odd. Round-trips directly from parity.
Discussion
Useful when reconstructing an x-only key from a persisted (bytes, parity) pair (e.g. a Taproot output-key identifier stored in a wallet database).
Throws
secp256k1Error.incorrectKeySize if data is not exactly 32 bytes; secp256k1Error.underlyingCryptoError if the coordinate fails secp256k1_xonly_pubkey_parse (out of range or no curve point).