Class PrivateKeyED25519


class PrivateKeyED25519 extends PrivateKey
Encapsulate the ED25519 private key.
  • Constructor Details

    • PrivateKeyED25519

      PrivateKeyED25519(byte[] keyData, @Nullable org.bouncycastle.crypto.params.KeyParameter chainCode)
      Constructor.
      Parameters:
      keyData - the key data
      chainCode - the chain code
  • Method Details

    • generateInternal

      static PrivateKeyED25519 generateInternal()
      Create a new private ED25519 key.
      Returns:
      the new key
    • fromPrivateKeyInfoInternal

      static PrivateKeyED25519 fromPrivateKeyInfoInternal(org.bouncycastle.asn1.pkcs.PrivateKeyInfo privateKeyInfo)
      Create a new private key from a private key info object.
      Parameters:
      privateKeyInfo - the private key info object
      Returns:
      the new key
    • fromSeed

      public static PrivateKey fromSeed(byte[] seed)
      Create an ED25519 key from seed. Implement the published algorithm as defined in BIP32 in order to derive the primary account key from the original (and never stored) master key. The original master key, which is a secure key generated according to the BIP39 specification, is input to this operation, and provides the base cryptographic seed material required to ensure the output is sufficiently random to maintain strong cryptographic assurances. The fromSeed() method must be provided with cryptographically secure material; otherwise, it will produce insecure output.
      Parameters:
      seed - the seed bytes
      Returns:
      the new key
      See Also:
    • derivableKeyED25519

      static PrivateKeyED25519 derivableKeyED25519(byte[] deriveData)
      Create a derived key. The industry standard protocol for deriving an active ed25519 keypair from a BIP39 master key is described in BIP32. By using this deterministic mechanism to derive cryptographically secure keypairs from a single original secret, the user maintains secure access to their wallet, even if they lose access to a particular system or wallet local data store. The active keypair can always be re-derived from the original master key. The use of the fixed "key" values in this code is defined by this deterministic protocol, and this data is mixed, in a deterministic but cryptographically secure manner, with the original master key and/or other derived keys "higher" in the tree to produce a cryptographically secure derived key. This "Key Derivation Function" makes use of secure hash algorithm and a secure hash based message authentication code to produce an initialization vector, and then produces the actual key from a portion of that vector.
      Parameters:
      deriveData - data to derive the key
      Returns:
      the new key
      See Also:
    • fromBytesInternal

      static PrivateKey fromBytesInternal(byte[] privateKey)
      Create a private key from a byte array.
      Parameters:
      privateKey - the byte array
      Returns:
      the new key
    • legacyDeriveChildKey

      static byte[] legacyDeriveChildKey(byte[] entropy, long index)
      Derive a legacy child key.
      Parameters:
      entropy - entropy byte array
      index - the child key index
      Returns:
      the new key
    • legacyDerive

      public PrivateKey legacyDerive(long index)
      Description copied from class: PrivateKey
      Derive a child key based on the index.
      Specified by:
      legacyDerive in class PrivateKey
      Parameters:
      index - the index
      Returns:
      the derived child key
    • isDerivable

      public boolean isDerivable()
      Description copied from class: PrivateKey
      Check if this private key supports derivation.

      This is currently only the case if this private key was created from a mnemonic.

      Specified by:
      isDerivable in class PrivateKey
      Returns:
      boolean
    • derive

      public PrivateKey derive(int index)
      Description copied from class: PrivateKey
      Given a wallet/account index, derive a child key compatible with the iOS and Android wallets.

      Use index 0 for the default account.

      Specified by:
      derive in class PrivateKey
      Parameters:
      index - the wallet/account index of the account, 0 for the default account.
      Returns:
      the derived key
      See Also:
    • getPublicKey

      public PublicKey getPublicKey()
      Description copied from class: PrivateKey
      Derive a public key from this private key.

      The public key can be freely given and used by other parties to verify the signatures generated by this private key.

      Specified by:
      getPublicKey in class PrivateKey
      Returns:
      the corresponding public key for this private key.
    • getChainCode

      public org.bouncycastle.crypto.params.KeyParameter getChainCode()
      Description copied from class: PrivateKey
      Get the chain code of the key
      Specified by:
      getChainCode in class PrivateKey
      Returns:
      the chainCode
    • sign

      public byte[] sign(byte[] message)
      Description copied from class: PrivateKey
      Sign a message with this private key.
      Specified by:
      sign in class PrivateKey
      Parameters:
      message - The array of bytes to sign with
      Returns:
      the signature of the message.
    • toBytes

      public byte[] toBytes()
      Description copied from class: Key
      Create the byte array.
      Specified by:
      toBytes in class PrivateKey
      Returns:
      the byte array representation
    • toBytesRaw

      public byte[] toBytesRaw()
      Description copied from class: PrivateKey
      Extract the raw byte array.
      Specified by:
      toBytesRaw in class PrivateKey
      Returns:
      the raw byte array
    • toBytesDER

      public byte[] toBytesDER()
      Description copied from class: PrivateKey
      Extract the byte array encoded as DER.
      Specified by:
      toBytesDER in class PrivateKey
      Returns:
      the byte array encoded as DER
    • isED25519

      public boolean isED25519()
      Description copied from class: PrivateKey
      Are we an ED25519 key?
      Specified by:
      isED25519 in class PrivateKey
      Returns:
      are we an ED25519 key
    • isECDSA

      public boolean isECDSA()
      Description copied from class: PrivateKey
      Are we an ECDSA key?
      Specified by:
      isECDSA in class PrivateKey
      Returns:
      are we an ECDSA key