Instance Method
add(_:format:)
Creates a new P256K.Signing.PublicKey by computing public_key' = public_key + G × tweak via secp256k1_ec_pubkey_tweak_add, where G is the secp256k1 generator point.
- 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.Signing.PublicKey
Parameters
-
tweak
-
A 32-byte tweak scalar; must not produce the point at infinity.
-
format
-
The serialization format of the returned P256K.Signing.PublicKey; defaults to .compressed.
Return Value
A new P256K.Signing.PublicKey equal to the original key plus the tweak times the generator.
Discussion
The public-key counterpart to add(_:) — applying the same 32-byte tweak to both forms yields a valid (sk', pk') pair. Used by BIP-32 unhardened public-key-only derivation (watch-only wallets) when the parent private key is not available.
Throws
secp256k1Error.underlyingCryptoError if the tweak is invalid or the result is the point at infinity.