mirror of
https://github.com/bitcoin-s/bitcoin-s.git
synced 2025-03-25 09:02:11 +01:00
Mask BIP39 password in the BIP39KeyManager (#2350)
* Mask BIP39 password in the BIP39KeyManager * Add toString test
This commit is contained in:
parent
24c776e453
commit
af4a0baf2d
2 changed files with 20 additions and 0 deletions
|
@ -44,6 +44,13 @@ class BIP39KeyManagerApiTest extends KeyManagerApiUnitTest {
|
|||
assert(km != dummy)
|
||||
}
|
||||
|
||||
it must "not put the bip39 password in the toString" in {
|
||||
val passpharse = "test-bip39-passpharse"
|
||||
val km = withInitializedKeyManager(bip39PasswordOpt = Some(passpharse))
|
||||
assert(!km.toString.contains(passpharse))
|
||||
assert(km.toString.contains("Masked(bip39password)"))
|
||||
}
|
||||
|
||||
it must "initialize the key manager" in {
|
||||
val entropy = MnemonicCode.getEntropy256Bits
|
||||
val aesPasswordOpt = KeyManagerTestUtil.aesPasswordOpt
|
||||
|
|
|
@ -76,6 +76,19 @@ case class BIP39KeyManager(
|
|||
def getRootXPub: ExtPublicKey = {
|
||||
rootExtPrivKey.extPublicKey
|
||||
}
|
||||
|
||||
/** This is overriden because we do not have a type for bip39 passwords
|
||||
* for which we can extend [[org.bitcoins.crypto.MaskedToString]]
|
||||
*/
|
||||
override def toString: String = {
|
||||
s"""
|
||||
|BIP39KeyManager(
|
||||
| mnemonic=$mnemonic,
|
||||
| kmParams=$kmParams,
|
||||
| bip39PasswordOpt=${bip39PasswordOpt.map(_ =>
|
||||
s"Masked(bip39password)")},
|
||||
| creationTime=$creationTime)""".stripMargin
|
||||
}
|
||||
}
|
||||
|
||||
object BIP39KeyManager
|
||||
|
|
Loading…
Add table
Reference in a new issue