Skip to content

Commit 2b3a74f

Browse files
author
Jeff Garzik
committed
Merge pull request jgarzik#15 from runeksvendsen/master
Key generation from secret: handle failure of point multiplication
2 parents b8ff69f + a6e1678 commit 2b3a74f

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

bitcoin/key.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ def generate(self, secret=None):
4242
group = ssl.EC_KEY_get0_group(self.k)
4343
pub_key = ssl.EC_POINT_new(group)
4444
ctx = ssl.BN_CTX_new()
45+
if not ssl.EC_POINT_mul(group, pub_key, priv_key, None, None, ctx):
46+
raise ValueError("Could not derive public key from the supplied secret.")
4547
ssl.EC_POINT_mul(group, pub_key, priv_key, None, None, ctx)
4648
ssl.EC_KEY_set_private_key(self.k, priv_key)
4749
ssl.EC_KEY_set_public_key(self.k, pub_key)

0 commit comments

Comments
 (0)