kanoniv-agent-auth
Cryptographic identity primitives for AI agents. Ed25519 keypairs, did:agent: decentralized identifiers, signed message envelopes, and provenance entries.
One library, three languages, byte-identical outputs.
Install
# Rust
# TypeScript / JavaScript
# Python
Quick Start
Rust
use ;
// Generate identity
let keypair = generate;
let identity = keypair.identity;
println!;
// did:agent:21fe31dfa154a261626bf854046fd227
// Sign a message
let payload = json!;
let signed = sign.unwrap;
// Verify
signed.verify.unwrap;
// Provenance chain
let entry = create.unwrap;
// Chain entries
let next = create.unwrap;
TypeScript
import {
generateKeyPair,
signMessage,
verifyMessage,
createProvenanceEntry,
provenanceContentHash,
} from "@kanoniv/agent-auth";
// Generate identity
const keypair = generateKeyPair();
console.log("DID:", keypair.identity.did);
// Sign and verify
const signed = signMessage(keypair, { action: "merge", entity_id: "abc123" });
verifyMessage(signed, keypair.identity); // throws on failure
// Provenance chain
const entry = createProvenanceEntry(
keypair,
"merge",
["entity-1", "entity-2"],
[],
{ reason: "duplicate" },
);
const next = createProvenanceEntry(
keypair,
"resolve",
["entity-3"],
[provenanceContentHash(entry)],
{},
);
Python
# Generate identity
=
=
# Sign and verify
=
# raises ValueError on failure
# Provenance chain
=
=
What's Inside
| Primitive | Description |
|---|---|
AgentKeyPair |
Ed25519 keypair generation and persistence |
AgentIdentity |
did:agent: DID derivation and DID Documents |
SignedMessage |
Canonical JSON signing with nonce and timestamp |
ProvenanceEntry |
Signed audit trail with DAG chaining |
DID Format
did:agent:{hex(sha256(public_key)[..16])}
32-character hex identifier derived from the SHA-256 hash of the Ed25519 public key, truncated to 128 bits.
Cross-Language Interop
All three implementations produce byte-identical:
- DIDs from the same public key
- Canonical JSON for signing
- Content hashes for provenance chaining
The fixtures/ directory contains test vectors generated from a known secret key. Every implementation is tested against these fixtures.
Specification
See spec/AGENT-IDENTITY.md for the formal specification.
License
MIT