Package convex.core.crypto
Class AKeyPair
java.lang.Object
convex.core.crypto.AKeyPair
- Direct Known Subclasses:
Ed25519KeyPair
Abstract base class for key pairs in Convex.
Intended as a lightweight container for underlying crypto primitives.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic AKeyPair
create(byte[] keyMaterial)
Creates a key pair using specific key material.static AKeyPair
create(AccountKey publicKey, Blob encodedPrivateKey)
Create a key pair with the given Address and encoded private keystatic AKeyPair
createSeeded(long seed)
Create a deterministic key pair with the given seed.abstract boolean
static AKeyPair
generate()
Generates a new, secure random key pair.abstract AccountKey
Gets the Account Public Key of this KeyPairabstract Blob
Gets the Private key encoded as a Blobabstract KeyPair
Gets the JCA representation of this Key Pairabstract PrivateKey
Gets the JCA PrivateKeyabstract PublicKey
Gets the JCA PublicKeyabstract ASignature
Signs a hash value with this key pair, producing a signature of the appropriate type.abstract <R extends ACell>
SignedData<R>signData(R value)
Signs a value with this key pairtoString()
-
Constructor Details
-
AKeyPair
public AKeyPair()
-
-
Method Details
-
getAccountKey
Gets the Account Public Key of this KeyPair- Returns:
- AccountKey for this KeyPair
-
getEncodedPrivateKey
Gets the Private key encoded as a Blob- Returns:
- Blob Private key data encoding
-
signData
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
-
sign
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
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
Create a key pair with the given Address and encoded private key- Parameters:
publicKey
- Public KeyencodedPrivateKey
- Encoded private key- Returns:
- New key pair
-
generate
Generates a new, secure random key pair. Uses a Java SecureRandom instance.- Returns:
- New Key Pair instance.
-
create
Creates a key pair using specific key material.- Parameters:
keyMaterial
- Bytes to use as key- Returns:
- New key pair
-
getPrivate
Gets the JCA PrivateKey- Returns:
- Private Key
-
getPublic
Gets the JCA PublicKey- Returns:
- Public Key
-
toString
-
getJCAKeyPair
Gets the JCA representation of this Key Pair- Returns:
- JCA KepPair
-