Client and backend. This class is shared: the same code is compiled into your app and into your server, so everything on this page works in both.
public static final class Schnorr.KeyPair
- Object
- Schnorr.KeyPair
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.
Constructors
public KeyPair(byte[] privateKey) | Derives the public key of privateKey, which is copied. |
Methods
public byte[] getPublicKey() | The x-only public key, as [Schnorr#publicKey(byte[])] returns it. |
public byte[] sign(byte[] message, byte[] auxRand) | Signs a message, giving the signature [Schnorr#sign(byte[], byte[], byte[])] gives. |
public void destroy() | Wipes the private key; later calls to [#sign(byte[], byte[])] throw. |
Inherited methods
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.