Class Schnorr.KeyPair
java.lang.Object
com.codename1.security.Schnorr.KeyPair
- Enclosing class:
Schnorr
A private key with its x-only public key, derived once, for signing
many messages; the counterpart of libsecp256k1's secp256k1_keypair.
The two cannot be supplied separately: signing with a public key that
is not the private key's own reveals the private key.
The object holds the private key until destroy() wipes it. Use it
from one thread at a time: a destroy racing a sign signs with a
half-wiped key. Where a native engine signs, it derives the public key
itself and the saving is the engine's to make.
-
Constructor Summary
ConstructorsConstructorDescriptionKeyPair(byte[] privateKey) Derives the public key ofprivateKey, which is copied. -
Method Summary
Modifier and TypeMethodDescriptionvoiddestroy()Wipes the private key; later calls to [#sign(byte[], byte[])] throw.byte[]The x-only public key, as [Schnorr#publicKey(byte[])] returns it.byte[]sign(byte[] message, byte[] auxRand) Signs a message, giving the signature [Schnorr#sign(byte[], byte[], byte[])] gives.
-
Constructor Details
-
KeyPair
public KeyPair(byte[] privateKey) Derives the public key of
privateKey, which is copied.Throws
CryptoException: if the private key is not valid
-
-
Method Details
-
getPublicKey
public byte[] getPublicKey()The x-only public key, as [Schnorr#publicKey(byte[])] returns it. -
sign
public byte[] sign(byte[] message, byte[] auxRand) Signs a message, giving the signature [Schnorr#sign(byte[], byte[], byte[])] gives.
Throws
CryptoException: if the randomness is malformed, or the key has been destroyed
-
destroy
public void destroy()Wipes the private key; later calls to [#sign(byte[], byte[])] throw.
-