Skip to content

Git Integration

PrimeStamp integrates deeply with Git to provide version-chained document authentication. Rather than proving that a document existed at a single point in time, the Git integration proves that a document evolved through an authenticated chain of changes.

Features

  • Automatic stamping on commits via Git hooks
  • Version chain verification across commit history
  • Delta stamps that only cover changes between versions
  • Branch and merge proofs
  • Structural diff analysis using Prime-Space fingerprints
  • Multi-author collaborative tracking

Quick Start

Install Git Hooks

# Initialize PrimeStamp in a Git repository
cd /path/to/your/repo
primestamp git init

# This installs:
#   .git/hooks/pre-commit   - stamps changed files
#   .git/hooks/post-commit  - records commit metadata

Manual Stamping

# Stamp all tracked files in the current commit
primestamp git stamp HEAD

# Stamp a specific file
primestamp git stamp HEAD -- path/to/file.py

# Verify the stamp chain for a file
primestamp git verify path/to/file.py

Version Chains

A VersionChain links successive document stamps into a cryptographically verifiable history.

from primestamp.integrations.git import VersionChain, StructuralDiffEngine
from primestamp.core.engine import StampEngine
from primestamp.core.crypto import KeyPair

keys = KeyPair.generate()
engine = StampEngine(keys)

# The chain is built automatically when using Git hooks,
# or you can construct it manually:
chain = VersionChain(
    chain_id="doc-chain-001",
    document_name="contract.pdf",
)
print(f"Chain length: {chain.length}")
print(f"HEAD stamp: {chain.head}")

Delta Stamps

Delta stamps record only what changed between versions, enabling efficient storage and selective disclosure.

from primestamp.integrations.git import StructuralDiffEngine

diff_engine = StructuralDiffEngine()

diff = diff_engine.compute_diff(old_content, new_content)
print(f"Sections added: {diff.sections_added}")
print(f"Sections modified: {diff.sections_modified}")
print(f"Sections unchanged: {diff.sections_unchanged}")
print(f"Overall similarity: {diff.overall_similarity:.4f}")

Structural Diffs

PrimeStamp uses Prime-Space fingerprints to compute structural diffs rather than line-level text diffs. This reveals which logical sections changed and by how much.

Field Description
section_changes Per-section change type and similarity score
scale_similarities Multi-scale similarity from shadow transforms
sections_added Count of new sections
sections_removed Count of removed sections
sections_modified Count of modified sections
overall_similarity Aggregate structural similarity (0.0--1.0)

Configuration

Configure Git integration in .primestamp.toml at the repository root:

[git]
auto_stamp = true
preset = "standard"
stamp_patterns = ["*.py", "*.md", "*.pdf"]
ignore_patterns = ["*.pyc", "__pycache__", ".env"]
delta_stamps = true

[git.hooks]
pre_commit = true
post_commit = true
Option Default Description
auto_stamp true Automatically stamp changed files on commit.
preset standard Default stamping preset for Git-triggered stamps.
stamp_patterns ["*"] Glob patterns for files to stamp.
ignore_patterns [] Glob patterns for files to skip.
delta_stamps true Generate delta stamps between versions.

CI/CD Integration

Combine Git hooks with CI/CD integration to stamp builds and verify version chains as part of your pipeline. This creates an end-to-end authenticated software supply chain.

Branch and Merge

PrimeStamp tracks branches and merges within the version chain. Merge stamps include references to both parent chains, creating a verifiable DAG that mirrors the Git history.