Loading...
private.me Docs
Sign out Get started
Overview Quickstart ACIs Concepts Security
01

Configure the registry

Create an .npmrc file in your project root to point the @private.me scope at the private registry. Replace YOUR_TOKEN with the token provided by your account manager.

.npmrc
@xail:registry=https://api.xail.io/npm/
//api.xail.io/npm/:_authToken=YOUR_TOKEN
02

Install the packages

Two packages: the agent SDK for identity and messaging, plus the crypto library for XorIDA threshold sharing.

terminal
npm install @private.me/agent-sdk @private.me/crypto
03

Create an agent identity

Each agent gets a unique DID (Decentralized Identifier) backed by Ed25519 signing and X25519 key agreement keys. No registration, no API key — just a cryptographic identity.

create-agent.ts
import { Agent } from '@private.me/agent-sdk';

const agent = await Agent.create();

console.log(agent.did);
// did:key:z6MkhaXgBZDvotDkL5257faiztiGiC2QtKLGpbnnEGta2doK
Node 20 Note
Ed25519 raw private key export (exportKey('raw')) is not supported on Node 20. Use PKCS8 format to persist agent identities across restarts:
import { exportPKCS8, importFromPKCS8 } from '@private.me/agent-sdk';

// Save
const pkcs8 = await exportPKCS8(agent.identity.privateKey);
fs.writeFileSync('agent.key', pkcs8.value);

// Restore
const identity = await importFromPKCS8(fs.readFileSync('agent.key'));
const agent = await Agent.fromIdentity(identity.value, { registry, transport });
04

Send a secure message

The SDK automatically encrypts with AES-256-GCM, signs with Ed25519, and splits via XorIDA threshold sharing. The recipient needs k-of-n shares to reconstruct.

send-message.ts
const recipientDid = 'did:key:z6Mkr...';

const result = await agent.send(recipientDid, {
  type: 'alert',
  payload: 'Anomaly detected in sector 7',
  timestamp: Date.now()
});

console.log(result.shares.length);
// 3 (split across channels)
05

Receive and verify

HMAC verification happens before reconstruction -- always. If any share has been tampered with, the SDK rejects it before the message is ever assembled.

receive-verify.ts
const shares = await collectShares(channels);

// HMAC verification happens automatically
const message = await agent.receive(shares);

if (message.ok) {
  console.log(message.value.payload);
  // 'Anomaly detected in sector 7'
}