mirror of
https://github.com/bitcoinj/bitcoinj.git
synced 2025-02-25 07:07:39 +01:00
DeterministicKey: throw a KeyCrypterException instead of an IllegalStateException if the derivation check fails (as this can happen when the password is wrong)
This commit is contained in:
parent
48b4df73a1
commit
a73677e9fb
1 changed files with 4 additions and 1 deletions
|
@ -433,7 +433,10 @@ public class DeterministicKey extends ECKey {
|
|||
downCursor = HDKeyDerivation.deriveChildKey(downCursor, num);
|
||||
}
|
||||
// downCursor is now the same key as us, but with private key bytes.
|
||||
checkState(downCursor.pub.equals(pub));
|
||||
// If it's not, it means we tried decrypting with an invalid password and earlier checks e.g. for padding didn't
|
||||
// catch it.
|
||||
if (!downCursor.pub.equals(pub))
|
||||
throw new KeyCrypterException("Could not decrypt bytes");
|
||||
return checkNotNull(downCursor.priv);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue