Class: KeyPair
A keypair represents a private key and its respective public key. It is used for signing data, usually transactions.
Table of contents
Constructors
Properties
Methods
Constructors
constructor
• new KeyPair(private_key
, public_key
): KeyPair
Parameters
Name | Type |
---|---|
private_key | PrivateKey |
public_key | PublicKey |
Returns
Defined in
web.d.ts:1059
Properties
privateKey
• Readonly
privateKey: PrivateKey
Gets the keypair's private key.
Defined in
web.d.ts:1089
publicKey
• Readonly
publicKey: PublicKey
Gets the keypair's public key.
Defined in
web.d.ts:1093
Methods
free
▸ free(): void
Returns
void
Defined in
web.d.ts:1027
serialize
▸ serialize(): Uint8Array
Serializes the keypair to a byte array.
Returns
Uint8Array
Defined in
web.d.ts:1064
sign
▸ sign(data
): Signature
Signs arbitrary data, returns a signature object.
Parameters
Name | Type |
---|---|
data | Uint8Array |
Returns
Defined in
web.d.ts:1070
signTransaction
▸ signTransaction(transaction
): void
Signs a transaction and sets the signature proof on the transaction object.
Parameters
Name | Type |
---|---|
transaction | Transaction |
Returns
void
Defined in
web.d.ts:1075
toAddress
▸ toAddress(): Address
Gets the keypair's address.
Returns
Defined in
web.d.ts:1080
toHex
▸ toHex(): string
Formats the keypair into a hex string.
Returns
string
Defined in
web.d.ts:1085
derive
▸ derive(private_key
): KeyPair
Derives a keypair from an existing private key.
Parameters
Name | Type |
---|---|
private_key | PrivateKey |
Returns
Defined in
web.d.ts:1038
fromHex
▸ fromHex(hex
): KeyPair
Parses a keypair from its hex representation.
Throws when the string is not valid hex format or when it represents less than 64 bytes.
Parameters
Name | Type |
---|---|
hex | string |
Returns
Defined in
web.d.ts:1046
generate
▸ generate(): KeyPair
Generates a new keypair from secure randomness.
Returns
Defined in
web.d.ts:1032
unserialize
▸ unserialize(bytes
): KeyPair
Deserializes a keypair from a byte array.
Throws when the byte array contains less than 64 bytes.
Parameters
Name | Type |
---|---|
bytes | Uint8Array |
Returns
Defined in
web.d.ts:1054