Skip to content

Create an Evidence Bundle

Bundle multiple signed interaction records into a portable evidence package that can travel across transports.

Install

pnpm add @peac/protocol @peac/crypto @peac/schema

Issue and bundle records

import { issueWire02 } from '@peac/protocol'
import { generateKeypair } from '@peac/crypto'
import { computeReceiptRef } from '@peac/schema'

const { privateKey } = await generateKeypair()

// Issue records for different interaction types
const access = await issueWire02({
  iss: 'https://api.example.com',
  kind: 'evidence',
  type: 'org.peacprotocol/access',
  pillars: ['access'],
  privateKey,
  kid: 'peac-2026-03',
})

const attribution = await issueWire02({
  iss: 'https://api.example.com',
  kind: 'evidence',
  type: 'org.peacprotocol/attribution',
  pillars: ['attribution'],
  privateKey,
  kid: 'peac-2026-03',
})

// Bundle as a portable evidence package
const bundle = {
  version: '0.2',
  carriers: [
    { receipt_jws: access.jws, receipt_ref: computeReceiptRef(access.jws) },
    { receipt_jws: attribution.jws, receipt_ref: computeReceiptRef(attribution.jws) },
  ],
}

Each receipt_ref is a SHA-256 hash of the compact JWS, enabling integrity verification without parsing the full receipt.