-
Notifications
You must be signed in to change notification settings - Fork 36
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
is_prime=True and is_prime=False produce the same output #51
Comments
Oh, wow, this is quite a bug. I will have a fix for this out later tonight, along with instructions stating how to recover from it if you are affected by it. The short of it is: caching was busted and was returning some invalid keys, but no coins are lost because we can just regenerate any bad keys. |
Yeah, ha, scared me a bit when I noticed it. And sounds good. |
To clarify, are hardened keys the default here, or are unhardened keys? If it's the latter, then:
If it's the former then it would seem that someone simply wouldn't be able to walk up the public chain. |
@shea256 The question of prime/not-prime defaults is separate from the caching bug you found: First: the prime/not-prime (aka hardened/not-hardened) children: The default derivation, when calling with
You ask:
Yes, that's unfortunately true, and those issues are present in BIP32. Bitmerchant's It should be noted that, I will totally admit that none of this is clear, and results in behavior that is possibly dangerous, but that's the way the BIP is written. I could deprecate this method and switch to something a little more explicit. What do you think of this:
As for the reported bug: The behavior you're seeing is due to bad memoization code (written by me, unfortunately). That did not properly calculate cache keys. Calling >>> wallet.get_child(0, is_prime=True)
>>> wallet.get_child(0, is_prime=False) results in both children being prime. Yet, calling >>> wallet.get_child(0, is_prime=False)
>>> wallet.get_child(0, is_prime=True) results in both children being non-prime. I reiterate - this may seem serious, but the common use case is generating a non-prime public key for use as a payment address, so it's unlikely that users will have called both in quick succession and been exposed to the bug. In fact, for this to be exploitable all of these must be true:
If your use of |
Awesome, thanks for putting in the fix! |
The following two operations give me the same output:
I would expect a different key for a hardened (prime) key and an unhardened one.
Is there something I'm doing wrong here or is this a bug in the library?
The text was updated successfully, but these errors were encountered: