Skip to main content

Overview

The primitives.keypair() function generates a new Ed25519 keypair or reuses an existing private key. This is a low-level primitive that doesn’t register the agent with Vestauth.
For most use cases, use agent.init() instead, which both creates a keypair AND registers it with Vestauth. Use primitives.keypair() only when you need manual control over key generation.

Signature

Parameters

string
default:"undefined"
An existing private JWK as a JSON string. If provided, the keypair will be derived from this key instead of generating a new one.
string
default:"agent"
A prefix used internally for key identification. Typically left as default.

Return Value

Returns a Keypair object containing both public and private JWKs:
PublicJwk
required
The public key in JWK format.
PrivateJwk
required
The private key in JWK format.

Example - Generate New Keypair

Example - Reuse Existing Private Key

Example Output

Key ID (kid)

The kid (Key ID) field is automatically calculated using the RFC 7638 JWK thumbprint algorithm. This provides a consistent, collision-resistant identifier for the public key.

Secure Storage

The private key (privateJwk.d) must be kept secret. Never:
  • Commit it to version control
  • Send it over unencrypted connections
  • Log it to console in production
  • Expose it in client-side code

Integration with Other Methods

Algorithm Details

Vestauth uses the Ed25519 signature algorithm:
  • Key Type: OKP (Octet String Key Pairs)
  • Curve: Ed25519
  • Key Size: 256 bits
  • Signature Size: 512 bits
  • Security Level: ~128 bits
Ed25519 provides:
  • Fast signature generation and verification
  • Small key and signature sizes
  • Resistance to side-channel attacks
  • No need for random number generation during signing