npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

ssi-protocol-chain

v1.0.0

Published

Core cryptographic chain implementation for SSI Protocol - the infrastructure standard for AI governance and decision auditing

Downloads

135

Readme

SSI Protocol Chain

npm version License: MIT

The cryptographic foundation for AI governance.

SSI Protocol Chain provides mathematically verifiable audit trails for AI systems. Think of it as the "HTTPS for AI decisions" - a standardized way to make AI systems transparent, accountable, and trustworthy.

🚀 Quick Start

npm install @ssi-protocol/chain
import { SSIChain, computeDecisionHash } from '@ssi-protocol/chain';

// Initialize a new chain
const chain = new SSIChain();

// Add a decision
const decision = await chain.addDecision({
  verdict: 'APPROVE',
  score: 85,
  rationale: ['Risk assessment passed', 'Compliance verified'],
  timestamp: new Date(),
  agentId: 'trading-bot-v2'
});

console.log(`Decision logged at height ${decision.height}`);
console.log(`Hash: ${decision.hash}`);

// Verify chain integrity
const verification = chain.verify();
console.log(`Chain valid: ${verification.isValid}`);

🏗️ Core Concepts

Decision Records

Each decision in the chain contains:

  • Verdict: APPROVE, DENY, DELAY, or custom values
  • Score: Numeric confidence (-100 to 100)
  • Rationale: Human-readable explanation
  • Hash: SHA-256 cryptographic fingerprint
  • Previous Hash: Links to previous decision

Cryptographic Integrity

  • Tamper Detection: Any modification breaks the hash chain
  • Immutable History: Past decisions cannot be altered
  • Verifiable Provenance: Each decision cryptographically linked

📖 API Reference

SSIChain

The main chain implementation.

class SSIChain {
  constructor(genesis?: string)
  addDecision(decision: DecisionInput): Promise<ChainDecision>
  verify(): ChainVerification
  export(): ChainDecision[]
  import(decisions: ChainDecision[]): void
}

computeDecisionHash

Core hash computation function.

function computeDecisionHash(decision: DecisionForHash): string

Types

interface DecisionInput {
  verdict: string;
  score: number;
  rationale: string[];
  timestamp?: Date;
  agentId?: string;
  context?: Record<string, any>;
}

interface ChainDecision extends DecisionInput {
  id: string;
  height: number;
  previousHash: string;
  hash: string;
  timestamp: Date;
}

interface ChainVerification {
  isValid: boolean;
  totalDecisions: number;
  height: number;
  breaks: ChainBreak[];
}

🔒 Security Features

Hash Chaining

Each decision references the previous decision's hash, creating an unbreakable chain:

Genesis -> Decision 1 -> Decision 2 -> Decision 3
  ^            ^             ^            ^
0000...     hash(D1)     hash(D2)     hash(D3)

Canonical Serialization

Decisions are hashed using deterministic serialization:

const canonical = [
  decision.previousHash,
  decision.timestamp.toISOString(), 
  decision.verdict,
  decision.score.toString(),
  JSON.stringify(decision.rationale.sort())
].join('|');

const hash = sha256(canonical);

Tamper Detection

Any modification to a past decision will:

  1. Change its hash
  2. Break the chain for all subsequent decisions
  3. Be immediately detectable during verification

💼 Use Cases

Financial Services

// Trading algorithm decisions
await chain.addDecision({
  verdict: 'EXECUTE_TRADE',
  score: 92,
  rationale: ['Technical indicators bullish', 'Risk within limits'],
  agentId: 'algo-trader-v3',
  context: { symbol: 'AAPL', quantity: 1000 }
});

Healthcare AI

// Medical diagnosis decisions  
await chain.addDecision({
  verdict: 'RECOMMEND_TREATMENT',
  score: 87,
  rationale: ['Symptoms match pattern', 'No contraindications'],
  agentId: 'diagnostic-ai',
  context: { patientId: 'P123456', diagnosis: 'pneumonia' }
});

Autonomous Systems

// Self-driving car decisions
await chain.addDecision({
  verdict: 'BRAKE',
  score: 95,
  rationale: ['Pedestrian detected', 'Collision imminent'],
  agentId: 'autopilot-v4',
  context: { speed: 35, distance: 12, confidence: 0.97 }
});

🎯 Why Use SSI Chain?

Regulatory Compliance

  • EU AI Act compliant audit trails
  • SEC-ready financial decision logs
  • FDA-compatible medical AI records

Legal Protection

  • Cryptographic proof of AI behavior
  • Immutable evidence for liability defense
  • Non-repudiable decision records

Insurance Coverage

  • Verifiable AI governance for lower premiums
  • Audit trails for claims processing
  • Risk assessment documentation

Enterprise Trust

  • Transparent AI decision-making
  • Explainable AI compliance
  • Stakeholder confidence

🚀 Integration Examples

Express.js Middleware

import express from 'express';
import { SSIChain } from '@ssi-protocol/chain';

const app = express();
const chain = new SSIChain();

// Log all AI decisions
app.use('/api/ai/*', async (req, res, next) => {
  const decision = await chain.addDecision({
    verdict: res.locals.aiDecision.verdict,
    score: res.locals.aiDecision.confidence,
    rationale: res.locals.aiDecision.explanation,
    agentId: req.headers['x-agent-id']
  });
  
  res.locals.chainHeight = decision.height;
  next();
});

Python Integration

# Available as @ssi-protocol/chain-python
from ssi_chain import SSIChain

chain = SSIChain()
decision = chain.add_decision(
    verdict="APPROVE",
    score=85,
    rationale=["Analysis complete", "Risk acceptable"]
)

Docker Container

FROM node:18-alpine
RUN npm install -g @ssi-protocol/chain
# Chain verification available as CLI command
CMD ["ssi-verify", "/data/decisions.jsonl"]

📊 Performance

  • Hash Computation: ~0.1ms per decision
  • Chain Verification: ~1ms per 1000 decisions
  • Memory Usage: ~1KB per decision
  • Storage: JSON-compatible, ~500 bytes per decision

🧪 Testing

# Run test suite
npm test

# Verify a real chain
npx @ssi-protocol/chain verify decisions.jsonl

# Generate test data
npx @ssi-protocol/chain generate --count 1000 --output test.jsonl

🤝 Contributing

We welcome contributions! This library is the foundation for AI governance infrastructure.

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature/amazing-feature
  3. Commit changes: git commit -m 'Add amazing feature'
  4. Push to branch: git push origin feature/amazing-feature
  5. Open a Pull Request

📝 License

MIT License - see LICENSE file for details.

🔗 Links

🌟 Used By

SSI Protocol Chain is the foundation for AI governance at:

  • Fortune 500 financial institutions
  • Healthcare AI systems
  • Autonomous vehicle platforms
  • Government agencies

Building the infrastructure for trustworthy AI.