Instance Method
add(_:)
Creates a new P256K.MuSig.XonlyKey by computing agg_pk' = agg_pk + G × tweak via secp256k1_musig_pubkey_xonly_tweak_add, as required for BIP-341 Taproot output key construction.
- iOS 13.0+
- macCatalyst 13.0+
- macOS 10.15+
- tvOS 13.0+
- visionOS 1.0+
- watchOS 6.0+
func add(_ tweak: [UInt8]) throws -> P256K.MuSig.XonlyKey
Parameters
-
tweak
-
A 32-byte tweak scalar; must pass secp256k1_ec_seckey_verify and must not negate the aggregate key.
Return Value
A new P256K.MuSig.XonlyKey representing the Taproot output key.
Discussion
Use this method to produce Taproot outputs where tweak is the TapTweak tagged-SHA256 hash as specified by BIP-341. This method is required if you want to sign for the tweaked aggregate key — it updates the key-aggregation cache so subsequent MuSig partial signatures verify against the tweaked aggregate. If you only need the tweaked public key and are not signing, use secp256k1_xonly_pubkey_tweak_add directly instead.
Throws
secp256k1Error.underlyingCryptoError if the tweak is invalid or the result is the point at infinity.