Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 23 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<h1 align="center">json-trail</h1>
<h1 align="center">json-record</h1>

<p align="center">
<img src="https://github.com/cmyers/json-trail/actions/workflows/ci.yml/badge.svg?branch=main" alt="CI" />
<img src="https://img.shields.io/npm/v/json-trail" alt="npm version" />
<img src="https://github.com/cmyers/json-record/actions/workflows/ci.yml/badge.svg?branch=main" alt="CI" />
<img src="https://img.shields.io/npm/v/json-record" alt="npm version" />
<img src="https://img.shields.io/badge/dependencies-0-brightgreen" alt="dependencies" />
<img src="https://img.shields.io/badge/types-TypeScript-blue" alt="types" />
<img src="https://img.shields.io/github/license/cmyers/json-trail" alt="license" />
<img src="https://img.shields.io/github/license/cmyers/json-record" alt="license" />
</p>

<h3 align="center">
Expand All @@ -14,11 +14,11 @@

---

json-trail gives you **chronological integrity**: a guarantee that a sequence of blocks has not been altered, reordered, or truncated. It does not enforce authenticity or authorship; it simply ensures the history is intact.
json-record gives you **chronological integrity**: a guarantee that a sequence of blocks has not been altered, reordered, or truncated. It does not enforce authenticity or authorship; it simply ensures the history is intact.

---

## Why json-trail?
## Why json-record?

Most applications do not need a blockchain, or consensus protocol.
They just need a simple, deterministic way to ensure that:
Expand All @@ -27,7 +27,7 @@ They just need a simple, deterministic way to ensure that:
- nothing was removed
- nothing was rewritten

json-trail gives you that primitive, nothing more and nothing less.
json-record gives you that primitive, nothing more and nothing less.

It is ideal for:

Expand All @@ -52,7 +52,7 @@ It is ideal for:

## Environment Support

json-trail runs anywhere WebCrypto is available:
json-record runs anywhere WebCrypto is available:

- Node.js 18+ (global crypto.subtle)
- Browsers
Expand All @@ -66,9 +66,9 @@ A pure, deterministic, in-memory primitive.

---

## What json-trail guarantees
## What json-record guarantees

json-trail provides **tamper-evident ordering**:
json-record provides **tamper-evident ordering**:

- A block's payload cannot be changed without detection
- A block's header cannot be changed without detection
Expand All @@ -79,9 +79,9 @@ This is the same integrity model used by Git commit chains and linear Merkle-sty

---

## What json-trail does not guarantee
## What json-record does not guarantee

json-trail does not provide:
json-record does not provide:

- authenticity
- authorship
Expand All @@ -91,7 +91,7 @@ json-trail does not provide:

If you need to prove who created the data, seal the payload with **json-seal** before storing it in the trail.

json-trail stays intentionally minimal.
json-record stays intentionally minimal.

---

Expand All @@ -100,7 +100,7 @@ json-trail stays intentionally minimal.
### Creating a block

```ts
import { createBlock } from "json-trail";
import { createBlock } from "json-record";

const payload = new TextEncoder().encode("hello world");

Expand All @@ -113,7 +113,7 @@ const block1 = await createBlock(payload, block0);
### Verifying a block

```ts
import { verifyBlock } from "json-trail";
import { verifyBlock } from "json-record";

const ok = await verifyBlock(block1);
console.log(ok); // true
Expand All @@ -124,7 +124,7 @@ console.log(ok); // true
### Verifying a chain

```ts
import { verifyChain } from "json-trail";
import { verifyChain } from "json-record";

const chain = [block0, block1];
const ok = await verifyChain(chain);
Expand All @@ -139,7 +139,7 @@ If you want to prove where the data came from, seal the payload before putting i

```ts
import { generateKeyPair, signPayload } from "json-seal";
import { createBlock } from "json-trail";
import { createBlock } from "json-record";

const { privateKey, publicKey } = await generateKeyPair();

Expand All @@ -153,15 +153,15 @@ const block = await createBlock(
This gives you:

- authenticity of the payload (json-seal)
- chronological integrity of the chain (json-trail)
- chronological integrity of the chain (json-record)

A clean, layered integrity model.

---

## Storage

json-trail is an in-memory primitive.
json-record is an in-memory primitive.
For persistence, serialize blocks however you like.

A recommended format:
Expand All @@ -173,14 +173,14 @@ A recommended format:
}
```

json-trail does not define a storage format.
json-record does not define a storage format.
You choose how to store, sync, or replicate the chain.

---

## Design Philosophy

json-trail is intentionally small:
json-record is intentionally small:

- no I/O
- no storage format
Expand All @@ -195,15 +195,15 @@ You build the policies on top.

## Prior Art

json-trail builds on a long lineage of cryptographic integrity primitives:
json-record builds on a long lineage of cryptographic integrity primitives:

- Git commit chains
- Merkle-style hash chains
- Blockchain data structures (without consensus or networking)
- Certificate Transparency logs
- Secure audit log research

json-trail distills these ideas into a tiny, deterministic, dependency-free primitive designed for local-first apps, PWAs, and in-memory trails. It offers integrity without the complexity.
json-record distills these ideas into a tiny, deterministic, dependency-free primitive designed for local-first apps, PWAs, and in-memory trails. It offers integrity without the complexity.

---

Expand Down
16 changes: 8 additions & 8 deletions docs/api.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

<head>
<meta charset="UTF-8" />
<title>json-trail - API</title>
<title>json-record - API</title>
<link rel="stylesheet" href="style.css" />
</head>

Expand All @@ -13,7 +13,7 @@
<h1>API Reference</h1>

<p>
json-trail exposes a minimal API for creating hash-linked blocks and
json-record exposes a minimal API for creating hash-linked blocks and
verifying their integrity. All operations use deterministic SHA-256 hashing and return plain data structures
containing Uint8Array fields.
</p>
Expand All @@ -27,7 +27,7 @@ <h2>createBlock(payload, prevBlock)</h2>
</p>

<h3>Import</h3>
<pre><code>import { createBlock } from "json-trail";
<pre><code>import { createBlock } from "json-record";
</code></pre>

<h3>Usage</h3>
Expand Down Expand Up @@ -64,7 +64,7 @@ <h2>verifyBlock(block)</h2>
</p>

<h3>Import</h3>
<pre><code>import { verifyBlock } from "json-trail";
<pre><code>import { verifyBlock } from "json-record";
</code></pre>

<h3>Usage</h3>
Expand All @@ -86,7 +86,7 @@ <h2>verifyChain(blocks)</h2>
</p>

<h3>Import</h3>
<pre><code>import { verifyChain } from "json-trail";
<pre><code>import { verifyChain } from "json-record";
</code></pre>

<h3>Usage</h3>
Expand All @@ -102,12 +102,12 @@ <h3>Returns</h3>
<a href="api.html">API</a>
<a href="examples.html">Examples</a>
<a href="integrity-model.html">Integrity Model</a>
<a href="seal-and-trail.html">Using json-seal with json-trail</a>
<a href="seal-and-trail.html">Using json-seal with json-record</a>
</nav>

<p class="external-links">
<a href="https://github.com/cmyers/json-trail">GitHub</a> ·
<a href="https://www.npmjs.com/package/json-trail">npm</a>
<a href="https://github.com/cmyers/json-record">GitHub</a> ·
<a href="https://www.npmjs.com/package/json-record">npm</a>
</p>

</main>
Expand Down
10 changes: 5 additions & 5 deletions docs/examples.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

<head>
<meta charset="UTF-8" />
<title>json-trail - Examples</title>
<title>json-record - Examples</title>
<link rel="stylesheet" href="style.css" />
</head>

Expand All @@ -14,7 +14,7 @@ <h1>Examples</h1>

<h2>Basic usage</h2>

<pre><code>import { createBlock, verifyBlock, verifyChain } from "json-trail";
<pre><code>import { createBlock, verifyBlock, verifyChain } from "json-record";

const enc = new TextEncoder();
const payload = enc.encode("hello world");
Expand All @@ -40,12 +40,12 @@ <h2>Tampering detection</h2>
<a href="api.html">API</a>
<a href="examples.html">Examples</a>
<a href="integrity-model.html">Integrity Model</a>
<a href="seal-and-trail.html">Using json-seal with json-trail</a>
<a href="seal-and-trail.html">Using json-seal with json-record</a>
</nav>

<p class="external-links">
<a href="https://github.com/cmyers/json-trail">GitHub</a> ·
<a href="https://www.npmjs.com/package/json-trail">npm</a>
<a href="https://github.com/cmyers/json-record">GitHub</a> ·
<a href="https://www.npmjs.com/package/json-record">npm</a>
</p>

</main>
Expand Down
16 changes: 8 additions & 8 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,30 @@

<head>
<meta charset="UTF-8" />
<title>json-trail</title>
<title>json-record</title>
<link rel="stylesheet" href="style.css" />
</head>

<body>
<main>

<h1>json-trail</h1>
<h1>json-record</h1>
<p class="subtitle">
Tamper-evident, hash-linked blocks for apps. Zero dependencies.
</p>

<p>
json-trail is a tiny library for creating hash-linked blocks that detect
json-record is a tiny library for creating hash-linked blocks that detect
any modification to payloads or history. It provides chronological
integrity without keys, signatures, or complex state.
</p>

<h2>Why json-trail exists</h2>
<h2>Why json-record exists</h2>

<p>
Local-first apps store data on the device and sync when possible. Without
a server acting as the source of truth, you still need a way to know
whether your local history has been tampered with. json-trail provides a
whether your local history has been tampered with. json-record provides a
minimal, deterministic, tamper-evident structure for that purpose.
</p>

Expand All @@ -44,12 +44,12 @@ <h2>Features</h2>
<a href="api.html">API</a>
<a href="examples.html">Examples</a>
<a href="integrity-model.html">Integrity Model</a>
<a href="seal-and-trail.html">Using json-seal with json-trail</a>
<a href="seal-and-trail.html">Using json-seal with json-record</a>
</nav>

<p class="external-links">
<a href="https://github.com/cmyers/json-trail">GitHub</a> ·
<a href="https://www.npmjs.com/package/json-trail">npm</a>
<a href="https://github.com/cmyers/json-record">GitHub</a> ·
<a href="https://www.npmjs.com/package/json-record">npm</a>
</p>

</main>
Expand Down
10 changes: 5 additions & 5 deletions docs/integrity-model.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

<head>
<meta charset="UTF-8" />
<title>json-trail - Integrity Model</title>
<title>json-record - Integrity Model</title>
<link rel="stylesheet" href="style.css" />
</head>

Expand All @@ -13,7 +13,7 @@
<h1>Integrity Model</h1>

<p>
json-trail uses a simple hashing model to detect tampering.
json-record uses a simple hashing model to detect tampering.
</p>

<h2>Block structure</h2>
Expand Down Expand Up @@ -41,12 +41,12 @@ <h2>Chain validity</h2>
<a href="api.html">API</a>
<a href="examples.html">Examples</a>
<a href="integrity-model.html">Integrity Model</a>
<a href="seal-and-trail.html">Using json-seal with json-trail</a>
<a href="seal-and-trail.html">Using json-seal with json-record</a>
</nav>

<p class="external-links">
<a href="https://github.com/cmyers/json-trail">GitHub</a> ·
<a href="https://www.npmjs.com/package/json-trail">npm</a>
<a href="https://github.com/cmyers/json-record">GitHub</a> ·
<a href="https://www.npmjs.com/package/json-record">npm</a>
</p>

</main>
Expand Down
12 changes: 6 additions & 6 deletions docs/seal-and-trail.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@

<head>
<meta charset="UTF-8" />
<title>json-seal + json-trail</title>
<title>json-seal + json-record</title>
<link rel="stylesheet" href="style.css" />
</head>

<body>
<main>

<h1>json-seal + json-trail</h1>
<h1>json-seal + json-record</h1>

<p>
json-seal provides authenticity. json-trail provides chronological integrity.
json-seal provides authenticity. json-record provides chronological integrity.
Together, they form a signed, tamper-evident, hash-linked log entry.
</p>

Expand All @@ -24,7 +24,7 @@ <h1>json-seal + json-trail</h1>
<h2>Example</h2>

<pre><code>import { generateKeyPair, signPayload, canonicalize } from "json-seal";
import { createBlock } from "json-trail";
import { createBlock } from "json-record";

const { privateKey, publicKey } = await generateKeyPair();

Expand All @@ -39,7 +39,7 @@ <h2>Example</h2>
Using <code>canonicalize</code> ensures that the bytes passed into
<code>createBlock</code> are deterministic. json-seal produces a stable,
canonical representation of the sealed envelope, so hashing it with
json-trail yields consistent results across platforms and runtimes.
json-record yields consistent results across platforms and runtimes.
</p>

<h2>Verification flow</h2>
Expand All @@ -54,7 +54,7 @@ <h2>Verification flow</h2>
<a href="api.html">API</a>
<a href="examples.html">Examples</a>
<a href="integrity-model.html">Integrity Model</a>
<a href="seal-and-trail.html">Using json-seal with json-trail</a>
<a href="seal-and-trail.html">Using json-seal with json-record</a>
</nav>

</main>
Expand Down
Loading