Skip to main content

Function: generateRandomKeyPair()

function generateRandomKeyPair(): object

Generate a new private key and its corresponding public key.

Returns

object

The new private key and its corresponding public key

privateKey

privateKey: 0x${string};

publicKey

publicKey: 0x${string};

Example

const { privateKey, publicKey } = generateKeyPair();
console.log(privateKey);
console.log(publicKey);
// => "0x..."
// => "0x..."

Defined

@nilfoundation/niljs/src/signers/privateKey.ts:24