Skip to main content

Create and verify workflows

Creation hashes each source block independently and writes raw 32-byte digests to a sink. Verification must use a seed_hash and, when available, a source size obtained from a trusted upper-layer protocol. A structurally valid seed alone is not proof of publisher intent.

import {createSeed, verifySeed, Digest} from 'masterseed';

const source = (async function* () { yield new TextEncoder().encode('hello'); })();
const seedBytes: Uint8Array[] = [];
const info = await createSeed(source, {write: async (digest) => { seedBytes.push(digest.slice()); }});
const expected = Digest.fromHex(info.seedHashHex); // obtain this from the trusted protocol in production
const verified = await verifySeed(seedBytes, expected);
console.log(verified.blockCount, verified.seedHashHex);

ByteSource iterables are consumed once. Create a new iterable (or reopen a file adapter) for every subsequent pass.