Instance Method
combine(_:format:)
Creates a new P256K.Signing.PublicKey by adding this key together with pubkeys via secp256k1_ec_pubkey_combine, equivalent to point addition on the secp256k1 curve.
- iOS 13.0+
- macCatalyst 13.0+
- macOS 10.15+
- tvOS 13.0+
- visionOS 1.0+
- watchOS 6.0+
func combine(_ pubkeys: [P256K.Signing.PublicKey], format: P256K.Format = .compressed) throws -> P256K.Signing.PublicKey
Parameters
-
pubkeys
-
Additional P256K.Signing.PublicKey values to combine with this key; must contain at least one key.
-
format
-
The serialization format of the returned P256K.Signing.PublicKey; defaults to .compressed.
Return Value
A new P256K.Signing.PublicKey equal to the elliptic-curve sum of all input keys.
Discussion
Point addition is the basis for unhardened BIP-32 child public key derivation and for constructing multisig output keys without revealing individual private keys. The result equals G × (sk₀ + sk₁ + … + skₙ) if each input key was derived from its corresponding private key, making it useful for verifying that a set of keys sums to a known aggregate.
Throws
secp256k1Error.underlyingCryptoError if secp256k1_ec_pubkey_combine fails (e.g., all keys cancel to the point at infinity).