Class BitcoinKey

java.lang.Object
com.codename1.crypto.bitcoin.BitcoinKey

public abstract class BitcoinKey extends Object
A secp256k1 key that signs Bitcoin inputs without necessarily exposing its private key. Psbt.sign(int, BitcoinKey) takes one, so an input can be signed by a key held in memory (fromPrivateKey(byte[])), by a wallet that derives it per signature, or by a hardware device or key service that implements the two signing methods.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Wipes any key material the instance holds.
    static BitcoinKey
    fromPrivateKey(byte[] privateKey)
    A key over a 32-byte private key, which is copied; destroy() wipes the copy.
    byte[]
    The 32-byte x-only Taproot internal key.
    abstract byte[]
    The compressed 33-byte public key.
    byte[]
    The uncompressed 65-byte public key, which some legacy outputs pay to.
    signEcdsa(byte[] sighash)
    An ECDSA signature over a 32-byte sighash, RFC 6979 deterministic and low-S.
    abstract byte[]
    signTaproot(byte[] sighash, byte[] merkleRoot)
    A BIP-340 signature over a 32-byte Taproot sighash, made with the key tweaked by BIP-341 for merkleRoot (null for a key-path-only output, as BIP-86 derives).

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • BitcoinKey

      public BitcoinKey()
  • Method Details

    • getPublicKey

      public abstract byte[] getPublicKey()
      The compressed 33-byte public key.
    • signEcdsa

      public abstract Secp256k1.EcdsaSignature signEcdsa(byte[] sighash)
      An ECDSA signature over a 32-byte sighash, RFC 6979 deterministic and low-S.
    • signTaproot

      public abstract byte[] signTaproot(byte[] sighash, byte[] merkleRoot)
      A BIP-340 signature over a 32-byte Taproot sighash, made with the key tweaked by BIP-341 for merkleRoot (null for a key-path-only output, as BIP-86 derives).
    • getUncompressedPublicKey

      public byte[] getUncompressedPublicKey()
      The uncompressed 65-byte public key, which some legacy outputs pay to.
    • getInternalKey

      public byte[] getInternalKey()
      The 32-byte x-only Taproot internal key.
    • destroy

      public void destroy()
      Wipes any key material the instance holds. The default holds none.
    • fromPrivateKey

      public static BitcoinKey fromPrivateKey(byte[] privateKey)

      A key over a 32-byte private key, which is copied; destroy() wipes the copy.

      Throws
      • IllegalArgumentException: if the bytes are not a valid private key