Classes
KeyPair
A keypair represents a private key and its respective public key. It is used for signing data, usually transactions.
Constructors
new KeyPair()
Parameter | Type |
---|---|
First | PublicKey |
Returns |
---|
KeyPair |
Properties
privateKey
Gets the keypair's private key.
publicKey
Gets the keypair's public key.
Methods
free()
serialize()
Serializes the keypair to a byte array.
sign()
Signs arbitrary data, returns a signature object.
Parameter | Type |
---|---|
First | Uint8Array |
Returns |
---|
Signature |
signTransaction()
Signs a transaction and sets the signature proof on the transaction object.
Parameter | Type |
---|---|
First | Transaction |
toAddress()
Gets the keypair's address.
Returns |
---|
Address |
toHex()
Formats the keypair into a hex string.
derive()
Derives a keypair from an existing private key.
Parameter | Type |
---|---|
First | PrivateKey |
Returns |
---|
KeyPair |
deserialize()
Deserializes a keypair from a byte array.
Throws when the byte array contains less than 64 bytes.
Parameter | Type |
---|---|
First | Uint8Array |
Returns |
---|
KeyPair |
fromHex()
Parses a keypair from its hex representation.
Throws when the string is not valid hex format or when it represents less than 64 bytes.
Parameter | Type |
---|---|
First | string |
Returns |
---|
KeyPair |
generate()
Generates a new keypair from secure randomness.
Returns |
---|
KeyPair |