Class AKeyPair

java.lang.Object
convex.core.crypto.AKeyPair
Direct Known Subclasses:
Ed25519KeyPair

public abstract class AKeyPair extends Object
Abstract base class for key pairs in Convex. Intended as a lightweight container for underlying crypto primitives.
  • Constructor Details

    • AKeyPair

      public AKeyPair()
  • Method Details

    • getAccountKey

      public abstract AccountKey getAccountKey()
      Gets the Account Public Key of this KeyPair
      Returns:
      AccountKey for this KeyPair
    • getEncodedPrivateKey

      public abstract Blob getEncodedPrivateKey()
      Gets the Private key encoded as a Blob
      Returns:
      Blob Private key data encoding
    • signData

      public abstract <R extends ACell> SignedData<R> signData(R value)
      Signs a value with this key pair
      Type Parameters:
      R - Type of Value
      Parameters:
      value - Value to sign. Can be any valid CVM value.
      Returns:
      Signed Data Object
    • equals

      public abstract boolean equals(Object a)
      Overrides:
      equals in class Object
    • sign

      public abstract ASignature sign(Hash hash)
      Signs a hash value with this key pair, producing a signature of the appropriate type.
      Parameters:
      hash - Hash of value to sign
      Returns:
      A Signature compatible with the key pair.
    • createSeeded

      public static AKeyPair createSeeded(long seed)
      Create a deterministic key pair with the given seed. SECURITY: Never use this for valuable keys or real assets: intended for deterministic testing only.
      Parameters:
      seed - Any long value. The same seed will produce the same key pair.
      Returns:
      New key pair
    • create

      public static AKeyPair create(AccountKey publicKey, Blob encodedPrivateKey)
      Create a key pair with the given Address and encoded private key
      Parameters:
      publicKey - Public Key
      encodedPrivateKey - Encoded private key
      Returns:
      New key pair
    • generate

      public static AKeyPair generate()
      Generates a new, secure random key pair. Uses a Java SecureRandom instance.
      Returns:
      New Key Pair instance.
    • create

      public static AKeyPair create(byte[] keyMaterial)
      Creates a key pair using specific key material.
      Parameters:
      keyMaterial - Bytes to use as key
      Returns:
      New key pair
    • getPrivate

      public abstract PrivateKey getPrivate()
      Gets the JCA PrivateKey
      Returns:
      Private Key
    • getPublic

      public abstract PublicKey getPublic()
      Gets the JCA PublicKey
      Returns:
      Public Key
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getJCAKeyPair

      public abstract KeyPair getJCAKeyPair()
      Gets the JCA representation of this Key Pair
      Returns:
      JCA KepPair