Skip to main content
Defined in the Base Account SDK
Retrieves an existing P256 key pair if one has been previously generated and stored. This is useful for checking if keys already exist before generating new ones.

Parameters

This function takes no parameters.

Returns

P256KeyPair | null
The stored P256 key pair or null if no key pair exists.
Private Key AccessThe retrieved private keys should be handled with the same security considerations as newly generated keys.

Get or Create Pattern

A common pattern is to check for existing keys before generating new ones:

Storage Behavior

The getKeypair function retrieves keys from:
  • Browser’s secure storage (for web applications)
  • Platform-specific secure storage (for native applications)
  • Memory cache (for the current session)
Key pairs are stored securely and are only accessible within the same origin and application context.

Error Handling

The getKeypair function can throw errors for:
  • Storage access failures
  • Data corruption issues
  • Browser compatibility problems
Always wrap calls to getKeypair in a try-catch block:

Key Lifecycle Management

Security Considerations

Private Key AccessThe retrieved private keys should be handled with the same security considerations as newly generated keys.
  • Always verify key integrity before use
  • Implement proper access controls
  • Consider re-generating keys periodically for enhanced security