Datasets:
mike dupont commited on
Commit ·
810ef53
1
Parent(s): a5d4448
feat: NFT viewer with 6-layer stego decoder + WAV reconstruction
Browse filesClick tiles to collect, decode 6 stego bit planes per image:
R0: CBOR shard data
G0: Witness chain
B0: Eigenspace (Cl(15,0,0))
R1: Source text
G1: Notation (Dietrich & Loretz 1975)
B1: Cuneiform UTF-8
Collect all 71 → reconstruct NFT7 payload → play 8.4MB WAV audio.
Tiles served from solana.solfunmeme.com/retro-sync/
app.html
CHANGED
|
@@ -3,247 +3,393 @@
|
|
| 3 |
<head>
|
| 4 |
<meta charset="utf-8">
|
| 5 |
<meta name="viewport" content="width=device-width,initial-scale=1">
|
| 6 |
-
<title>Hurrian Hymn h.6 — 71-Shard NFT
|
| 7 |
<style>
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
.
|
| 13 |
-
.
|
| 14 |
-
.
|
| 15 |
-
.
|
| 16 |
-
.
|
| 17 |
-
.
|
| 18 |
-
.
|
| 19 |
-
.
|
| 20 |
-
.
|
| 21 |
-
.
|
| 22 |
-
.
|
| 23 |
-
.
|
| 24 |
-
.
|
| 25 |
-
.
|
| 26 |
-
.detail
|
| 27 |
-
.detail
|
| 28 |
-
.
|
| 29 |
-
.
|
| 30 |
-
.
|
| 31 |
-
.
|
| 32 |
-
.
|
| 33 |
-
.
|
| 34 |
-
.
|
| 35 |
-
.
|
| 36 |
-
.
|
| 37 |
-
|
| 38 |
-
#proof { color:#4a4; font-size:.75rem; margin-bottom:1rem; }
|
| 39 |
</style>
|
| 40 |
</head>
|
| 41 |
<body>
|
| 42 |
-
<h1>
|
| 43 |
-
<p class="
|
| 44 |
-
|
| 45 |
-
<div class="collection">
|
| 46 |
-
Collected: <span class="count" id="collected">0</span>/71 shards
|
| 47 |
-
· <span id="decoded-bytes">0</span> bytes decoded
|
| 48 |
-
· Click shards to collect · Collect all 71 to verify the ZK proof
|
| 49 |
-
</div>
|
| 50 |
-
|
| 51 |
-
<div id="proof"></div>
|
| 52 |
|
| 53 |
<div class="stats">
|
| 54 |
-
<div>
|
| 55 |
-
<div>
|
| 56 |
-
<div>
|
|
|
|
| 57 |
</div>
|
| 58 |
|
| 59 |
-
<div class="
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
<button onclick="filter('artifact')">Artifacts</button>
|
| 64 |
-
<button onclick="filter('witness')">Witnesses</button>
|
| 65 |
-
<button onclick="filter('eigenspace')">Eigenspace</button>
|
| 66 |
-
<button onclick="filter('metadata')">Metadata</button>
|
| 67 |
-
<button onclick="filter('reconstruction')">Reconstructions</button>
|
| 68 |
-
<button onclick="filter('reference')">References</button>
|
| 69 |
-
<button onclick="filter('youtube')">YouTube</button>
|
| 70 |
-
<button onclick="filter('pipeline')">Pipeline</button>
|
| 71 |
-
</div>
|
| 72 |
|
| 73 |
<div class="detail" id="detail">
|
|
|
|
| 74 |
<h2 id="detail-title"></h2>
|
| 75 |
-
<
|
| 76 |
-
<
|
|
|
|
| 77 |
</div>
|
| 78 |
|
| 79 |
-
<div class="grid" id="grid"></div>
|
| 80 |
-
|
| 81 |
<script>
|
| 82 |
-
const
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 83 |
let manifest = null;
|
| 84 |
let collected = new Set();
|
| 85 |
let shardCache = {};
|
| 86 |
-
|
| 87 |
-
|
| 88 |
|
| 89 |
async function init() {
|
| 90 |
-
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
|
|
|
|
|
|
|
|
|
| 99 |
}
|
| 100 |
-
|
| 101 |
}
|
| 102 |
|
| 103 |
-
function
|
| 104 |
-
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
|
| 111 |
-
|
| 112 |
-
|
| 113 |
-
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
<
|
| 118 |
-
|
| 119 |
-
`;
|
| 120 |
-
|
| 121 |
-
grid.appendChild(div);
|
| 122 |
-
});
|
| 123 |
}
|
| 124 |
|
| 125 |
-
async function
|
| 126 |
-
collected.add(
|
| 127 |
-
document.getElementById('
|
|
|
|
| 128 |
|
| 129 |
-
// Fetch
|
| 130 |
-
if (!shardCache[
|
| 131 |
try {
|
| 132 |
-
const r = await fetch(`${
|
| 133 |
-
|
| 134 |
-
|
| 135 |
-
const bytes = new TextEncoder().encode(text);
|
| 136 |
-
const hash = Array.from(new Uint8Array(await crypto.subtle.digest('SHA-256', bytes))).slice(0,8);
|
| 137 |
-
const cid = hash.map(b=>b.toString(16).padStart(2,'0')).join('');
|
| 138 |
-
shardCache[s.index] = { magic:'0xda51', cid, bytes: bytes.length, payload, raw: bytes };
|
| 139 |
-
} catch(e) {
|
| 140 |
-
shardCache[s.index] = { magic:'0xda51', cid:'pending', bytes:0, payload:s, raw:null };
|
| 141 |
-
}
|
| 142 |
}
|
| 143 |
|
| 144 |
-
|
| 145 |
-
|
| 146 |
-
|
| 147 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 148 |
}
|
| 149 |
|
| 150 |
-
function
|
| 151 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 152 |
const detail = document.getElementById('detail');
|
| 153 |
detail.className = 'detail open';
|
| 154 |
-
|
| 155 |
-
|
| 156 |
-
|
| 157 |
-
//
|
| 158 |
-
const
|
| 159 |
-
const
|
| 160 |
-
|
| 161 |
-
|
| 162 |
-
|
| 163 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 164 |
];
|
| 165 |
-
|
| 166 |
-
|
| 167 |
-
|
| 168 |
-
btn.textContent = label;
|
| 169 |
-
btn.onclick = () => showLayer(s.index, key);
|
| 170 |
-
layers.appendChild(btn);
|
| 171 |
-
});
|
| 172 |
|
| 173 |
-
showLayer(
|
| 174 |
}
|
| 175 |
|
| 176 |
-
function showLayer(idx,
|
| 177 |
-
|
| 178 |
-
|
| 179 |
-
|
|
|
|
|
|
|
| 180 |
|
| 181 |
-
|
| 182 |
-
|
| 183 |
-
})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 184 |
|
| 185 |
-
|
| 186 |
-
|
| 187 |
-
|
| 188 |
-
|
| 189 |
-
|
| 190 |
-
|
| 191 |
-
|
| 192 |
-
|
| 193 |
-
|
| 194 |
-
|
| 195 |
-
|
| 196 |
-
|
| 197 |
-
|
| 198 |
-
|
| 199 |
-
|
| 200 |
-
|
| 201 |
-
|
| 202 |
-
|
| 203 |
-
|
| 204 |
-
|
| 205 |
-
if (d.raw) {
|
| 206 |
-
const hex = Array.from(d.raw.slice(0, 256))
|
| 207 |
-
.map(b => b.toString(16).padStart(2,'0'))
|
| 208 |
-
.join(' ')
|
| 209 |
-
.match(/.{1,48}/g).join('\n');
|
| 210 |
-
pre.textContent = hex + (d.raw.length > 256 ? `\n... (${d.raw.length} bytes total)` : '');
|
| 211 |
-
} else {
|
| 212 |
-
pre.textContent = '(not available)';
|
| 213 |
}
|
| 214 |
-
|
| 215 |
}
|
|
|
|
| 216 |
}
|
| 217 |
|
| 218 |
-
function
|
| 219 |
-
|
| 220 |
-
|
| 221 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 222 |
|
| 223 |
-
|
| 224 |
-
|
| 225 |
-
|
| 226 |
-
|
| 227 |
-
|
| 228 |
-
|
| 229 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 230 |
} else {
|
| 231 |
-
|
| 232 |
}
|
| 233 |
}
|
| 234 |
|
| 235 |
-
|
| 236 |
-
|
| 237 |
-
|
| 238 |
-
|
| 239 |
-
|
| 240 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 241 |
}
|
| 242 |
|
| 243 |
-
function
|
| 244 |
-
|
| 245 |
-
if (currentFilter === 'all') return manifest.shards;
|
| 246 |
-
return manifest.shards.filter(s => s.category === currentFilter);
|
| 247 |
}
|
| 248 |
|
| 249 |
init();
|
|
|
|
| 3 |
<head>
|
| 4 |
<meta charset="utf-8">
|
| 5 |
<meta name="viewport" content="width=device-width,initial-scale=1">
|
| 6 |
+
<title>Hurrian Hymn h.6 — 71-Shard NFT Collection</title>
|
| 7 |
<style>
|
| 8 |
+
*{box-sizing:border-box;margin:0;padding:0}
|
| 9 |
+
body{font:14px/1.5 'SF Mono',monospace;background:#0d1117;color:#c9d1d9;padding:1rem}
|
| 10 |
+
h1{font-size:1.4rem;color:#f0f6fc;margin-bottom:.3rem}
|
| 11 |
+
.sub{color:#8b949e;font-size:.8rem;margin-bottom:1rem}
|
| 12 |
+
.stats{display:flex;gap:1.5rem;flex-wrap:wrap;margin-bottom:1rem;font-size:.85rem}
|
| 13 |
+
.stat{background:#161b22;border:1px solid #30363d;border-radius:6px;padding:.4rem .8rem}
|
| 14 |
+
.stat b{color:#58a6ff}
|
| 15 |
+
.filters{margin-bottom:1rem;display:flex;gap:.5rem;flex-wrap:wrap}
|
| 16 |
+
.filters button{background:#21262d;color:#c9d1d9;border:1px solid #30363d;border-radius:4px;padding:3px 10px;cursor:pointer;font-size:.75rem}
|
| 17 |
+
.filters button.active{background:#1f6feb;border-color:#1f6feb;color:#fff}
|
| 18 |
+
.grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(100px,1fr));gap:6px;margin-bottom:1rem}
|
| 19 |
+
.tile{position:relative;cursor:pointer;border:2px solid #30363d;border-radius:4px;overflow:hidden;aspect-ratio:1;transition:transform .15s}
|
| 20 |
+
.tile:hover{transform:scale(1.05);z-index:1}
|
| 21 |
+
.tile.prime{border-color:#ffd700}
|
| 22 |
+
.tile.collected{opacity:1}.tile:not(.collected){opacity:.6}
|
| 23 |
+
.tile img{width:100%;height:100%;display:block}
|
| 24 |
+
.tile .label{position:absolute;bottom:0;left:0;right:0;background:rgba(0,0,0,.7);font-size:9px;padding:1px 3px;color:#c9d1d9;text-align:center}
|
| 25 |
+
.detail{position:fixed;top:0;right:-50%;width:50%;height:100%;background:#161b22;border-left:2px solid #30363d;overflow-y:auto;transition:right .3s;padding:1rem;z-index:10}
|
| 26 |
+
.detail.open{right:0}
|
| 27 |
+
.detail h2{font-size:1.1rem;color:#f0f6fc;margin-bottom:.5rem}
|
| 28 |
+
.close{position:absolute;top:.5rem;right:.5rem;background:none;border:none;color:#8b949e;font-size:1.5rem;cursor:pointer}
|
| 29 |
+
.layer-tabs{display:flex;gap:4px;margin:.5rem 0;flex-wrap:wrap}
|
| 30 |
+
.layer-tabs button{background:#21262d;color:#8b949e;border:1px solid #30363d;border-radius:4px;padding:2px 8px;cursor:pointer;font-size:.7rem}
|
| 31 |
+
.layer-tabs button.active{background:#238636;border-color:#238636;color:#fff}
|
| 32 |
+
.layer-content{background:#0d1117;border:1px solid #30363d;border-radius:4px;padding:.5rem;font-size:.75rem;max-height:300px;overflow:auto;white-space:pre-wrap;word-break:break-all;margin:.5rem 0}
|
| 33 |
+
.stego-canvas{border:1px solid #30363d;border-radius:4px;margin:.5rem 0}
|
| 34 |
+
.progress{background:#21262d;border-radius:4px;height:8px;margin:.5rem 0}
|
| 35 |
+
.progress-bar{background:linear-gradient(90deg,#238636,#ffd700);height:100%;border-radius:4px;transition:width .3s}
|
| 36 |
+
.hex{color:#7ee787}.cunei{color:#ffd700;font-size:1.2rem}
|
| 37 |
+
canvas{image-rendering:pixelated}
|
|
|
|
| 38 |
</style>
|
| 39 |
</head>
|
| 40 |
<body>
|
| 41 |
+
<h1>𒀸𒌑𒄴𒊑 Hurrian Hymn h.6 — 71-Shard NFT Collection</h1>
|
| 42 |
+
<p class="sub">Tablet RS 15.30 · ~1400 BC · Ugarit · West (1994) · DA51 CBOR · Groth16/BN254 · 6-Layer Stego</p>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 43 |
|
| 44 |
<div class="stats">
|
| 45 |
+
<div class="stat">Collected: <b id="count">0</b>/71</div>
|
| 46 |
+
<div class="stat">Decoded: <b id="decoded">0</b> B</div>
|
| 47 |
+
<div class="stat">Stego: <b id="stego-status">—</b></div>
|
| 48 |
+
<div class="stat">ZK: <b id="zk-status">pending</b></div>
|
| 49 |
</div>
|
| 50 |
|
| 51 |
+
<div class="progress"><div class="progress-bar" id="pbar" style="width:0%"></div></div>
|
| 52 |
+
|
| 53 |
+
<div class="filters" id="filters"></div>
|
| 54 |
+
<div class="grid" id="grid"></div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 55 |
|
| 56 |
<div class="detail" id="detail">
|
| 57 |
+
<button class="close" onclick="closeDetail()">×</button>
|
| 58 |
<h2 id="detail-title"></h2>
|
| 59 |
+
<canvas id="tile-canvas" class="stego-canvas" width="512" height="512"></canvas>
|
| 60 |
+
<div class="layer-tabs" id="layer-tabs"></div>
|
| 61 |
+
<div class="layer-content" id="layer-content"></div>
|
| 62 |
</div>
|
| 63 |
|
|
|
|
|
|
|
| 64 |
<script>
|
| 65 |
+
const BASE = 'https://solana.solfunmeme.com/retro-sync';
|
| 66 |
+
const TILES_URL = BASE + '/tiles';
|
| 67 |
+
const SHARDS_URL = BASE + '/shards';
|
| 68 |
+
|
| 69 |
+
const CATEGORIES = ['generator','source','artifact','witness','eigenspace','metadata','reconstruction','reference','youtube','pipeline','reserved'];
|
| 70 |
+
const CAT_COLORS = {generator:'#ffd700',source:'#d2a8ff',artifact:'#7ee787',witness:'#e3b341',eigenspace:'#79c0ff',metadata:'#ff7b72',reconstruction:'#a5d6ff',reference:'#d29922',youtube:'#f778ba',pipeline:'#56d364',reserved:'#484f58'};
|
| 71 |
+
const PRIMES = [2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71];
|
| 72 |
+
|
| 73 |
+
const STEGO_PLANES = [
|
| 74 |
+
{name:'R bit 0 — CBOR shard', ch:0, bit:0, color:'#ff6b6b'},
|
| 75 |
+
{name:'G bit 0 — Witness', ch:1, bit:0, color:'#51cf66'},
|
| 76 |
+
{name:'B bit 0 — Eigenspace', ch:2, bit:0, color:'#339af0'},
|
| 77 |
+
{name:'R bit 1 — Source', ch:0, bit:1, color:'#ff922b'},
|
| 78 |
+
{name:'G bit 1 — Notation', ch:1, bit:1, color:'#20c997'},
|
| 79 |
+
{name:'B bit 1 — Cuneiform', ch:2, bit:1, color:'#845ef7'},
|
| 80 |
+
];
|
| 81 |
+
|
| 82 |
let manifest = null;
|
| 83 |
let collected = new Set();
|
| 84 |
let shardCache = {};
|
| 85 |
+
let stegoCache = {};
|
| 86 |
+
let activeFilter = 'all';
|
| 87 |
|
| 88 |
async function init() {
|
| 89 |
+
const r = await fetch(BASE + '/manifest.json');
|
| 90 |
+
manifest = await r.json();
|
| 91 |
+
renderFilters();
|
| 92 |
+
renderGrid();
|
| 93 |
+
}
|
| 94 |
+
|
| 95 |
+
function renderFilters() {
|
| 96 |
+
const el = document.getElementById('filters');
|
| 97 |
+
let html = '<button class="active" onclick="setFilter(\'all\',this)">all (71)</button>';
|
| 98 |
+
for (const cat of CATEGORIES) {
|
| 99 |
+
const n = manifest.shards.filter(s => s.category === cat).length;
|
| 100 |
+
if (n > 0) html += `<button onclick="setFilter('${cat}',this)">${cat} (${n})</button>`;
|
| 101 |
}
|
| 102 |
+
el.innerHTML = html;
|
| 103 |
}
|
| 104 |
|
| 105 |
+
function setFilter(cat, btn) {
|
| 106 |
+
activeFilter = cat;
|
| 107 |
+
document.querySelectorAll('.filters button').forEach(b => b.classList.remove('active'));
|
| 108 |
+
btn.classList.add('active');
|
| 109 |
+
renderGrid();
|
| 110 |
+
}
|
| 111 |
+
|
| 112 |
+
function renderGrid() {
|
| 113 |
+
const shards = activeFilter === 'all' ? manifest.shards : manifest.shards.filter(s => s.category === activeFilter);
|
| 114 |
+
const el = document.getElementById('grid');
|
| 115 |
+
el.innerHTML = shards.map(s => {
|
| 116 |
+
const prime = PRIMES.includes(s.index);
|
| 117 |
+
const cls = [prime ? 'prime' : '', collected.has(s.index) ? 'collected' : ''].join(' ');
|
| 118 |
+
return `<div class="tile ${cls}" onclick="collect(${s.index})" title="#${s.index} ${s.name} [${s.category}]">
|
| 119 |
+
<img src="${TILES_URL}/${String(s.index).padStart(2,'0')}.png" loading="lazy" alt="Shard ${s.index}">
|
| 120 |
+
<div class="label">${prime?'★':'·'}${s.index} ${s.category}</div>
|
| 121 |
+
</div>`;
|
| 122 |
+
}).join('');
|
|
|
|
|
|
|
| 123 |
}
|
| 124 |
|
| 125 |
+
async function collect(idx) {
|
| 126 |
+
collected.add(idx);
|
| 127 |
+
document.getElementById('count').textContent = collected.size;
|
| 128 |
+
document.getElementById('pbar').style.width = (collected.size/71*100)+'%';
|
| 129 |
|
| 130 |
+
// Fetch JSON shard
|
| 131 |
+
if (!shardCache[idx]) {
|
| 132 |
try {
|
| 133 |
+
const r = await fetch(`${SHARDS_URL}/${String(idx).padStart(2,'0')}.json`);
|
| 134 |
+
shardCache[idx] = await r.json();
|
| 135 |
+
} catch(e) { shardCache[idx] = {error: e.message}; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 136 |
}
|
| 137 |
|
| 138 |
+
// Decode stego from tile image
|
| 139 |
+
if (!stegoCache[idx]) {
|
| 140 |
+
stegoCache[idx] = await decodeStegoFromImage(idx);
|
| 141 |
+
}
|
| 142 |
+
|
| 143 |
+
updateStats();
|
| 144 |
+
showDetail(idx);
|
| 145 |
+
renderGrid();
|
| 146 |
+
if (collected.size === 71) reconstructPayload();
|
| 147 |
}
|
| 148 |
|
| 149 |
+
async function decodeStegoFromImage(idx) {
|
| 150 |
+
return new Promise((resolve) => {
|
| 151 |
+
const img = new Image();
|
| 152 |
+
img.crossOrigin = 'anonymous';
|
| 153 |
+
img.onload = () => {
|
| 154 |
+
const c = document.createElement('canvas');
|
| 155 |
+
c.width = 512; c.height = 512;
|
| 156 |
+
const ctx = c.getContext('2d');
|
| 157 |
+
ctx.drawImage(img, 0, 0);
|
| 158 |
+
const pixels = ctx.getImageData(0, 0, 512, 512).data; // RGBA
|
| 159 |
+
|
| 160 |
+
// Extract 6 bit planes
|
| 161 |
+
const layers = {};
|
| 162 |
+
for (const plane of STEGO_PLANES) {
|
| 163 |
+
const bytes = [];
|
| 164 |
+
const npx = 512*512;
|
| 165 |
+
const bytesPerLayer = npx / 8;
|
| 166 |
+
for (let i = 0; i < bytesPerLayer; i++) {
|
| 167 |
+
let byte = 0;
|
| 168 |
+
for (let b = 0; b < 8; b++) {
|
| 169 |
+
const px = i * 8 + b;
|
| 170 |
+
if (px >= npx) break;
|
| 171 |
+
const rgbaIdx = px * 4 + plane.ch;
|
| 172 |
+
byte |= ((pixels[rgbaIdx] >> plane.bit) & 1) << b;
|
| 173 |
+
}
|
| 174 |
+
bytes.push(byte);
|
| 175 |
+
}
|
| 176 |
+
layers[plane.name] = new Uint8Array(bytes);
|
| 177 |
+
}
|
| 178 |
+
resolve(layers);
|
| 179 |
+
};
|
| 180 |
+
img.onerror = () => resolve({});
|
| 181 |
+
img.src = `${TILES_URL}/${String(idx).padStart(2,'0')}.png`;
|
| 182 |
+
});
|
| 183 |
+
}
|
| 184 |
+
|
| 185 |
+
function updateStats() {
|
| 186 |
+
let totalBytes = 0;
|
| 187 |
+
for (const idx of collected) {
|
| 188 |
+
if (stegoCache[idx]) {
|
| 189 |
+
for (const layer of Object.values(stegoCache[idx])) {
|
| 190 |
+
totalBytes += layer.length;
|
| 191 |
+
}
|
| 192 |
+
}
|
| 193 |
+
}
|
| 194 |
+
document.getElementById('decoded').textContent = totalBytes.toLocaleString();
|
| 195 |
+
document.getElementById('stego-status').textContent = `${collected.size}×6 planes`;
|
| 196 |
+
}
|
| 197 |
+
|
| 198 |
+
function showDetail(idx) {
|
| 199 |
+
const s = manifest.shards.find(x => x.index === idx);
|
| 200 |
const detail = document.getElementById('detail');
|
| 201 |
detail.className = 'detail open';
|
| 202 |
+
const prime = PRIMES.includes(idx);
|
| 203 |
+
document.getElementById('detail-title').textContent = `${prime?'★':''} Shard #${idx} — ${s.name} [${s.category}]`;
|
| 204 |
+
|
| 205 |
+
// Draw tile on canvas
|
| 206 |
+
const canvas = document.getElementById('tile-canvas');
|
| 207 |
+
const ctx = canvas.getContext('2d');
|
| 208 |
+
const img = new Image();
|
| 209 |
+
img.crossOrigin = 'anonymous';
|
| 210 |
+
img.onload = () => ctx.drawImage(img, 0, 0, 512, 512);
|
| 211 |
+
img.src = `${TILES_URL}/${String(idx).padStart(2,'0')}.png`;
|
| 212 |
+
|
| 213 |
+
// Layer tabs
|
| 214 |
+
const tabs = document.getElementById('layer-tabs');
|
| 215 |
+
const layers = [
|
| 216 |
+
{id:'json', name:'JSON Shard', color:'#58a6ff'},
|
| 217 |
+
{id:'data_layers', name:'Data Layers', color:'#79c0ff'},
|
| 218 |
+
...STEGO_PLANES.map((p,i) => ({id:'stego_'+i, name:p.name, color:p.color})),
|
| 219 |
+
{id:'hex', name:'Raw Hex', color:'#7ee787'},
|
| 220 |
+
{id:'visual', name:'Stego Visual', color:'#d2a8ff'},
|
| 221 |
];
|
| 222 |
+
tabs.innerHTML = layers.map((l,i) =>
|
| 223 |
+
`<button style="border-color:${l.color}" onclick="showLayer(${idx},'${l.id}',this)">${l.name}</button>`
|
| 224 |
+
).join('');
|
|
|
|
|
|
|
|
|
|
|
|
|
| 225 |
|
| 226 |
+
showLayer(idx, 'json', tabs.firstChild);
|
| 227 |
}
|
| 228 |
|
| 229 |
+
function showLayer(idx, layerId, btn) {
|
| 230 |
+
document.querySelectorAll('#layer-tabs button').forEach(b => b.classList.remove('active'));
|
| 231 |
+
if (btn) btn.classList.add('active');
|
| 232 |
+
const el = document.getElementById('layer-content');
|
| 233 |
+
const shard = shardCache[idx];
|
| 234 |
+
const stego = stegoCache[idx] || {};
|
| 235 |
|
| 236 |
+
if (layerId === 'json') {
|
| 237 |
+
el.innerHTML = `<pre>${JSON.stringify(shard, null, 2).slice(0, 4000)}</pre>`;
|
| 238 |
+
} else if (layerId === 'data_layers') {
|
| 239 |
+
if (shard && shard.data_layers) {
|
| 240 |
+
const dl = shard.data_layers;
|
| 241 |
+
el.innerHTML = Object.keys(dl).map(k => {
|
| 242 |
+
const l = dl[k];
|
| 243 |
+
return `<b>${k}</b>: chunk ${l.chunk}/${l.of}, ${l.total_bytes.toLocaleString()} B total\n` +
|
| 244 |
+
` data: ${l.data.slice(0,80)}${l.data.length>80?'...':''}`;
|
| 245 |
+
}).join('\n\n');
|
| 246 |
+
} else {
|
| 247 |
+
el.textContent = 'No data_layers in shard';
|
| 248 |
+
}
|
| 249 |
+
} else if (layerId === 'hex') {
|
| 250 |
+
const bytes = stego[STEGO_PLANES[0].name];
|
| 251 |
+
if (bytes) {
|
| 252 |
+
const hex = Array.from(bytes.slice(0, 256)).map(b => b.toString(16).padStart(2,'0')).join(' ');
|
| 253 |
+
el.innerHTML = `<span class="hex">${hex}</span>\n\n... ${bytes.length} bytes in R bit 0 plane`;
|
| 254 |
+
} else {
|
| 255 |
+
el.textContent = 'Collect this shard to decode stego';
|
| 256 |
+
}
|
| 257 |
+
} else if (layerId === 'visual') {
|
| 258 |
+
visualizeStegoPlanes(idx);
|
| 259 |
+
el.textContent = 'Stego bit planes rendered on canvas above.\nEach plane shown as a separate color channel.';
|
| 260 |
+
} else if (layerId.startsWith('stego_')) {
|
| 261 |
+
const pi = parseInt(layerId.split('_')[1]);
|
| 262 |
+
const plane = STEGO_PLANES[pi];
|
| 263 |
+
const bytes = stego[plane.name];
|
| 264 |
+
if (bytes) {
|
| 265 |
+
// Try to decode as text
|
| 266 |
+
let text = '';
|
| 267 |
+
try { text = new TextDecoder('utf-8', {fatal: false}).decode(bytes.slice(0, 512)); } catch(e) {}
|
| 268 |
+
const nonNull = bytes.filter(b => b !== 0).length;
|
| 269 |
+
const hex = Array.from(bytes.slice(0, 128)).map(b => b.toString(16).padStart(2,'0')).join(' ');
|
| 270 |
+
el.innerHTML = `<b>${plane.name}</b>\nBytes: ${bytes.length} (${nonNull} non-zero)\n\n` +
|
| 271 |
+
`<b>Text preview:</b>\n${text.replace(/\0/g,'·').slice(0,300)}\n\n` +
|
| 272 |
+
`<b>Hex:</b>\n<span class="hex">${hex}</span>...`;
|
| 273 |
+
} else {
|
| 274 |
+
el.textContent = 'Collect this shard to decode';
|
| 275 |
+
}
|
| 276 |
+
}
|
| 277 |
+
}
|
| 278 |
+
|
| 279 |
+
function visualizeStegoPlanes(idx) {
|
| 280 |
+
const canvas = document.getElementById('tile-canvas');
|
| 281 |
+
const ctx = canvas.getContext('2d');
|
| 282 |
+
const stego = stegoCache[idx];
|
| 283 |
+
if (!stego) return;
|
| 284 |
|
| 285 |
+
// Render each plane as colored pixels
|
| 286 |
+
const imgData = ctx.createImageData(512, 512);
|
| 287 |
+
for (const plane of STEGO_PLANES) {
|
| 288 |
+
const bytes = stego[plane.name];
|
| 289 |
+
if (!bytes) continue;
|
| 290 |
+
const color = plane.color;
|
| 291 |
+
const r = parseInt(color.slice(1,3),16);
|
| 292 |
+
const g = parseInt(color.slice(3,5),16);
|
| 293 |
+
const b = parseInt(color.slice(5,7),16);
|
| 294 |
+
for (let i = 0; i < bytes.length; i++) {
|
| 295 |
+
for (let bit = 0; bit < 8; bit++) {
|
| 296 |
+
const px = i * 8 + bit;
|
| 297 |
+
if (px >= 512*512) break;
|
| 298 |
+
if ((bytes[i] >> bit) & 1) {
|
| 299 |
+
const off = px * 4;
|
| 300 |
+
imgData.data[off] = Math.min(255, imgData.data[off] + r/6);
|
| 301 |
+
imgData.data[off+1] = Math.min(255, imgData.data[off+1] + g/6);
|
| 302 |
+
imgData.data[off+2] = Math.min(255, imgData.data[off+2] + b/6);
|
| 303 |
+
imgData.data[off+3] = 255;
|
| 304 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 305 |
}
|
| 306 |
+
}
|
| 307 |
}
|
| 308 |
+
ctx.putImageData(imgData, 0, 0);
|
| 309 |
}
|
| 310 |
|
| 311 |
+
async function reconstructPayload() {
|
| 312 |
+
document.getElementById('zk-status').textContent = 'reconstructing...';
|
| 313 |
+
// Collect all stego data in order — use the full 6-plane stream per tile
|
| 314 |
+
const allBytes = [];
|
| 315 |
+
const CAP = 512*512*6/8; // 196608 per tile
|
| 316 |
+
|
| 317 |
+
for (let idx = 1; idx <= 71; idx++) {
|
| 318 |
+
const stego = stegoCache[idx];
|
| 319 |
+
if (!stego) { allBytes.push(...new Array(CAP).fill(0)); continue; }
|
| 320 |
+
|
| 321 |
+
// Re-extract as interleaved stream (matching Rust embed_all order)
|
| 322 |
+
const img = await loadImagePixels(idx);
|
| 323 |
+
if (!img) { allBytes.push(...new Array(CAP).fill(0)); continue; }
|
| 324 |
|
| 325 |
+
for (let i = 0; i < CAP; i++) {
|
| 326 |
+
let byte = 0;
|
| 327 |
+
for (let b = 0; b < 8; b++) {
|
| 328 |
+
const bitIdx = i * 8 + b;
|
| 329 |
+
const px = Math.floor(bitIdx / 6);
|
| 330 |
+
const plane = bitIdx % 6;
|
| 331 |
+
if (px >= 512*512) break;
|
| 332 |
+
const ch = plane % 3;
|
| 333 |
+
const bitPos = Math.floor(plane / 3);
|
| 334 |
+
const val = (img[px * 4 + ch] >> bitPos) & 1;
|
| 335 |
+
byte |= val << b;
|
| 336 |
+
}
|
| 337 |
+
allBytes.push(byte);
|
| 338 |
+
}
|
| 339 |
+
}
|
| 340 |
+
|
| 341 |
+
// Parse NFT7 header
|
| 342 |
+
const data = new Uint8Array(allBytes);
|
| 343 |
+
const magic = String.fromCharCode(data[0], data[1], data[2], data[3]);
|
| 344 |
+
if (magic === 'NFT7') {
|
| 345 |
+
const view = new DataView(data.buffer);
|
| 346 |
+
const segCount = view.getUint32(4, true);
|
| 347 |
+
let offset = 8;
|
| 348 |
+
const segments = [];
|
| 349 |
+
for (let s = 0; s < segCount && offset < data.length; s++) {
|
| 350 |
+
const nameLen = view.getUint32(offset, true); offset += 4;
|
| 351 |
+
const name = new TextDecoder().decode(data.slice(offset, offset + nameLen)); offset += nameLen;
|
| 352 |
+
const dataLen = view.getUint32(offset, true); offset += 4;
|
| 353 |
+
const segData = data.slice(offset, offset + dataLen); offset += dataLen;
|
| 354 |
+
segments.push({name, data: segData, size: dataLen});
|
| 355 |
+
}
|
| 356 |
+
|
| 357 |
+
document.getElementById('zk-status').innerHTML = `<span style="color:#238636">✓ NFT7 DECODED</span> — ${segments.length} segments`;
|
| 358 |
+
|
| 359 |
+
// Offer WAV playback
|
| 360 |
+
const wav = segments.find(s => s.name === 'wav');
|
| 361 |
+
if (wav) {
|
| 362 |
+
const blob = new Blob([wav.data], {type: 'audio/wav'});
|
| 363 |
+
const url = URL.createObjectURL(blob);
|
| 364 |
+
const info = document.getElementById('layer-content');
|
| 365 |
+
info.innerHTML = `<b>🎵 Full payload reconstructed from 71 stego tiles!</b>\n\n` +
|
| 366 |
+
segments.map(s => `${s.name}: ${s.size.toLocaleString()} bytes`).join('\n') +
|
| 367 |
+
`\n\n<audio controls src="${url}" style="width:100%"></audio>\n` +
|
| 368 |
+
`<a href="${url}" download="h6_west.wav" style="color:#58a6ff">⬇ Download WAV</a>`;
|
| 369 |
+
}
|
| 370 |
} else {
|
| 371 |
+
document.getElementById('zk-status').textContent = 'reconstruction failed — collect all 71';
|
| 372 |
}
|
| 373 |
}
|
| 374 |
|
| 375 |
+
function loadImagePixels(idx) {
|
| 376 |
+
return new Promise(resolve => {
|
| 377 |
+
const img = new Image();
|
| 378 |
+
img.crossOrigin = 'anonymous';
|
| 379 |
+
img.onload = () => {
|
| 380 |
+
const c = document.createElement('canvas');
|
| 381 |
+
c.width = 512; c.height = 512;
|
| 382 |
+
const ctx = c.getContext('2d');
|
| 383 |
+
ctx.drawImage(img, 0, 0);
|
| 384 |
+
resolve(ctx.getImageData(0, 0, 512, 512).data);
|
| 385 |
+
};
|
| 386 |
+
img.onerror = () => resolve(null);
|
| 387 |
+
img.src = `${TILES_URL}/${String(idx).padStart(2,'0')}.png`;
|
| 388 |
+
});
|
| 389 |
}
|
| 390 |
|
| 391 |
+
function closeDetail() {
|
| 392 |
+
document.getElementById('detail').className = 'detail';
|
|
|
|
|
|
|
| 393 |
}
|
| 394 |
|
| 395 |
init();
|