diff --git a/coincurve/keys.py b/coincurve/keys.py index 3823058..0ce29f4 100644 --- a/coincurve/keys.py +++ b/coincurve/keys.py @@ -470,7 +470,7 @@ class PublicKey: new_key = ffi.new('secp256k1_pubkey *') combined = lib.secp256k1_ec_pubkey_combine( - self.context.ctx, new_key, [pk.public_key for pk in public_keys], len(public_keys) + self.context.ctx, new_key, [pk.public_key for pk in [self, *public_keys]], len(public_keys) + 1 ) if not combined: diff --git a/tests/test_keys.py b/tests/test_keys.py index e2a2b76..89190c2 100644 --- a/tests/test_keys.py +++ b/tests/test_keys.py @@ -140,3 +140,9 @@ class TestPublicKey: point = G.multiply(x) assert point.add(k) == G.multiply(int_to_bytes_padded((bytes_to_int(x) + bytes_to_int(k)) % n)) + + def test_combine(self): + a = PrivateKey().public_key + b = PrivateKey().public_key + + assert PublicKey.combine_keys([a, b]) == a.combine([b])