Class DecryptingKeyBag

  • All Implemented Interfaces:
    KeyBag

    public class DecryptingKeyBag
    extends java.lang.Object
    implements KeyBag
    A DecryptingKeyBag filters a pre-existing key bag, decrypting keys as they are requested using the provided AES key. If the keys are encrypted and no AES key provided, ECKey.KeyIsEncryptedException will be thrown.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected org.bouncycastle.crypto.params.KeyParameter aesKey  
      protected KeyBag target  
    • Constructor Summary

      Constructors 
      Constructor Description
      DecryptingKeyBag​(KeyBag target, org.bouncycastle.crypto.params.KeyParameter aesKey)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      ECKey findKeyFromPubKey​(byte[] pubKey)
      Locates a keypair from the keychain given the raw public key bytes.
      ECKey findKeyFromPubKeyHash​(byte[] pubKeyHash, Script.ScriptType scriptType)
      Locates a keypair from the keychain given the hash of the public key, and (optionally) by usage for a specific script type.
      RedeemData findRedeemDataFromScriptHash​(byte[] scriptHash)
      Locates a redeem data (redeem script and keys) from the keychain given the hash of the script.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • target

        protected final KeyBag target
      • aesKey

        protected final org.bouncycastle.crypto.params.KeyParameter aesKey
    • Constructor Detail

      • DecryptingKeyBag

        public DecryptingKeyBag​(KeyBag target,
                                @Nullable
                                org.bouncycastle.crypto.params.KeyParameter aesKey)
    • Method Detail

      • findKeyFromPubKeyHash

        @Nullable
        public ECKey findKeyFromPubKeyHash​(byte[] pubKeyHash,
                                           @Nullable
                                           Script.ScriptType scriptType)
        Description copied from interface: KeyBag
        Locates a keypair from the keychain given the hash of the public key, and (optionally) by usage for a specific script type. This is needed when finding out which key we need to use to redeem a transaction output.
        Specified by:
        findKeyFromPubKeyHash in interface KeyBag
        Parameters:
        pubKeyHash - hash of the keypair to look for
        scriptType - only look for given usage (currently Script.ScriptType.P2PKH or Script.ScriptType.P2WPKH) or null if we don't care
        Returns:
        found key or null if no such key was found.
      • findKeyFromPubKey

        @Nullable
        public ECKey findKeyFromPubKey​(byte[] pubKey)
        Description copied from interface: KeyBag
        Locates a keypair from the keychain given the raw public key bytes.
        Specified by:
        findKeyFromPubKey in interface KeyBag
        Returns:
        ECKey or null if no such key was found.
      • findRedeemDataFromScriptHash

        @Nullable
        public RedeemData findRedeemDataFromScriptHash​(byte[] scriptHash)
        Description copied from interface: KeyBag
        Locates a redeem data (redeem script and keys) from the keychain given the hash of the script. This is needed when finding out which key and script we need to use to locally sign a P2SH transaction input. It is assumed that wallet should not have more than one private key for a single P2SH tx for security reasons. Returns RedeemData object or null if no such data was found.
        Specified by:
        findRedeemDataFromScriptHash in interface KeyBag