Overview
Theprimitives.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 aKeypair 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)
Thekid (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
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
- Fast signature generation and verification
- Small key and signature sizes
- Resistance to side-channel attacks
- No need for random number generation during signing
Related Methods
- agent.init() - Generate keypair AND register with Vestauth
- primitives.headers() - Sign requests with a keypair
- primitives.verify() - Verify signatures using a public key