Skip to main content

Cryptographic identity primitives for AI agents - Ed25519 keypairs, DIDs, signed envelopes, and provenance entries

Project description

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
cargo add kanoniv-agent-auth

# TypeScript / JavaScript
npm install @kanoniv/agent-auth

# Python
pip install kanoniv-agent-auth

Quick Start

Rust

use kanoniv_agent_auth::{AgentKeyPair, SignedMessage, ProvenanceEntry, ActionType};

// Generate identity
let keypair = AgentKeyPair::generate();
let identity = keypair.identity();
println!("DID: {}", identity.did);
// did:agent:21fe31dfa154a261626bf854046fd227

// Sign a message
let payload = serde_json::json!({"action": "merge", "entity_id": "abc123"});
let signed = SignedMessage::sign(&keypair, payload).unwrap();

// Verify
signed.verify(&identity).unwrap();

// Provenance chain
let entry = ProvenanceEntry::create(
    &keypair,
    ActionType::Merge,
    vec!["entity-1".into(), "entity-2".into()],
    vec![],
    serde_json::json!({"reason": "duplicate"}),
).unwrap();

// Chain entries
let next = ProvenanceEntry::create(
    &keypair,
    ActionType::Resolve,
    vec!["entity-3".into()],
    vec![entry.content_hash()],
    serde_json::json!({}),
).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

from kanoniv_agent_auth import AgentKeyPair, ProvenanceEntry
import json

# Generate identity
keypair = AgentKeyPair.generate()
identity = keypair.identity()
print(f"DID: {identity.did}")

# Sign and verify
signed = keypair.sign('{"action": "merge", "entity_id": "abc123"}')
signed.verify(identity)  # raises ValueError on failure

# Provenance chain
entry = ProvenanceEntry.create(
    keypair, "merge",
    ["entity-1", "entity-2"], [],
    '{"reason": "duplicate"}',
)

next_entry = ProvenanceEntry.create(
    keypair, "resolve",
    ["entity-3"], [entry.content_hash()],
    "{}",
)

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

kanoniv_agent_auth-0.1.0-cp313-cp313-win_amd64.whl (430.1 kB view details)

Uploaded CPython 3.13Windows x86-64

kanoniv_agent_auth-0.1.0-cp313-cp313-manylinux_2_34_x86_64.whl (603.4 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.34+ x86-64

kanoniv_agent_auth-0.1.0-cp313-cp313-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl (1.0 MB view details)

Uploaded CPython 3.13macOS 10.12+ universal2 (ARM64, x86-64)macOS 10.12+ x86-64macOS 11.0+ ARM64

kanoniv_agent_auth-0.1.0-cp312-cp312-win_amd64.whl (430.1 kB view details)

Uploaded CPython 3.12Windows x86-64

kanoniv_agent_auth-0.1.0-cp312-cp312-manylinux_2_34_x86_64.whl (603.3 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.34+ x86-64

kanoniv_agent_auth-0.1.0-cp312-cp312-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl (1.0 MB view details)

Uploaded CPython 3.12macOS 10.12+ universal2 (ARM64, x86-64)macOS 10.12+ x86-64macOS 11.0+ ARM64

kanoniv_agent_auth-0.1.0-cp311-cp311-win_amd64.whl (431.8 kB view details)

Uploaded CPython 3.11Windows x86-64

kanoniv_agent_auth-0.1.0-cp311-cp311-manylinux_2_34_x86_64.whl (606.3 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.34+ x86-64

kanoniv_agent_auth-0.1.0-cp311-cp311-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl (1.1 MB view details)

Uploaded CPython 3.11macOS 10.12+ universal2 (ARM64, x86-64)macOS 10.12+ x86-64macOS 11.0+ ARM64

kanoniv_agent_auth-0.1.0-cp310-cp310-win_amd64.whl (431.8 kB view details)

Uploaded CPython 3.10Windows x86-64

kanoniv_agent_auth-0.1.0-cp310-cp310-manylinux_2_34_x86_64.whl (606.5 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.34+ x86-64

kanoniv_agent_auth-0.1.0-cp310-cp310-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl (1.1 MB view details)

Uploaded CPython 3.10macOS 10.12+ universal2 (ARM64, x86-64)macOS 10.12+ x86-64macOS 11.0+ ARM64

File details

Details for the file kanoniv_agent_auth-0.1.0-cp313-cp313-win_amd64.whl.

File metadata

File hashes

Hashes for kanoniv_agent_auth-0.1.0-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 297004c88369e36939a68354236db5047a7f3261bb2bbcb16cc440e08c1917e7
MD5 f8f06694cfea25d84002d90d0829f7a5
BLAKE2b-256 36a99e2a024444a95011d622321d88eda63546d51eecfb0d0b057149e379755b

See more details on using hashes here.

File details

Details for the file kanoniv_agent_auth-0.1.0-cp313-cp313-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for kanoniv_agent_auth-0.1.0-cp313-cp313-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 b4183b84a65dd0e44766902abe9f68eff59d12739997836b11c2a5aefd461e5a
MD5 226216387f3bba3563659738a6f02e34
BLAKE2b-256 2cc92f2d80522c4be49f883c3d9ddb56ea66fb5f68e2e51e7c7e4cde9065c5bf

See more details on using hashes here.

File details

Details for the file kanoniv_agent_auth-0.1.0-cp313-cp313-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl.

File metadata

File hashes

Hashes for kanoniv_agent_auth-0.1.0-cp313-cp313-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
Algorithm Hash digest
SHA256 e58176ada1d7a153a07b3e60ae04b304d7a5ade69d355c729aecab72bc45ba2d
MD5 b7f50238a10cb7eecb87c49c0e39adb1
BLAKE2b-256 a2eea1a20eb8ccc8a2bb067b38e62b649317bfaa7d0c478b8e230b859b024c3b

See more details on using hashes here.

File details

Details for the file kanoniv_agent_auth-0.1.0-cp312-cp312-win_amd64.whl.

File metadata

File hashes

Hashes for kanoniv_agent_auth-0.1.0-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 80ad9ac4b72a45e9f89c4f275f912cf53f8733f034fbdddeeb983ddb14c33503
MD5 f818d75415047a30ca614580f47f60b7
BLAKE2b-256 d48766ad38bff6c2f853badd9fab3b1a5f6cb7e7aa1ee722e7165b4f76463e08

See more details on using hashes here.

File details

Details for the file kanoniv_agent_auth-0.1.0-cp312-cp312-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for kanoniv_agent_auth-0.1.0-cp312-cp312-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 d010393e205080c2013a23b646f0b34cb2e955e67241b7eefc6e17295dc0131e
MD5 b350838c974ad0bfcc8034b1d1dc0990
BLAKE2b-256 81054098551bfb89e4f7bef0b150e5b79839eea39d69281b97bb830cb121f207

See more details on using hashes here.

File details

Details for the file kanoniv_agent_auth-0.1.0-cp312-cp312-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl.

File metadata

File hashes

Hashes for kanoniv_agent_auth-0.1.0-cp312-cp312-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
Algorithm Hash digest
SHA256 ae97aa1c29a2d9cfe7a3145e306c52c76e385cf554ca6d9e0f127d0c880c1a96
MD5 6dc40a36ae2a13323f4bb6e0f181a52a
BLAKE2b-256 9488f2acc085232d3b72b8ae6f86e26bca1d2d52271c0b3000c660d1b7bb2ece

See more details on using hashes here.

File details

Details for the file kanoniv_agent_auth-0.1.0-cp311-cp311-win_amd64.whl.

File metadata

File hashes

Hashes for kanoniv_agent_auth-0.1.0-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 85384614a99893f06607e16551d8878253c99a2b7001569e2b5b1ba02f8e6293
MD5 9f3763b16a86c847e61b79cb456589db
BLAKE2b-256 363c865d92ea4ac56f02ef7a1def0b728397e915c3c92a4b6ad084c5a38a17e3

See more details on using hashes here.

File details

Details for the file kanoniv_agent_auth-0.1.0-cp311-cp311-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for kanoniv_agent_auth-0.1.0-cp311-cp311-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 fdbb37442f1559dd8ba7aa596719ae7afef41bd8a3b5131aa33cf8a5ec564940
MD5 b69a7af7fba712e447d39ee91531fef9
BLAKE2b-256 3ee83b524160d862fbb9a37657941ebae45eb6bfe0afd94a3af453ba8b9b9dd8

See more details on using hashes here.

File details

Details for the file kanoniv_agent_auth-0.1.0-cp311-cp311-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl.

File metadata

File hashes

Hashes for kanoniv_agent_auth-0.1.0-cp311-cp311-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
Algorithm Hash digest
SHA256 af909ad0b24dcc16d8b14bcfd94943802161f21ae8820164cfa5acadcff6d025
MD5 353247b335f8cbbcc70f52231e1c1226
BLAKE2b-256 7cda1a421214fb419feb08c24f93bf70ee9ed2ddbe20e04c734b15bb20c7d25f

See more details on using hashes here.

File details

Details for the file kanoniv_agent_auth-0.1.0-cp310-cp310-win_amd64.whl.

File metadata

File hashes

Hashes for kanoniv_agent_auth-0.1.0-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 2359ac377e8047bba1e06bc20496588468ad021ac49986d1467773a687924466
MD5 9ae4d809dbe2ef4c2d0c91f23d4cc79f
BLAKE2b-256 390b1eb16f0be29b543ebb43c49f7162224e3205b3892822e58774701203b4d2

See more details on using hashes here.

File details

Details for the file kanoniv_agent_auth-0.1.0-cp310-cp310-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for kanoniv_agent_auth-0.1.0-cp310-cp310-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 0aac6db57f91048d131cb9e36abf404263b99d6233ab9551d65284b859ace2b3
MD5 93c9dbd5ed663ca2370357315327aecc
BLAKE2b-256 936aa048ca1179025ca5e021b85eab13784bdb78aa950dc55813ad893b0ceb13

See more details on using hashes here.

File details

Details for the file kanoniv_agent_auth-0.1.0-cp310-cp310-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl.

File metadata

File hashes

Hashes for kanoniv_agent_auth-0.1.0-cp310-cp310-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
Algorithm Hash digest
SHA256 20fe0b1a96d7eb6a24e47d0fed2a8e4fe6e80a74212d810e819a4c0ea002389c
MD5 34c4f85d7f506b4821fe4af0b4b76a89
BLAKE2b-256 ffd5050a0b6a434568185c28fe349b5d24dfdbded3b8d7f03cc0163dcdd849bb

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page