Remove Node.js hooks, require ots CLI only
- Delete hooks/post-commit-node (local proofs only, no attestation) - Delete hooks/pre-commit-node (no upgrade support) - Update hooks/install.sh to require ots CLI (no fallback) - Update documentation with clear ots CLI requirement - Add prominent warnings about Node.js limitations Rationale: The @opentimestamps/ots Node.js package only creates local proofs without calendar submission or Bitcoin attestation. For tamper-evident timestamps, ots CLI is the only complete implementation. No partial/fallback implementations.
This commit is contained in:
parent
b1e305d831
commit
b4e2eb3c12
6 changed files with 203 additions and 357 deletions
91
AGENTS.md
91
AGENTS.md
|
|
@ -2,85 +2,88 @@
|
||||||
|
|
||||||
Quick reference for AI agents installing OpenTimestamp hooks.
|
Quick reference for AI agents installing OpenTimestamp hooks.
|
||||||
|
|
||||||
## When to Use
|
## ⚠️ Hard Requirement
|
||||||
|
|
||||||
Use this skill when the user wants to:
|
**`ots` CLI must be installed.** No fallback available.
|
||||||
- Add tamper-evident timestamps to git commits
|
|
||||||
- Create cryptographic proof of commit history
|
|
||||||
- Anchor commits to Bitcoin blockchain via OpenTimestamp
|
|
||||||
|
|
||||||
## Installation (Auto-Detect)
|
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# 1. Install prerequisites (ots CLI recommended)
|
|
||||||
pipx install opentimestamps-client
|
pipx install opentimestamps-client
|
||||||
|
```
|
||||||
|
|
||||||
# 2. Install hooks (auto-detects available tools)
|
The Node.js `@opentimestamps/ots` package is **not a valid alternative** - it only creates local proofs without calendar submission or Bitcoin attestation.
|
||||||
|
|
||||||
|
## Installation
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# 1. Verify/install prerequisites
|
||||||
|
if ! command -v ots &> /dev/null; then
|
||||||
|
pipx install opentimestamps-client
|
||||||
|
fi
|
||||||
|
|
||||||
|
# 2. Install hooks
|
||||||
./hooks/install.sh .
|
./hooks/install.sh .
|
||||||
|
|
||||||
# 3. Commit proofs to repository
|
# 3. Commit proofs
|
||||||
git add .ots/ .gitignore
|
git add .ots/ .gitignore
|
||||||
git commit -m "Add OpenTimestamp proofs for commit history"
|
git commit -m "Add OpenTimestamp proofs for commit history"
|
||||||
```
|
```
|
||||||
|
|
||||||
## Installation Modes
|
|
||||||
|
|
||||||
The installer auto-detects and installs matching hooks:
|
|
||||||
|
|
||||||
| Detected | Hooks Installed | Attestation |
|
|
||||||
|----------|----------------|-------------|
|
|
||||||
| `ots` CLI | `post-commit-ots`, `pre-commit-ots` | Full Bitcoin |
|
|
||||||
| `@opentimestamps/ots` (node) | `post-commit-node`, `pre-commit-node` | Local only |
|
|
||||||
|
|
||||||
**Recommendation:** Always prefer ots CLI for production use.
|
|
||||||
|
|
||||||
## Manual Installation
|
## Manual Installation
|
||||||
|
|
||||||
### ots CLI Mode
|
|
||||||
```bash
|
```bash
|
||||||
cp hooks/post-commit-ots .git/hooks/
|
cp hooks/post-commit-ots .git/hooks/post-commit
|
||||||
cp hooks/pre-commit-ots .git/hooks/
|
cp hooks/pre-commit-ots .git/hooks/pre-commit
|
||||||
chmod +x .git/hooks/*
|
chmod +x .git/hooks/post-commit .git/hooks/pre-commit
|
||||||
```
|
```
|
||||||
|
|
||||||
### Node.js Mode
|
**.gitignore:**
|
||||||
```bash
|
```
|
||||||
cp hooks/post-commit-node .git/hooks/
|
.ots/.attestation-cache
|
||||||
cp hooks/pre-commit-node .git/hooks/
|
|
||||||
chmod +x .git/hooks/*
|
|
||||||
npm install @opentimestamps/ots # If not already installed
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## Key Files
|
## Key Files
|
||||||
|
|
||||||
| File | Purpose | Version? |
|
| File | Purpose | Version? |
|
||||||
|------|---------|----------|
|
|------|---------|----------|
|
||||||
| `hooks/post-commit-ots` | Post-commit hook (ots CLI) | Yes |
|
| `hooks/post-commit-ots` | Post-commit hook | Yes |
|
||||||
| `hooks/pre-commit-ots` | Backfill hook (ots CLI) | Yes |
|
| `hooks/pre-commit-ots` | Backfill hook | Yes |
|
||||||
| `hooks/post-commit-node` | Post-commit hook (Node.js) | Yes |
|
| `hooks/install.sh` | Installer (checks ots) | Yes |
|
||||||
| `hooks/pre-commit-node` | Backfill hook (Node.js) | Yes |
|
|
||||||
| `hooks/install.sh` | Auto-detect installer | Yes |
|
|
||||||
| `.ots/*.ots` | Individual proofs | Yes |
|
| `.ots/*.ots` | Individual proofs | Yes |
|
||||||
| `.ots/proof.ots` | Latest proof reference | Yes |
|
| `.ots/proof.ots` | Latest proof reference | Yes |
|
||||||
| `.ots/commit-chain.txt` | Commit chain | Yes |
|
| `.ots/commit-chain.txt` | Commit chain | Yes |
|
||||||
| `.ots/.attestation-cache` | Local cache | No |
|
| `.ots/.attestation-cache` | Local cache | No |
|
||||||
| `node_modules/` | Node dependencies (if used) | No |
|
|
||||||
|
|
||||||
## Verification
|
## Verification
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# Check if proof is attested
|
# Check attestation status
|
||||||
ots info .ots/<commit-hash>.ots | grep -c "PendingAttestation"
|
ots info .ots/<commit-hash>.ots | grep -c "PendingAttestation"
|
||||||
# 0 = attested, >0 = pending
|
# 0 = attested, >0 = pending
|
||||||
|
|
||||||
# Verify proof
|
# Verify proof
|
||||||
ots verify .ots/<commit-hash>.ots
|
ots verify .ots/<commit-hash>.ots
|
||||||
|
|
||||||
|
# Upgrade pending proofs
|
||||||
|
ots upgrade .ots/<commit-hash>.ots
|
||||||
```
|
```
|
||||||
|
|
||||||
## Notes
|
## Important Notes
|
||||||
|
|
||||||
- Proofs take ~10 min to become Bitcoin-attested
|
- **No Node.js fallback** - ots CLI is mandatory
|
||||||
- Cache avoids redundant calendar calls (1-hour validity)
|
- **Attestation time:** ~10 min (Bitcoin confirmation)
|
||||||
- Pre-commit backfill adds ~10-15s to commit time
|
- **Cache validity:** 1 hour, re-checks pending after 10 min
|
||||||
- Node.js version creates local proofs only (no calendar submission)
|
- **Commit overhead:** ~10-15s after initial backfill
|
||||||
- Safe to commit `.ots/` directory (binary proofs are ~500-900B each)
|
- **Proof size:** ~500-900 bytes each
|
||||||
|
- **Safe to commit:** Yes, `.ots/` directory should be versioned
|
||||||
|
|
||||||
|
## Why ots CLI is Required
|
||||||
|
|
||||||
|
| Feature | ots CLI | Node.js Package |
|
||||||
|
|---------|---------|-----------------|
|
||||||
|
| Calendar submission | ✓ | ✗ |
|
||||||
|
| Bitcoin attestation | ✓ | ✗ |
|
||||||
|
| Proof upgrade | ✓ | ✗ |
|
||||||
|
| Verification | ✓ | ✗ |
|
||||||
|
| Local proofs | ✓ | ✓ |
|
||||||
|
|
||||||
|
The Node.js package only creates self-attested local proofs with no third-party verification. For tamper-evident timestamps anchored to Bitcoin, ots CLI is the only complete implementation.
|
||||||
|
|
|
||||||
122
README.md
122
README.md
|
|
@ -1,24 +1,25 @@
|
||||||
# Git OpenTimestamp Hook
|
# Git OpenTimestamp Hook
|
||||||
|
|
||||||
Automatically generate and manage [OpenTimestamp](https://opentimestamps.org/) proofs for git commits.
|
Automatically generate [OpenTimestamp](https://opentimestamps.org/) proofs for git commits with full Bitcoin attestation.
|
||||||
|
|
||||||
## What It Does
|
## ⚠️ Requirements
|
||||||
|
|
||||||
- **Post-commit hook**: Creates cryptographic proof for every commit
|
**Required:** `opentimestamps-client` (ots CLI)
|
||||||
- **Pre-commit backfill**: Upgrades historical proofs to Bitcoin-attested status
|
|
||||||
- **Proof chaining**: Links commits together for full history integrity
|
|
||||||
- **Smart caching**: Minimizes network calls after initial backfill
|
|
||||||
|
|
||||||
Proofs are stored in `.ots/` and can be versioned alongside your code for tamper-evident history.
|
```bash
|
||||||
|
pipx install opentimestamps-client
|
||||||
|
```
|
||||||
|
|
||||||
|
> **Note:** The Node.js `@opentimestamps/ots` package is **not supported** - it only creates local proofs without calendar submission or Bitcoin attestation. For tamper-evident timestamps, you must use the Python `opentimestamps-client`.
|
||||||
|
|
||||||
## Quick Install
|
## Quick Install
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# Clone or download this skill
|
# Clone this repository
|
||||||
git clone <repository-url>
|
git clone <repository-url>
|
||||||
cd git-ots-hook
|
cd git-ots-hook
|
||||||
|
|
||||||
# Install both hooks (auto-detects ots CLI or Node.js)
|
# Install hooks (requires ots CLI)
|
||||||
./hooks/install.sh /path/to/your/repo
|
./hooks/install.sh /path/to/your/repo
|
||||||
|
|
||||||
# Commit the proofs
|
# Commit the proofs
|
||||||
|
|
@ -27,102 +28,85 @@ git add .ots/
|
||||||
git commit -m "Add OpenTimestamp proofs"
|
git commit -m "Add OpenTimestamp proofs"
|
||||||
```
|
```
|
||||||
|
|
||||||
That's it! The hooks are now installed and will automatically timestamp every commit.
|
That's it! Every commit will now be timestamped and anchored to Bitcoin.
|
||||||
|
|
||||||
## Manual Installation
|
## Manual Installation
|
||||||
|
|
||||||
### For ots CLI (Recommended)
|
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
|
# Copy hooks
|
||||||
cp hooks/post-commit-ots .git/hooks/post-commit
|
cp hooks/post-commit-ots .git/hooks/post-commit
|
||||||
cp hooks/pre-commit-ots .git/hooks/pre-commit
|
cp hooks/pre-commit-ots .git/hooks/pre-commit
|
||||||
chmod +x .git/hooks/post-commit .git/hooks/pre-commit
|
chmod +x .git/hooks/post-commit .git/hooks/pre-commit
|
||||||
|
|
||||||
|
# Setup .gitignore
|
||||||
|
echo ".ots/.attestation-cache" >> .gitignore
|
||||||
```
|
```
|
||||||
|
|
||||||
### For Node.js (Local proofs only)
|
## What You Get
|
||||||
|
|
||||||
```bash
|
- **Automatic timestamping** - Every commit gets a cryptographic proof
|
||||||
cp hooks/post-commit-node .git/hooks/post-commit
|
- **Bitcoin attestation** - Proofs anchored to Bitcoin blockchain (~10 min)
|
||||||
cp hooks/pre-commit-node .git/hooks/pre-commit
|
- **Full history** - Backfill hook upgrades all historical commits
|
||||||
chmod +x .git/hooks/post-commit .git/hooks/pre-commit
|
- **Smart caching** - Minimal network overhead after initial setup
|
||||||
```
|
- **Tamper-evident** - Anyone can verify your commit history
|
||||||
|
|
||||||
### Setup .gitignore
|
|
||||||
|
|
||||||
```
|
|
||||||
.ots/.attestation-cache
|
|
||||||
node_modules/
|
|
||||||
```
|
|
||||||
|
|
||||||
### Commit Initial Proofs
|
|
||||||
|
|
||||||
```bash
|
|
||||||
git add .ots/
|
|
||||||
git commit -m "Add OpenTimestamp proofs"
|
|
||||||
```
|
|
||||||
|
|
||||||
## Prerequisites
|
|
||||||
|
|
||||||
Install the OpenTimestamp client:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
# Recommended: Python CLI
|
|
||||||
pipx install opentimestamps-client
|
|
||||||
|
|
||||||
# Alternative: Node.js package
|
|
||||||
npm install -g @opentimestamps/ots
|
|
||||||
```
|
|
||||||
|
|
||||||
Verify installation:
|
|
||||||
```bash
|
|
||||||
ots --version
|
|
||||||
```
|
|
||||||
|
|
||||||
## Generated Files
|
## Generated Files
|
||||||
|
|
||||||
```
|
```
|
||||||
repo/
|
repo/
|
||||||
├── .ots/
|
├── .ots/
|
||||||
│ ├── <commit-hash>.ots # Individual proof per commit
|
│ ├── <commit-hash>.ots # Individual proof (commit this)
|
||||||
│ ├── proof.ots # Latest commit proof
|
│ ├── proof.ots # Latest proof (commit this)
|
||||||
│ ├── prev-commit.txt # Previous commit reference
|
│ ├── prev-commit.txt # Chain link (commit this)
|
||||||
│ ├── commit-chain.txt # Full commit chain
|
│ ├── commit-chain.txt # Full chain (commit this)
|
||||||
│ └── .attestation-cache # Local cache (gitignore this)
|
│ └── .attestation-cache # Local cache (ignore this)
|
||||||
└── ...
|
└── ...
|
||||||
```
|
```
|
||||||
|
|
||||||
## Verification
|
## Verification
|
||||||
|
|
||||||
Verify a proof:
|
**Check a proof:**
|
||||||
|
```bash
|
||||||
|
ots info .ots/<commit-hash>.ots
|
||||||
|
```
|
||||||
|
|
||||||
|
**Verify attestation:**
|
||||||
```bash
|
```bash
|
||||||
ots verify .ots/<commit-hash>.ots
|
ots verify .ots/<commit-hash>.ots
|
||||||
```
|
```
|
||||||
|
|
||||||
Check attestation status:
|
**Upgrade pending proofs:**
|
||||||
```bash
|
```bash
|
||||||
./scripts/check-attestation.sh .ots/<commit-hash>.ots
|
ots upgrade .ots/<commit-hash>.ots
|
||||||
# Output: "attested" or "pending"
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## How It Works
|
## How It Works
|
||||||
|
|
||||||
1. **Commit created** → Post-commit hook runs
|
1. You make a git commit
|
||||||
2. **Proof generated** → `ots stamp` creates `.ots` file
|
2. Post-commit hook extracts commit hash
|
||||||
3. **Submitted to calendars** → 4+ remote calendars receive hash
|
3. Hash submitted to 4+ remote calendar servers
|
||||||
4. **Bitcoin anchoring** → Calendars batch and anchor to Bitcoin (~10 min)
|
4. Calendars aggregate and anchor to Bitcoin
|
||||||
5. **Attestation** → Proof becomes fully verifiable against Bitcoin blockchain
|
5. After ~10 min: proof becomes Bitcoin-attested
|
||||||
|
6. Pre-commit hook upgrades old proofs before new commits
|
||||||
|
|
||||||
## Performance
|
## Performance
|
||||||
|
|
||||||
- **First backfill**: 30-60s (scans history, contacts calendars)
|
- **First backfill:** 30-60s (full history scan)
|
||||||
- **Subsequent commits**: 10-15s (cached status skips redundant calls)
|
- **Normal commits:** 10-15s (cached, minimal network)
|
||||||
- **Cache**: 1-hour validity, 10-min recheck for pending proofs
|
- **Attestation:** ~10 min (Bitcoin block time)
|
||||||
|
|
||||||
## License
|
## Uninstall
|
||||||
|
|
||||||
MIT
|
```bash
|
||||||
|
rm .git/hooks/post-commit .git/hooks/pre-commit
|
||||||
|
```
|
||||||
|
|
||||||
## Links
|
## Links
|
||||||
|
|
||||||
- [OpenTimestamp](https://opentimestamps.org/)
|
- [OpenTimestamp](https://opentimestamps.org/)
|
||||||
- [ots Client](https://github.com/opentimestamps/opentimestamps-client)
|
- [opentimestamps-client](https://github.com/opentimestamps/opentimestamps-client)
|
||||||
|
- [Bitcoin anchoring explained](https://petertodd.org/2016/opentimestamps-announcement)
|
||||||
|
|
||||||
|
## License
|
||||||
|
|
||||||
|
MIT
|
||||||
|
|
|
||||||
116
SKILL.md
116
SKILL.md
|
|
@ -1,16 +1,40 @@
|
||||||
---
|
---
|
||||||
name: git-ots-hook
|
name: git-ots-hook
|
||||||
description: Install and manage OpenTimestamp git hooks that generate cryptographic proof for every commit. Use when you need to add tamper-evident timestamps to git commits using the OpenTimestamp protocol. Auto-detects ots CLI (recommended) or Node.js package.
|
description: Install and manage OpenTimestamp git hooks that generate cryptographic proof for every commit. Requires opentimestamps-client (ots CLI) for full Bitcoin attestation.
|
||||||
---
|
---
|
||||||
|
|
||||||
# Git OpenTimestamp Hook
|
# Git OpenTimestamp Hook
|
||||||
|
|
||||||
Automatically generates OpenTimestamp proofs for git commits via git hooks.
|
Automatically generates OpenTimestamp proofs for git commits via git hooks.
|
||||||
|
|
||||||
|
## ⚠️ Prerequisites (Required)
|
||||||
|
|
||||||
|
**You must have `ots` CLI installed:**
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Recommended (isolated install)
|
||||||
|
pipx install opentimestamps-client
|
||||||
|
|
||||||
|
# Or with pip
|
||||||
|
pip install opentimestamps-client
|
||||||
|
|
||||||
|
# Or from source
|
||||||
|
git clone https://github.com/opentimestamps/opentimestamps-client
|
||||||
|
cd opentimestamps-client && pip install .
|
||||||
|
```
|
||||||
|
|
||||||
|
**Verify installation:**
|
||||||
|
```bash
|
||||||
|
ots --version
|
||||||
|
# v0.7.2 or later
|
||||||
|
```
|
||||||
|
|
||||||
|
> **Why ots CLI is required:** The Node.js `@opentimestamps/ots` package only creates local proofs without calendar submission or Bitcoin attestation. For tamper-evident timestamps anchored to Bitcoin, the Python `opentimestamps-client` is the only complete implementation.
|
||||||
|
|
||||||
## Quick Start
|
## Quick Start
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# Install both hooks (auto-detects ots CLI or Node.js)
|
# Install both hooks (requires ots CLI)
|
||||||
./hooks/install.sh /path/to/repo
|
./hooks/install.sh /path/to/repo
|
||||||
|
|
||||||
# Or from repo root
|
# Or from repo root
|
||||||
|
|
@ -18,32 +42,18 @@ Automatically generates OpenTimestamp proofs for git commits via git hooks.
|
||||||
```
|
```
|
||||||
|
|
||||||
The installer will:
|
The installer will:
|
||||||
1. Detect available tools (ots CLI preferred, Node.js fallback)
|
1. Verify `ots` CLI is installed
|
||||||
2. Install matching hooks
|
2. Install post-commit and pre-commit hooks
|
||||||
3. Setup `.gitignore` (excludes cache + node_modules)
|
3. Setup `.gitignore` (excludes cache file)
|
||||||
4. Install `@opentimestamps/ots` locally if using Node.js mode
|
|
||||||
|
|
||||||
## What It Does
|
## What It Does
|
||||||
|
|
||||||
- **Auto-detects tools**: ots CLI (full Bitcoin attestation) or Node.js package (local proofs only)
|
|
||||||
- **Post-commit hook**: Generates `.ots/<commit-hash>.ots` for each new commit
|
- **Post-commit hook**: Generates `.ots/<commit-hash>.ots` for each new commit
|
||||||
- **Pre-commit backfill**: Upgrades historical proofs to attested status (ots CLI only)
|
- **Pre-commit backfill**: Upgrades historical proofs to Bitcoin-attested status
|
||||||
- Creates `.ots/proof.ots` (latest proof reference)
|
- Creates `.ots/proof.ots` (latest proof reference)
|
||||||
- Stores commit chain in `.ots/commit-chain.txt`
|
- Stores commit chain in `.ots/commit-chain.txt`
|
||||||
- Smart caching: Skips calendar calls for recently checked proofs
|
- Smart caching: Skips calendar calls for recently checked proofs
|
||||||
|
- Submits to 4+ remote calendar servers for Bitcoin anchoring
|
||||||
## Prerequisites
|
|
||||||
|
|
||||||
**Option 1: ots CLI (Recommended - Full Bitcoin attestation)**
|
|
||||||
```bash
|
|
||||||
pipx install opentimestamps-client
|
|
||||||
```
|
|
||||||
|
|
||||||
**Option 2: Node.js (Local proofs only)**
|
|
||||||
```bash
|
|
||||||
# Package will be installed locally by the installer
|
|
||||||
# Or globally: npm install -g @opentimestamps/ots
|
|
||||||
```
|
|
||||||
|
|
||||||
## Generated Files
|
## Generated Files
|
||||||
|
|
||||||
|
|
@ -58,32 +68,39 @@ repo/
|
||||||
└── ...
|
└── ...
|
||||||
```
|
```
|
||||||
|
|
||||||
## Manual Usage
|
## Manual Installation
|
||||||
|
|
||||||
**Install hooks (auto-detect):**
|
If you prefer manual setup:
|
||||||
```bash
|
|
||||||
./hooks/install.sh /path/to/repo
|
|
||||||
```
|
|
||||||
|
|
||||||
**Manual installation:**
|
|
||||||
```bash
|
```bash
|
||||||
# For ots CLI:
|
|
||||||
cp hooks/post-commit-ots .git/hooks/post-commit
|
cp hooks/post-commit-ots .git/hooks/post-commit
|
||||||
cp hooks/pre-commit-ots .git/hooks/pre-commit
|
cp hooks/pre-commit-ots .git/hooks/pre-commit
|
||||||
|
|
||||||
# For Node.js:
|
|
||||||
cp hooks/post-commit-node .git/hooks/post-commit
|
|
||||||
cp hooks/pre-commit-node .git/hooks/pre-commit
|
|
||||||
|
|
||||||
chmod +x .git/hooks/post-commit .git/hooks/pre-commit
|
chmod +x .git/hooks/post-commit .git/hooks/pre-commit
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Add to `.gitignore`:
|
||||||
|
```
|
||||||
|
.ots/.attestation-cache
|
||||||
|
```
|
||||||
|
|
||||||
|
## Manual Usage
|
||||||
|
|
||||||
**Check attestation status:**
|
**Check attestation status:**
|
||||||
```bash
|
```bash
|
||||||
ots info .ots/<commit-hash>.ots | grep -c "PendingAttestation"
|
ots info .ots/<commit-hash>.ots | grep -c "PendingAttestation"
|
||||||
# 0 = attested, >0 = pending
|
# 0 = attested, >0 = pending
|
||||||
```
|
```
|
||||||
|
|
||||||
|
**Verify a proof:**
|
||||||
|
```bash
|
||||||
|
ots verify .ots/<commit-hash>.ots
|
||||||
|
```
|
||||||
|
|
||||||
|
**Upgrade pending proofs:**
|
||||||
|
```bash
|
||||||
|
ots upgrade .ots/<commit-hash>.ots
|
||||||
|
```
|
||||||
|
|
||||||
## Notes
|
## Notes
|
||||||
|
|
||||||
### Versioning Proofs
|
### Versioning Proofs
|
||||||
|
|
@ -101,28 +118,39 @@ git commit -m "Add OpenTimestamp proofs"
|
||||||
|
|
||||||
**Ignore these:**
|
**Ignore these:**
|
||||||
- `.attestation-cache` - Local performance cache
|
- `.attestation-cache` - Local performance cache
|
||||||
- `node_modules/` - If using Node.js mode (auto-added by installer)
|
|
||||||
|
|
||||||
### Performance
|
### Performance
|
||||||
|
|
||||||
- **First backfill:** ~30-60s (scans history, contacts calendars)
|
- **First backfill:** ~30-60s (scans history, contacts calendars)
|
||||||
- **Subsequent commits:** ~10-15s (cached status skips redundant calls)
|
- **Subsequent commits:** ~10-15s (cached status skips redundant calls)
|
||||||
- **Cache:** 1-hour validity, 10-min recheck for pending proofs
|
- **Cache:** 1-hour validity, re-checks pending proofs after 10 min
|
||||||
|
- **Attestation time:** ~10 min (Bitcoin block confirmation)
|
||||||
|
|
||||||
### Modes
|
### How It Works
|
||||||
|
|
||||||
| Feature | ots CLI | Node.js |
|
1. **Commit created** → Post-commit hook runs
|
||||||
|---------|---------|---------|
|
2. **Hash generated** → SHA256 of commit hash
|
||||||
| Calendar submission | ✓ | ✗ |
|
3. **Submitted to calendars** → 4+ remote servers receive hash
|
||||||
| Bitcoin attestation | ✓ | ✗ |
|
4. **Bitcoin anchoring** → Calendars batch and anchor to Bitcoin
|
||||||
| Local proofs | ✓ | ✓ |
|
5. **Attestation** → `ots upgrade` downloads Bitcoin proof
|
||||||
| Upgrade support | ✓ | ✗ |
|
6. **Verification** → Anyone can verify against Bitcoin blockchain
|
||||||
| Speed | Fast | Fast |
|
|
||||||
|
|
||||||
**Recommendation:** Use ots CLI for production. Node.js for development/testing only.
|
### Calendar Servers
|
||||||
|
|
||||||
|
Default calendars used:
|
||||||
|
- `https://a.pool.opentimestamps.org`
|
||||||
|
- `https://b.pool.opentimestamps.org`
|
||||||
|
- `https://a.pool.eternitywall.com`
|
||||||
|
- `https://btc.calendar.catallaxy.com`
|
||||||
|
|
||||||
## Uninstall
|
## Uninstall
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
rm .git/hooks/post-commit .git/hooks/pre-commit
|
rm .git/hooks/post-commit .git/hooks/pre-commit
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Links
|
||||||
|
|
||||||
|
- [OpenTimestamp](https://opentimestamps.org/)
|
||||||
|
- [opentimestamps-client](https://github.com/opentimestamps/opentimestamps-client)
|
||||||
|
- [How OpenTimestamp works](https://petertodd.org/2016/opentimestamps-announcement)
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# Git OpenTimestamp Hooks Installer
|
# Git OpenTimestamp Hooks Installer
|
||||||
# Detects available tools and installs matching hooks
|
# Requires: opentimestamps-client (ots CLI)
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
|
|
@ -14,44 +14,35 @@ if ! git rev-parse --git-dir > /dev/null 2>&1; then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
HOOKS_DIR="$(git rev-parse --git-dir)/hooks"
|
# Check for ots CLI (required)
|
||||||
MODE=""
|
if ! command -v ots &> /dev/null; then
|
||||||
|
echo "Error: ots CLI not found" >&2
|
||||||
# Detect available tools
|
echo "" >&2
|
||||||
if command -v ots &> /dev/null; then
|
echo "OpenTimestamp client is required for full Bitcoin attestation." >&2
|
||||||
MODE="ots"
|
echo "Install with one of:" >&2
|
||||||
echo "Detected: ots CLI"
|
echo "" >&2
|
||||||
elif command -v node &> /dev/null && node -e "require('@opentimestamps/ots')" &> /dev/null 2>&1; then
|
echo " # Recommended (isolated install)" >&2
|
||||||
MODE="node"
|
echo " pipx install opentimestamps-client" >&2
|
||||||
echo "Detected: @opentimestamps/ots (Node.js)"
|
echo "" >&2
|
||||||
echo "Note: Node version creates local proofs only (no calendar submission)"
|
echo " # Or with pip" >&2
|
||||||
echo ""
|
echo " pip install opentimestamps-client" >&2
|
||||||
|
echo "" >&2
|
||||||
# Install node package locally if not already present
|
echo " # Or from source" >&2
|
||||||
if [ ! -d "node_modules/@opentimestamps" ]; then
|
echo " git clone https://github.com/opentimestamps/opentimestamps-client" >&2
|
||||||
echo "Installing @opentimestamps/ots locally..."
|
echo " cd opentimestamps-client && pip install ." >&2
|
||||||
npm install @opentimestamps/ots
|
echo "" >&2
|
||||||
echo "✓ Package installed"
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
echo "Error: Neither ots CLI nor @opentimestamps/ots found" >&2
|
|
||||||
echo "Install one of:" >&2
|
|
||||||
echo " pipx install opentimestamps-client (recommended)" >&2
|
|
||||||
echo " npm install @opentimestamps/ots (local proofs only)" >&2
|
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo ""
|
echo "✓ Detected: ots CLI ($(ots --version))"
|
||||||
echo "Installing $MODE hooks to: $HOOKS_DIR"
|
|
||||||
|
|
||||||
# Copy appropriate hooks
|
HOOKS_DIR="$(git rev-parse --git-dir)/hooks"
|
||||||
if [ "$MODE" = "ots" ]; then
|
|
||||||
cp "$SCRIPT_DIR/post-commit-ots" "$HOOKS_DIR/post-commit"
|
echo "Installing hooks to: $HOOKS_DIR"
|
||||||
cp "$SCRIPT_DIR/pre-commit-ots" "$HOOKS_DIR/pre-commit"
|
|
||||||
else
|
# Copy ots hooks
|
||||||
cp "$SCRIPT_DIR/post-commit-node" "$HOOKS_DIR/post-commit"
|
cp "$SCRIPT_DIR/post-commit-ots" "$HOOKS_DIR/post-commit"
|
||||||
cp "$SCRIPT_DIR/pre-commit-node" "$HOOKS_DIR/pre-commit"
|
cp "$SCRIPT_DIR/pre-commit-ots" "$HOOKS_DIR/pre-commit"
|
||||||
fi
|
|
||||||
|
|
||||||
chmod +x "$HOOKS_DIR/post-commit" "$HOOKS_DIR/pre-commit"
|
chmod +x "$HOOKS_DIR/post-commit" "$HOOKS_DIR/pre-commit"
|
||||||
|
|
||||||
|
|
@ -61,29 +52,18 @@ echo "✓ Pre-commit backfill hook installed"
|
||||||
# Setup .gitignore
|
# Setup .gitignore
|
||||||
GITIGNORE=".gitignore"
|
GITIGNORE=".gitignore"
|
||||||
if [ ! -f "$GITIGNORE" ]; then
|
if [ ! -f "$GITIGNORE" ]; then
|
||||||
cat > "$GITIGNORE" << 'EOF'
|
echo ".ots/.attestation-cache" > "$GITIGNORE"
|
||||||
.ots/.attestation-cache
|
|
||||||
node_modules/
|
|
||||||
EOF
|
|
||||||
echo "✓ Created .gitignore"
|
echo "✓ Created .gitignore"
|
||||||
elif ! grep -q ".ots/.attestation-cache" "$GITIGNORE"; then
|
elif ! grep -q ".ots/.attestation-cache" "$GITIGNORE"; then
|
||||||
echo ".ots/.attestation-cache" >> "$GITIGNORE"
|
echo ".ots/.attestation-cache" >> "$GITIGNORE"
|
||||||
if [ "$MODE" = "node" ] && ! grep -q "node_modules/" "$GITIGNORE"; then
|
|
||||||
echo "node_modules/" >> "$GITIGNORE"
|
|
||||||
fi
|
|
||||||
echo "✓ Updated .gitignore"
|
echo "✓ Updated .gitignore"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
echo "Mode: $MODE"
|
echo "Configuration:"
|
||||||
if [ "$MODE" = "ots" ]; then
|
echo " - Full Bitcoin attestation via remote calendars"
|
||||||
echo " - Full Bitcoin attestation via calendars"
|
echo " - Proofs submitted to 4+ calendar servers"
|
||||||
echo " - Proofs submitted to remote calendars"
|
echo " - Attestation available after ~10 min (Bitcoin confirmation)"
|
||||||
else
|
|
||||||
echo " - Local proofs only (no calendar submission)"
|
|
||||||
echo " - For full attestation, use: pipx install opentimestamps-client"
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
echo "Next steps:"
|
echo "Next steps:"
|
||||||
echo "1. Make a test commit"
|
echo "1. Make a test commit"
|
||||||
|
|
|
||||||
|
|
@ -1,49 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
# Git OpenTimestamp Post-Commit Hook (Node.js version)
|
|
||||||
# Requires: @opentimestamps/ots (npm install)
|
|
||||||
|
|
||||||
set -e
|
|
||||||
|
|
||||||
OUTPUT_DIR=".ots"
|
|
||||||
OUTPUT_FILE="$OUTPUT_DIR/proof.ots"
|
|
||||||
|
|
||||||
mkdir -p "$OUTPUT_DIR"
|
|
||||||
|
|
||||||
COMMIT_HASH=$(git rev-parse HEAD)
|
|
||||||
|
|
||||||
# Generate proof using Node.js
|
|
||||||
node -e "
|
|
||||||
const ots = require('@opentimestamps/ots');
|
|
||||||
const fs = require('fs');
|
|
||||||
const hash = '$COMMIT_HASH';
|
|
||||||
const output = '$OUTPUT_FILE';
|
|
||||||
const hashBuffer = Buffer.from(hash, 'hex');
|
|
||||||
|
|
||||||
ots.Timestamp.hash(hashBuffer).then(timestamp => {
|
|
||||||
// Note: This creates a local proof only, not submitted to calendars
|
|
||||||
// For full Bitcoin attestation, use the ots CLI version
|
|
||||||
const proof = {
|
|
||||||
hash: hash,
|
|
||||||
timestamp: new Date().toISOString(),
|
|
||||||
status: 'pending',
|
|
||||||
note: 'Local proof only - use ots CLI for calendar submission'
|
|
||||||
};
|
|
||||||
fs.writeFileSync(output, JSON.stringify(proof, null, 2));
|
|
||||||
console.log('[ots-node] Generated local proof: ' + hash.substring(0, 8));
|
|
||||||
}).catch(err => {
|
|
||||||
console.error('[ots-node] Error:', err.message);
|
|
||||||
process.exit(1);
|
|
||||||
});
|
|
||||||
"
|
|
||||||
|
|
||||||
# Save previous commit for chaining
|
|
||||||
PREV_COMMIT=$(git rev-parse HEAD^1 2>/dev/null || echo "")
|
|
||||||
if [ -n "$PREV_COMMIT" ]; then
|
|
||||||
echo "$PREV_COMMIT" > "$OUTPUT_DIR/prev-commit.txt"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Create individual proof file (JSON format for node version)
|
|
||||||
INDIVIDUAL_PROOF="$OUTPUT_DIR/${COMMIT_HASH}.ots"
|
|
||||||
cp "$OUTPUT_FILE" "$INDIVIDUAL_PROOF"
|
|
||||||
|
|
||||||
echo "[ots-node] Proof generated successfully"
|
|
||||||
|
|
@ -1,100 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
# Git OpenTimestamp Pre-Commit Backfill Hook (Node.js version)
|
|
||||||
# Requires: @opentimestamps/ots (npm install)
|
|
||||||
# Note: Node version only generates local proofs, no calendar submission
|
|
||||||
|
|
||||||
set -e
|
|
||||||
|
|
||||||
OUTPUT_DIR=".ots"
|
|
||||||
STATUS_CACHE="$OUTPUT_DIR/.attestation-cache"
|
|
||||||
|
|
||||||
mkdir -p "$OUTPUT_DIR"
|
|
||||||
|
|
||||||
# Initialize cache
|
|
||||||
if [ ! -f "$STATUS_CACHE" ]; then
|
|
||||||
echo "# Format: commit-hash:status:timestamp" > "$STATUS_CACHE"
|
|
||||||
fi
|
|
||||||
|
|
||||||
get_cached_status() {
|
|
||||||
local commit="$1"
|
|
||||||
local cache_line=$(grep "^$commit:" "$STATUS_CACHE" 2>/dev/null | tail -1)
|
|
||||||
if [ -n "$cache_line" ]; then
|
|
||||||
local status=$(echo "$cache_line" | cut -d: -f2)
|
|
||||||
local timestamp=$(echo "$cache_line" | cut -d: -f3)
|
|
||||||
local now=$(date +%s)
|
|
||||||
if [ "$((now - timestamp))" -lt 3600 ]; then
|
|
||||||
echo "$status"
|
|
||||||
return 0
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
return 1
|
|
||||||
}
|
|
||||||
|
|
||||||
cache_status() {
|
|
||||||
local commit="$1"
|
|
||||||
local status="$2"
|
|
||||||
echo "$commit:$status:$(date +%s)" >> "$STATUS_CACHE"
|
|
||||||
}
|
|
||||||
|
|
||||||
generate_proof_node() {
|
|
||||||
local hash="$1"
|
|
||||||
local output="$2"
|
|
||||||
|
|
||||||
node -e "
|
|
||||||
const ots = require('@opentimestamps/ots');
|
|
||||||
const fs = require('fs');
|
|
||||||
const hash = '$hash';
|
|
||||||
const output = '$output';
|
|
||||||
const hashBuffer = Buffer.from(hash, 'hex');
|
|
||||||
|
|
||||||
ots.Timestamp.hash(hashBuffer).then(timestamp => {
|
|
||||||
const proof = { hash: hash, timestamp: new Date().toISOString(), status: 'pending' };
|
|
||||||
fs.writeFileSync(output, JSON.stringify(proof, null, 2));
|
|
||||||
}).catch(err => { console.error('Error:', err); process.exit(1); });
|
|
||||||
"
|
|
||||||
}
|
|
||||||
|
|
||||||
echo "[ots-node] Backfilling proofs (local only, no calendar)..."
|
|
||||||
|
|
||||||
COMMITS=$(git rev-list --reverse HEAD)
|
|
||||||
TOTAL=$(echo "$COMMITS" | wc -l)
|
|
||||||
CURRENT=0
|
|
||||||
UPDATED=0
|
|
||||||
|
|
||||||
for COMMIT in $COMMITS; do
|
|
||||||
CURRENT=$((CURRENT + 1))
|
|
||||||
PROOF_FILE="$OUTPUT_DIR/${COMMIT}.ots"
|
|
||||||
|
|
||||||
if [ $CURRENT -le 3 ] || [ $CURRENT -eq $TOTAL ]; then
|
|
||||||
echo "[ots-node] Processing $CURRENT/$TOTAL: ${COMMIT:0:8}"
|
|
||||||
elif [ $CURRENT -eq 4 ]; then
|
|
||||||
echo "[ots-node] ... processing remaining ..."
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -f "$PROOF_FILE" ]; then
|
|
||||||
# Node version doesn't support upgrade, just check cache
|
|
||||||
CACHED_STATUS=$(get_cached_status "$COMMIT" || echo "")
|
|
||||||
[ "$CACHED_STATUS" = "attested" ] && continue
|
|
||||||
|
|
||||||
# Mark as pending (node can't attest)
|
|
||||||
cache_status "$COMMIT" "pending"
|
|
||||||
else
|
|
||||||
if generate_proof_node "$COMMIT" "$PROOF_FILE"; then
|
|
||||||
cache_status "$COMMIT" "pending"
|
|
||||||
UPDATED=$((UPDATED + 1))
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
# Update latest proof
|
|
||||||
LATEST_COMMIT=$(git rev-parse HEAD)
|
|
||||||
[ -f "$OUTPUT_DIR/${LATEST_COMMIT}.ots" ] && cp "$OUTPUT_DIR/${LATEST_COMMIT}.ots" "$OUTPUT_DIR/proof.ots"
|
|
||||||
|
|
||||||
# Save commit chain
|
|
||||||
rm -f "$OUTPUT_DIR/commit-chain.txt"
|
|
||||||
git rev-list HEAD | while read COMMIT; do
|
|
||||||
PREV=$(git rev-parse ${COMMIT}^1 2>/dev/null || echo "")
|
|
||||||
[ -n "$PREV" ] && echo "$COMMIT:$PREV" >> "$OUTPUT_DIR/commit-chain.txt"
|
|
||||||
done
|
|
||||||
|
|
||||||
echo "[ots-node] Backfill complete: $UPDATED generated (local proofs only)"
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue