Skip to main content
Defined in the Base Account SDK
Generates a new P256 key pair for use with Base Account. This is essential for advanced integrations and Sub Account management.

Parameters

This function takes no parameters.

Returns

P256KeyPair
A P256 key pair object containing the public and private keys.

Error Handling

Private Key SecurityNever expose private keys in client-side code or transmit them over insecure channels. Store them securely using appropriate key management systems.

Integration with Sub Accounts

Error Handling

The generateKeyPair function can throw errors for:
  • Cryptographic system failures
  • Insufficient entropy
  • Browser compatibility issues
Always wrap calls to generateKeyPair in a try-catch block:

Security Considerations

Private Key SecurityNever expose private keys in client-side code or transmit them over insecure channels. Store them securely using appropriate key management systems.
  • Store private keys using secure storage mechanisms
  • Never log private keys to console in production
  • Consider using hardware security modules for production applications
  • Implement proper key rotation policies