@aroha-sdk/core
v1.2.4
Published
Aroha core: identity, crypto, messaging, transport
Readme
@aroha-sdk/core
Transport, identity, and cryptographic primitives for the Aroha Protocol — the foundation every agent and mandate is built on.
Install
npm install @aroha-sdk/coreQuick example
import { generateKeyPair, generateDid, buildEnvelope, validateEnvelope } from "@aroha-sdk/core";
// Generate Ed25519 keypair and derive a DID for an agent
const { publicKey, privateKey } = await generateKeyPair();
const did = generateDid({ publicKey, name: "my-flight-agent" });
// → "did:aroha:my-flight-agent"
// Wrap a mandate token in a signed envelope for transport
const envelope = await buildEnvelope(
{ type: "mandate-request", mandateToken: token, payload: { action: "book-flight" } },
privateKey,
did,
);
// Recipient validates the envelope signature
const { valid, body, reason } = await validateEnvelope(envelope, senderPublicKey);Why this exists in the mandate chain
Agents need cryptographic identity to hold and present mandates. A mandate is issued to a specific DID — without a verifiable DID backed by an Ed25519 keypair, there is no way to prove that the mandate recipient is the legitimate grantee. @aroha-sdk/core provides that identity layer.
API
generateKeyPair()— generate an Ed25519 keypair. Returns{ publicKey, privateKey }.generateDid(opts)— derive adid:aroha:DID from a public key and agent name.buildEnvelope(body, privateKey, senderDID)— sign a JSON body and wrap it in a transport envelope.validateEnvelope(envelope, senderPublicKey)— verify the envelope signature. Returns{ valid, body?, reason? }.ArohaServer— HTTP server implementing the Aroha Protocol/v1/runcontract.ArohaClient— HTTP client for calling compliant agents.
License
MIT
