@getaid/crypto
v1.0.1
Published
Ed25519 keypair generation, challenge-response signing, and HMAC badge URL utilities for getaid.dev
Maintainers
Readme
@getaid/crypto
Ed25519 keypair generation, challenge-response signing/verification, and HMAC badge URL utilities for getaid.dev, the universal identity registry for AI agents.
Installation
npm install @getaid/cryptoUsage
Keypair Generation
import { generateKeypair } from "@getaid/crypto";
const { publicKey, privateKey } = await generateKeypair();
// publicKey: hex-encoded Ed25519 public key
// privateKey: hex-encoded Ed25519 private keyChallenge-Response Signing
import { generateNonce, signChallenge, verifySignature } from "@getaid/crypto";
// Verifier generates a nonce
const nonce = generateNonce();
// Agent signs the nonce with its private key
const signature = await signChallenge(nonce, privateKey);
// Verifier checks the signature against the registry's public key
const isValid = await verifySignature(nonce, signature, publicKey);HMAC Badge URLs
import { generateHmacBadgeUrl, verifyHmacBadgeUrl } from "@getaid/crypto";
// Generate a signed badge URL (5-minute TTL)
const { url } = generateHmacBadgeUrl("AID-000012347", hmacSecret);
// Verify a signed badge URL
const isValid = verifyHmacBadgeUrl(url, hmacSecret);API
| Function | Description |
| ---------------------- | --------------------------------------------------- |
| generateKeypair | Generate an Ed25519 keypair (hex-encoded) |
| generateNonce | Generate a cryptographic nonce (hex string) |
| signChallenge | Sign a challenge string with an Ed25519 private key |
| verifySignature | Verify an Ed25519 signature against a public key |
| generateHmacBadgeUrl | Create an HMAC-signed badge URL with 5-minute TTL |
| verifyHmacBadgeUrl | Verify an HMAC-signed badge URL |
Dependencies
@noble/ed25519for Ed25519 operations
License
MIT
