Function generateKeyPair

    • Generates a new Ed25519 key pair asynchronously using cryptographically secure random bytes.

      Returns Promise<KeyPair>

      A promise that resolves to a KeyPair object containing both private and public keys

      This function uses the noble-ed25519 library to generate a secure random private key and derives the corresponding public key. The asynchronous version is recommended for better performance in environments that support it.

      SECURITY WARNING: The generated private key must be stored securely. Never expose it in logs, network requests, or insecure storage. Consider using hardware wallets or encrypted storage for production applications.

      // Generate a new key pair
      const keyPair = await generateKeyPair()

      // Access the keys
      const privateKeyHex = keyPair.privateKey.toHex()
      const publicKeyHex = keyPair.publicKey.toHex()
      const address = keyPair.publicKey.toAddress()

      console.log('Address:', address)
      // Prints: klv1...