Browse Source
Fix `PublicKey.combine` method (#98)
* Fix `PublicKey.combine` method
* add test
* fix
master
Ofek Lev
3 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with
7 additions and
1 deletions
-
coincurve/keys.py
-
tests/test_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: |
|
|
|
|
|
@ -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]) |
|
|
|