Sandstorm v1.2 — QUAD AES: four AES-256 layers (1024-bit key), SHA-512 chain, 4 glass packets
Browse files- storm/index.html +26 -23
storm/index.html
CHANGED
|
@@ -1,5 +1,5 @@
|
|
| 1 |
<!doctype html><html><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1">
|
| 2 |
-
<title>SANDSTORM</title>
|
| 3 |
<style>
|
| 4 |
body{margin:0;background:#04060c;color:#f3e2b3;font:14px system-ui;padding:14px;max-width:900px;margin:auto}
|
| 5 |
h1{letter-spacing:4px;font-size:20px;margin:8px 0}
|
|
@@ -10,11 +10,11 @@ button.go{background:#c9a75d;color:#04060c;font-weight:700}
|
|
| 10 |
#snake{display:flex;flex-wrap:wrap;gap:6px;margin-top:12px}
|
| 11 |
.seg{flex:1 1 200px;background:linear-gradient(135deg,#ffffff14,#7fc4ff10);border:1px solid #9fd3ff55;border-radius:14px;padding:9px;backdrop-filter:blur(4px);word-break:break-all;animation:in .4s ease both}
|
| 12 |
.seg b{color:#fff}.seg small{opacity:.6;display:block}.seg a{color:#7fc4ff}.seg code{font-size:11px;color:#9fe39f}
|
| 13 |
-
.shard{border-color:#d4af3788}.shard.picked{outline:2px solid #d4af37}
|
| 14 |
@keyframes in{from{opacity:0;transform:translateY(8px)}to{opacity:1}}
|
| 15 |
#out{margin-top:10px;padding:10px;border-radius:10px;background:#0b1222;display:none}
|
| 16 |
</style></head><body>
|
| 17 |
-
<h1>🌪️ SANDSTORM ·
|
| 18 |
<textarea id="msg" placeholder="anything you want wrapped in the storm"></textarea>
|
| 19 |
<div class="row">Shards <select id="n"><option>3</option><option selected>5</option><option>7</option><option>9</option></select>
|
| 20 |
need <select id="k"><option>2</option><option selected>3</option><option>4</option><option>5</option></select> to rebuild
|
|
@@ -23,43 +23,46 @@ need <select id="k"><option>2</option><option selected>3</option><option>4</opti
|
|
| 23 |
<div class="row" id="rb" style="display:none"><span>Tap shards to pick them, then</span><button id="re">🧩 Rebuild</button></div>
|
| 24 |
<div id="out"></div>
|
| 25 |
<script>
|
| 26 |
-
const
|
| 27 |
-
|
| 28 |
const enc=new TextEncoder(),dec=new TextDecoder();
|
| 29 |
const hex=b=>[...new Uint8Array(b)].map(x=>x.toString(16).padStart(2,'0')).join('');
|
| 30 |
-
const sha=async b=>hex(await crypto.subtle.digest('SHA-
|
| 31 |
-
// GF(256)
|
| 32 |
const EXP=new Uint8Array(512),LOG=new Uint8Array(256);{let x=1;for(let i=0;i<255;i++){EXP[i]=x;LOG[x]=i;const xt=((x<<1)^(x&0x80?0x1b:0))&0xff;x^=xt}for(let i=255;i<512;i++)EXP[i]=EXP[i-255]}
|
| 33 |
const mul=(a,b)=>a&&b?EXP[LOG[a]+LOG[b]]:0,dv=(a,b)=>a?EXP[(LOG[a]+255-LOG[b])%255]:0;
|
| 34 |
function split(sec,n,k){const sh=[...Array(n)].map((_,i)=>({x:i+1,y:new Uint8Array(sec.length)}));
|
| 35 |
sec.forEach((s,bi)=>{const c=[s,...crypto.getRandomValues(new Uint8Array(k-1))];sh.forEach(S=>{let y=0;for(let j=c.length-1;j>=0;j--)y=mul(y,S.x)^c[j];S.y[bi]=y})});return sh}
|
| 36 |
function combine(sh){const L=sh[0].y.length,out=new Uint8Array(L);
|
| 37 |
for(let b=0;b<L;b++){let s=0;sh.forEach((Si,i)=>{let num=1,den=1;sh.forEach((Sj,j)=>{if(i!==j){num=mul(num,Sj.x);den=mul(den,Sj.x^Si.x)}});s^=mul(Si.y[b],dv(num,den))});out[b]=s}return out}
|
|
|
|
|
|
|
| 38 |
let state=null;const snake=document.getElementById('snake');
|
| 39 |
-
function seg(cls,title,
|
| 40 |
-
d.innerHTML=`<b>${title}</b><small>${new Date(t).toISOString()} · <a href="${
|
| 41 |
document.getElementById('go').onclick=async()=>{
|
| 42 |
const m=document.getElementById('msg').value;if(!m)return;const n=+document.getElementById('n').value,k=Math.min(+document.getElementById('k').value,n);
|
| 43 |
snake.innerHTML='';document.getElementById('out').style.display='none';
|
| 44 |
-
let prev='0'.repeat(
|
| 45 |
-
return seg(cls,title,
|
| 46 |
-
|
| 47 |
-
await link('','1 ·
|
| 48 |
-
const key=crypto.getRandomValues(new Uint8Array(32))
|
| 49 |
-
const ck=await
|
| 50 |
-
|
| 51 |
-
|
|
|
|
|
|
|
| 52 |
const sh=split(key,n,k);
|
| 53 |
-
for(const S of sh){const d=await link('shard',`
|
| 54 |
-
await link('','
|
| 55 |
-
state={sh,
|
| 56 |
};
|
| 57 |
document.getElementById('re').onclick=async()=>{
|
| 58 |
const out=document.getElementById('out');out.style.display='block';
|
| 59 |
const picked=[...document.querySelectorAll('.shard.picked')].map(d=>state.sh.find(s=>s.x==d.dataset.x));
|
| 60 |
if(picked.length<state.k){out.textContent=`🔒 ${picked.length} shard(s) — need ${state.k}. Still sealed.`;return}
|
| 61 |
-
try{const key=combine(picked);
|
| 62 |
-
|
| 63 |
-
out.textContent='🧩 Rebuilt: '+decodeURIComponent(escape(atob(
|
| 64 |
};
|
| 65 |
</script></body></html>
|
|
|
|
| 1 |
<!doctype html><html><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1">
|
| 2 |
+
<title>SANDSTORM · QUAD A</title>
|
| 3 |
<style>
|
| 4 |
body{margin:0;background:#04060c;color:#f3e2b3;font:14px system-ui;padding:14px;max-width:900px;margin:auto}
|
| 5 |
h1{letter-spacing:4px;font-size:20px;margin:8px 0}
|
|
|
|
| 10 |
#snake{display:flex;flex-wrap:wrap;gap:6px;margin-top:12px}
|
| 11 |
.seg{flex:1 1 200px;background:linear-gradient(135deg,#ffffff14,#7fc4ff10);border:1px solid #9fd3ff55;border-radius:14px;padding:9px;backdrop-filter:blur(4px);word-break:break-all;animation:in .4s ease both}
|
| 12 |
.seg b{color:#fff}.seg small{opacity:.6;display:block}.seg a{color:#7fc4ff}.seg code{font-size:11px;color:#9fe39f}
|
| 13 |
+
.shard{border-color:#d4af3788;cursor:pointer}.shard.picked{outline:2px solid #d4af37}.pkt{border-color:#ff5a5a66}
|
| 14 |
@keyframes in{from{opacity:0;transform:translateY(8px)}to{opacity:1}}
|
| 15 |
#out{margin-top:10px;padding:10px;border-radius:10px;background:#0b1222;display:none}
|
| 16 |
</style></head><body>
|
| 17 |
+
<h1>🌪️ SANDSTORM · QUAD A</h1>
|
| 18 |
<textarea id="msg" placeholder="anything you want wrapped in the storm"></textarea>
|
| 19 |
<div class="row">Shards <select id="n"><option>3</option><option selected>5</option><option>7</option><option>9</option></select>
|
| 20 |
need <select id="k"><option>2</option><option selected>3</option><option>4</option><option>5</option></select> to rebuild
|
|
|
|
| 23 |
<div class="row" id="rb" style="display:none"><span>Tap shards to pick them, then</span><button id="re">🧩 Rebuild</button></div>
|
| 24 |
<div id="out"></div>
|
| 25 |
<script>
|
| 26 |
+
const LAYERS=[{alg:'AES-CTR',name:'Glass 1 · AES-256-CTR'},{alg:'AES-GCM',name:'Glass 2 · AES-256-GCM'},{alg:'AES-CBC',name:'Glass 3 · AES-256-CBC'},{alg:'AES-GCM',name:'Glass 4 · AES-256-GCM'}];
|
| 27 |
+
const TL={aes:'https://github.com/openssl/openssl',sha:'https://github.com/B-Con/crypto-algorithms',shamir:'https://github.com/libtom/libtomcrypt',b64:'https://github.com/libtom/libtomcrypt',chain:'https://monocypher.org'};
|
| 28 |
const enc=new TextEncoder(),dec=new TextDecoder();
|
| 29 |
const hex=b=>[...new Uint8Array(b)].map(x=>x.toString(16).padStart(2,'0')).join('');
|
| 30 |
+
const sha=async b=>hex(await crypto.subtle.digest('SHA-512',b));
|
|
|
|
| 31 |
const EXP=new Uint8Array(512),LOG=new Uint8Array(256);{let x=1;for(let i=0;i<255;i++){EXP[i]=x;LOG[x]=i;const xt=((x<<1)^(x&0x80?0x1b:0))&0xff;x^=xt}for(let i=255;i<512;i++)EXP[i]=EXP[i-255]}
|
| 32 |
const mul=(a,b)=>a&&b?EXP[LOG[a]+LOG[b]]:0,dv=(a,b)=>a?EXP[(LOG[a]+255-LOG[b])%255]:0;
|
| 33 |
function split(sec,n,k){const sh=[...Array(n)].map((_,i)=>({x:i+1,y:new Uint8Array(sec.length)}));
|
| 34 |
sec.forEach((s,bi)=>{const c=[s,...crypto.getRandomValues(new Uint8Array(k-1))];sh.forEach(S=>{let y=0;for(let j=c.length-1;j>=0;j--)y=mul(y,S.x)^c[j];S.y[bi]=y})});return sh}
|
| 35 |
function combine(sh){const L=sh[0].y.length,out=new Uint8Array(L);
|
| 36 |
for(let b=0;b<L;b++){let s=0;sh.forEach((Si,i)=>{let num=1,den=1;sh.forEach((Sj,j)=>{if(i!==j){num=mul(num,Sj.x);den=mul(den,Sj.x^Si.x)}});s^=mul(Si.y[b],dv(num,den))});out[b]=s}return out}
|
| 37 |
+
const params=(L,v)=>L.alg==='AES-CTR'?{name:'AES-CTR',counter:v,length:64}:L.alg==='AES-CBC'?{name:'AES-CBC',iv:v}:{name:'AES-GCM',iv:v.slice(0,12)};
|
| 38 |
+
const ik=(L,raw)=>crypto.subtle.importKey('raw',raw,L.alg,false,['encrypt','decrypt']);
|
| 39 |
let state=null;const snake=document.getElementById('snake');
|
| 40 |
+
function seg(cls,title,url,lab,body,t){const d=document.createElement('div');d.className='seg '+cls;
|
| 41 |
+
d.innerHTML=`<b>${title}</b><small>${new Date(t).toISOString()} · <a href="${url}" target=_blank>${lab}</a></small><code>${body}</code>`;snake.appendChild(d);return d}
|
| 42 |
document.getElementById('go').onclick=async()=>{
|
| 43 |
const m=document.getElementById('msg').value;if(!m)return;const n=+document.getElementById('n').value,k=Math.min(+document.getElementById('k').value,n);
|
| 44 |
snake.innerHTML='';document.getElementById('out').style.display='none';
|
| 45 |
+
let prev='0'.repeat(128);const link=async(cls,title,url,lab,bytes,show)=>{const t=Date.now();const h=await sha(enc.encode(prev+hex(bytes)+t));prev=h;
|
| 46 |
+
return seg(cls,title,url,lab,(show||'')+`<br>🔗 ${h.slice(0,32)}…`,t)};
|
| 47 |
+
let data=enc.encode(btoa(unescape(encodeURIComponent(m))));
|
| 48 |
+
await link('','1 · Twist + braid',TL.b64,'Base64 braid',data,dec.decode(data).slice(0,60));
|
| 49 |
+
const key=crypto.getRandomValues(new Uint8Array(32*LAYERS.length));const ivs=LAYERS.map(()=>crypto.getRandomValues(new Uint8Array(16)));
|
| 50 |
+
for(let i=0;i<LAYERS.length;i++){const L=LAYERS[i];const ck=await ik(L,key.slice(i*32,i*32+32));
|
| 51 |
+
data=new Uint8Array(await crypto.subtle.encrypt(params(L,ivs[i]),ck,data));
|
| 52 |
+
await link('',`${i+2} · ${L.name}`,TL.aes,'own 256-bit key',data,hex(data).slice(0,48)+'…')}
|
| 53 |
+
const P=4,size=Math.ceil(data.length/P),pk=[];
|
| 54 |
+
for(let p=0;p<P;p++){const part=data.slice(p*size,(p+1)*size);pk.push(part);await link('pkt',`6 · Glass packet ${p+1} of ${P}`,TL.sha,'SHA-512 encased',part,hex(part).slice(0,40)+'…')}
|
| 55 |
const sh=split(key,n,k);
|
| 56 |
+
for(const S of sh){const d=await link('shard',`7 · Key shard ${S.x} of ${n}`,TL.shamir,'Shamir k-of-n',S.y,hex(S.y).slice(0,40)+'…');d.dataset.x=S.x;d.onclick=()=>d.classList.toggle('picked')}
|
| 57 |
+
await link('','8 · Snake tail (seal)',TL.chain,'SHA-512 chain',enc.encode(prev),'QUAD A · 1,024-bit key total · any change breaks every link after it');
|
| 58 |
+
state={sh,ivs,pk,k};document.getElementById('rb').style.display='flex';
|
| 59 |
};
|
| 60 |
document.getElementById('re').onclick=async()=>{
|
| 61 |
const out=document.getElementById('out');out.style.display='block';
|
| 62 |
const picked=[...document.querySelectorAll('.shard.picked')].map(d=>state.sh.find(s=>s.x==d.dataset.x));
|
| 63 |
if(picked.length<state.k){out.textContent=`🔒 ${picked.length} shard(s) — need ${state.k}. Still sealed.`;return}
|
| 64 |
+
try{const key=combine(picked);let data=new Uint8Array(state.pk.reduce((a,p)=>a+p.length,0));let o=0;state.pk.forEach(p=>{data.set(p,o);o+=p.length});
|
| 65 |
+
for(let i=LAYERS.length-1;i>=0;i--){const L=LAYERS[i];data=new Uint8Array(await crypto.subtle.decrypt(params(L,state.ivs[i]),await ik(L,key.slice(i*32,i*32+32)),data))}
|
| 66 |
+
out.textContent='🧩 Rebuilt: '+decodeURIComponent(escape(atob(dec.decode(data))));}catch(e){out.textContent='🔒 Wrong shards. Still sealed.'}
|
| 67 |
};
|
| 68 |
</script></body></html>
|