Instance Method
add(_:format:)
Creates a new P256K.MuSig.PublicKey by computing agg_pk' = agg_pk + G × tweak via secp256k1_musig_pubkey_ec_tweak_add (declared in Vendor/secp256k1-zkp/include/secp256k1_musig.h), updating the key aggregation cache in-place.
- iOS 13.0+
- macCatalyst 13.0+
- macOS 10.15+
- tvOS 13.0+
- visionOS 1.0+
- watchOS 6.0+
func add(_ tweak: [UInt8], format: P256K.Format = .compressed) throws -> P256K.MuSig.PublicKey
Parameters
-
tweak
-
A 32-byte tweak scalar; must pass secp256k1_ec_seckey_verify and must not negate the aggregate key.
-
format
-
The serialization format of the returned P256K.MuSig.PublicKey; defaults to .compressed.
Return Value
A new P256K.MuSig.PublicKey equal to the original aggregate key plus the tweak times the generator.
Discussion
Use this method when you need to sign for a BIP-32 child key derived from the aggregate. The cache update ensures the subsequent partial signatures verify against the tweaked aggregate. If you only need the tweaked public key for verification (not signing), use secp256k1_ec_pubkey_tweak_add directly instead.
Throws
secp256k1Error.underlyingCryptoError if the tweak is invalid or the result is the point at infinity.