Instance Method
add(_:)
Creates a new P256K.Schnorr.XonlyKey by applying a BIP-341 Taproot tweak to the x-only public key via secp256k1_xonly_pubkey_tweak_add and verifies the result with secp256k1_xonly_pubkey_tweak_add_check.
- iOS 13.0+
- macCatalyst 13.0+
- macOS 10.15+
- tvOS 13.0+
- visionOS 1.0+
- watchOS 6.0+
func add(_ tweak: [UInt8]) throws -> P256K.Schnorr.XonlyKey
Parameters
-
tweak
-
A 32-byte tweak scalar (typically the output of a Taproot TapTweak tagged hash).
Return Value
A new P256K.Schnorr.XonlyKey equal to the Taproot-tweaked x-only public key.
Discussion
This is the verifier-side companion to add(_:) — the same 32-byte tweak applied to both a private key and its x-only public key yields a valid (sk', xonly') pair for Taproot key-path spending. The verification check at the end catches inconsistent tweak + parity combinations that would otherwise produce a never-verifying output key.
Throws
secp256k1Error.underlyingCryptoError if the tweak is invalid, the result is the point at infinity, or the consistency check fails.