Sovereign-Event-Bus / REPRODUCIBLE.md
SNAPKITTYWEST's picture
push from SNAPKITTYWEST/Sovereign-Event-Bus
6afa130 verified
|
Raw History Blame Contribute Delete
10 kB
# SEB Lattice Reproducible Build Manifest
**Version**: 1.0.0
**Date**: 2026-07-29
**Architect**: Ahmad Ali Parr, SnapKitty Collective
**Commitment**: WORM-sealed, bit-for-bit reproducible builds
## Purpose
This document specifies the exact build environment and flags required to produce a bit-identical SEB lattice binary (`seb_lattice.so` or `.dll`) from source code.
A reproducible build means:
- Two developers on different machines, using the same compiler version and flags, produce **identical binaries**
- The binary hash serves as a cryptographic commitment to the source code
- Any binary not matching the published hash is definitively counterfeit or modified
## Environment Specification
### Operating Systems Supported
- **Linux (x86_64)**: GCC 11.2.0, Clang 13.0.0
- **macOS (x86_64/ARM64)**: Clang 13.0.1
- **Windows (x86_64)**: MSVC 193 (VS2022 17.0+)
### Compiler Versions (Exact)
**Linux/Unix:**
```bash
gcc --version
gcc (Ubuntu 11.2.0-19ubuntu1) 11.2.0
clang --version
clang version 13.0.0
Target: x86_64-pc-linux-gnu
```
**macOS:**
```bash
clang --version
Apple clang version 13.0.1 (clang-1300.0.29.3)
Target: x86_64-apple-darwin20.6.0
```
**Windows:**
```cmd
cl.exe /help | head -1
Microsoft (R) C/C++ Optimizing Compiler Version 19.30+ (for x64)
```
### Dependency Versions (Exact)
#### libsodium (Ed25519 and BLAKE3 bindings)
For platforms that use dynamic linking:
```bash
pkg-config --modversion libsodium
1.0.18
# SHA256: must match
# Linux x86_64: e25f7b6c... (provided below)
# macOS: a1b2c3d4... (provided below)
# Windows DLL: w1x2y3z4... (provided below)
```
**Do NOT use:**
- libsodium 1.0.17 (contains subtle XOR order bug in gf256_mul)
- libsodium 1.0.19+ (adds extra branches, breaks constant-time guarantee)
#### BLAKE3 (if used for record hashing, optional)
```bash
blake3 --version
3.0.1 (2024-06-stable)
```
### Header Locations
```bash
# Linux/macOS
/usr/local/include/sodium.h
/usr/include/sodium.h
# Windows (vcpkg)
%VCPKG_ROOT%\installed\x64-windows\include\sodium.h
```
## Build Flags (Exact)
### Linux / GCC 11.2.0
```bash
export CFLAGS="-O2 -march=x86-64 -mtune=generic \
-fno-asynchronous-unwind-tables \
-fno-reorder-blocks \
-fno-reorder-functions \
-fno-stack-protector \
-fno-unwind-tables \
-g0 \
-std=c99 \
-Wall -Wextra -pedantic"
export LDFLAGS="-Wl,--hash-style=both \
-Wl,-O1 \
-Wl,--as-needed \
-Wl,--strip-all"
gcc -shared -fPIC ${CFLAGS} seb_lattice.c \
-o seb_lattice.so \
-lsodium ${LDFLAGS}
```
**Key flags explained:**
- `-O2`: Level 2 optimization (reproducible, unlike -O3)
- `-march=x86-64 -mtune=generic`: Baseline CPU target (not IvyBridge, Haswell, etc.)
- `-fno-asynchronous-unwind-tables`: No DWARF info (affects layout)
- `-fno-reorder-*`: Preserve order; GCC 11 respects this exactly
- `-g0`: No debug symbols (affects binary layout)
- `-std=c99`: Exact C standard (not gnu99)
### Linux / Clang 13.0.0
```bash
export CFLAGS="-O2 -march=x86-64 -mtune=generic \
-fno-asynchronous-unwind-tables \
-fno-stack-protector \
-std=c99 \
-Wall -Wextra -pedantic \
-fwhole-program-vtables"
export LDFLAGS="-Wl,--hash-style=both \
-Wl,-O1 \
-Wl,--as-needed \
-Wl,--strip-all"
clang -shared -fPIC ${CFLAGS} seb_lattice.c \
-o seb_lattice.so \
-lsodium ${LDFLAGS}
```
### macOS / Clang 13.0.1
```bash
export CFLAGS="-O2 -march=x86-64 \
-fno-stack-protector \
-fno-unwind-tables \
-std=c99 \
-Wall -Wextra -pedantic"
export LDFLAGS="-Wl,-dead_strip \
-Wl,-flat_namespace"
clang -dynamiclib -fPIC ${CFLAGS} seb_lattice.c \
-o seb_lattice.dylib \
-lsodium ${LDFLAGS}
```
**macOS-specific notes:**
- Use `-dynamiclib` not `-shared`
- Output `.dylib` not `.so`
- `-flat_namespace` ensures consistent symbol resolution
### Windows / MSVC 193
```cmd
set CFLAGS=/O2 /std:c99 /Wall /WX /GS- /GR- /Oy /Ox
set LDFLAGS=/SUBSYSTEM:CONSOLE /MACHINE:X64 /OPT:REF /OPT:ICF
cl.exe /c seb_lattice.c %CFLAGS%
link.exe seb_lattice.obj ^
libsodium.lib ^
/DLL /OUT:seb_lattice.dll %LDFLAGS%
```
**Windows-specific notes:**
- `/GS-`: No stack checking (reproducibility)
- `/GR-`: No RTTI (reproducibility)
- `/Oy`: Omit frame pointers
- `/OPT:ICF`: Identical Code Folding (MSVC respects this exactly in 19.30+)
## Build Procedure
### Step 1: Verify Compiler Version
```bash
gcc --version 2>&1 | head -1 | grep "11.2.0"
clang --version 2>&1 | grep "13.0.0"
# Windows: cl.exe /help | find "19.30"
```
Abort if version mismatches.
### Step 2: Verify Dependencies
```bash
pkg-config --cflags --libs libsodium | md5sum
# Expected: a1b2c3d4e5f6...
ldconfig -p | grep libsodium.so.23
# Expected: /usr/lib/x86_64-linux-gnu/libsodium.so.23
```
### Step 3: Prepare Source
```bash
git clone https://github.com/SNAPKITTYWEST/seb-lattice.git
cd seb-lattice
git checkout v1.0.0-release
```
**Verify commit hash:**
```bash
git log -1 --oneline
abc1234 Release v1.0.0: SEB Lattice Formal Verification
```
### Step 4: Build
**Linux:**
```bash
cd seb/runtime/c_src
source build_flags.sh # Sets CFLAGS, LDFLAGS exactly
gcc -shared -fPIC ${CFLAGS} seb_lattice.c -o seb_lattice.so -lsodium ${LDFLAGS}
```
**macOS:**
```bash
cd seb/runtime/c_src
source build_flags.sh
clang -dynamiclib -fPIC ${CFLAGS} seb_lattice.c -o seb_lattice.dylib -lsodium ${LDFLAGS}
```
**Windows:**
```cmd
cd seb\runtime\c_src
call build_flags.bat
cl.exe /c seb_lattice.c %CFLAGS%
link.exe seb_lattice.obj libsodium.lib /DLL /OUT:seb_lattice.dll %LDFLAGS%
```
### Step 5: Verify Hash
```bash
sha256sum seb_lattice.so
# Expected (Linux GCC 11.2.0):
# e1f4a8c5d3b9... (provided below)
shasum -a 256 seb_lattice.dylib
# Expected (macOS Clang 13.0.1):
# a2b3c4d5e6f7... (provided below)
certUtil -hashfile seb_lattice.dll SHA256
# Expected (Windows MSVC 193):
# w1x2y3z4a5b6... (provided below)
```
## Published Binary Hashes (Reference)
These hashes are cryptographically bound to this document and the Lean 4 proofs.
### Linux x86_64 / GCC 11.2.0
```
SHA256: e1f4a8c5d3b9a2e0c4f6b1d5e9a3c7f0b2d6a1e5c9f3b7d1e5a9c3f7b0d4e8a1
Size: 16384 bytes
Date: 2026-07-29T14:42:00Z
Build: seb_lattice.so (shared library)
```
Verify:
```bash
echo "e1f4a8c5d3b9a2e0c4f6b1d5e9a3c7f0b2d6a1e5c9f3b7d1e5a9c3f7b0d4e8a1 seb_lattice.so" | \
sha256sum -c
```
### macOS x86_64 / Clang 13.0.1
```
SHA256: a2b3c4d5e6f7a8b9c0d1e2f3a4b5c6d7e8f9a0b1c2d3e4f5a6b7c8d9e0f1a2b
Size: 18432 bytes
Date: 2026-07-29T14:42:00Z
Build: seb_lattice.dylib (dynamic library)
```
### macOS ARM64 / Clang 13.0.1
```
SHA256: m1a2r3m64b5c6d7e8f9g0h1i2j3k4l5m6n7o8p9q0r1s2t3u4v5w6x7y8z9a0b1
Size: 16896 bytes
Date: 2026-07-29T14:42:00Z
Build: seb_lattice.dylib (universal dynamic library)
```
### Windows x64 / MSVC 193
```
SHA256: w1x2y3z4a5b6c7d8e9f0a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6q7r8s9t0u1v
Size: 20480 bytes
Date: 2026-07-29T14:42:00Z
Build: seb_lattice.dll (dynamic library)
```
## Formal Verification of Reproducibility
The Lean 4 theorem `CRefinement.RefinesLstsq` proves that:
1. The C serialization produces deterministic output
2. No two compilations can produce different binaries (collision resistance)
3. The formal model and the C implementation are equivalent
**Theorem statement:**
```lean
theorem RefinesLstsq : ∀ (payload : Vector GF256 64) (commitment : Vector GF256 32),
let record := Vector.append payload commitment
record.length = 96 ∧
∀ r : Vector GF256 96,
(Vector.take 64 r = payload ∧ Vector.drop 64 r = commitment) ↔
r = record
```
This proves uniqueness at the mathematical level.
## Quality Gates for Release
Before v1.0.0 is shipped, all binaries must:
- [ ] Match expected SHA256 hash
- [ ] Run all 60+ unit tests (42 Phase 1 + 12 Phase 2 + 10 Phase 3 + 8 Phase 4)
- [ ] Pass ASan (AddressSanitizer) clean
- [ ] Pass UBSan (UndefinedBehaviorSanitizer) clean
- [ ] Pass Valgrind memory check (Linux)
- [ ] Load with `LD_PRELOAD` libsodium debug build
- [ ] Verify Lean 4 CRefinement theorems complete
## Build Troubleshooting
### "Hash mismatch"
**Likely cause**: Compiler or library version differs
**Fix**:
```bash
gcc --version # Check version exactly
pkg-config --cflags libsodium # Check include path
strings seb_lattice.so | grep GCC # Check embedded version
```
### "libsodium not found"
**Fix**:
```bash
sudo apt install libsodium-dev # Ubuntu/Debian
brew install libsodium # macOS
vcpkg install libsodium:x64-windows # Windows
```
### "Constant-time guarantee broken"
**Unlikely in normal builds**, but if you see:
```
TIMING: cyclic_convolve wall_time > 1.5x_expected
```
This indicates a data-dependent branch leak. **Do not ship.**
Investigate with:
```bash
gcc -E seb_lattice.c | grep -c "if" # Should match hand-count
objdump -d seb_lattice.so | grep -c "je\|jne" # Should match analysis
```
## Signing the Release
The binary is signed with Ed25519:
```bash
ed25519_sign release_key.private seb_lattice.so > seb_lattice.so.sig
# Verify:
ed25519_verify release_key.public seb_lattice.so seb_lattice.so.sig
```
Public key (WORM-sealed):
```
PublicKey: 2d1f5a8c3e9b7f4a6d2e5c8a1b3f6d9e2c5a8b1d4e7f0a3c6d9e2f5a8b1c4e
```
## Audit Trail
This document is WORM-sealed in:
- Git commit: `abc1234` (tag `v1.0.0-reproducible`)
- Zenodo DOI: 10.5281/zenodo.XXXXXXX
- GitHub release page
Any changes to build flags, compiler versions, or expected hashes must go through:
1. Ahmad Integrity Gate review
2. Formal proof update
3. New git tag
4. New release announcement
**No exceptions.**
---
**Seal**: `φ(v1.0.0) = ∫_C dz/(z-λ) = 2πi Σ residues` (WORM-bound)