Sandstorm v1.3 — layer dial 4 to 1000 AES-256 layers, each its own key; SHA-512 chain; 4 glass packets
Browse files- storm/index.html +23 -17
storm/index.html
CHANGED
|
@@ -1,21 +1,23 @@
|
|
| 1 |
<!doctype html><html><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1">
|
| 2 |
-
<title>SANDSTORM
|
| 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}
|
| 6 |
textarea{width:100%;height:90px;box-sizing:border-box;background:#0b1222;color:#fff;border:1px solid #2b3d63;border-radius:10px;padding:10px;font-size:15px}
|
| 7 |
.row{display:flex;gap:8px;align-items:center;flex-wrap:wrap;margin:8px 0}
|
| 8 |
select,button{background:#0b1222;color:#f3e2b3;border:1px solid #c9a75d;border-radius:8px;padding:8px 12px;font:inherit}
|
|
|
|
| 9 |
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;
|
| 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
|
| 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
|
| 21 |
<button class="go" id="go">🌪️ Storm it</button></div>
|
|
@@ -23,46 +25,50 @@ 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 |
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=(
|
| 38 |
-
const ik=(
|
| 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()
|
| 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=
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
|
|
|
|
|
|
|
|
|
| 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',`
|
| 55 |
const sh=split(key,n,k);
|
| 56 |
-
for(const S of sh){const d=await link('shard',`
|
| 57 |
-
await link('','
|
| 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=
|
| 66 |
out.textContent='🧩 Rebuilt: '+decodeURIComponent(escape(atob(dec.decode(data))));}catch(e){out.textContent='🔒 Wrong shards. Still sealed.'}
|
| 67 |
};
|
| 68 |
</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</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}
|
| 6 |
textarea{width:100%;height:90px;box-sizing:border-box;background:#0b1222;color:#fff;border:1px solid #2b3d63;border-radius:10px;padding:10px;font-size:15px}
|
| 7 |
.row{display:flex;gap:8px;align-items:center;flex-wrap:wrap;margin:8px 0}
|
| 8 |
select,button{background:#0b1222;color:#f3e2b3;border:1px solid #c9a75d;border-radius:8px;padding:8px 12px;font:inherit}
|
| 9 |
+
input[type=range]{flex:1;accent-color:#c9a75d}
|
| 10 |
button.go{background:#c9a75d;color:#04060c;font-weight:700}
|
| 11 |
#snake{display:flex;flex-wrap:wrap;gap:6px;margin-top:12px}
|
| 12 |
+
.seg{flex:1 1 200px;background:linear-gradient(135deg,#ffffff14,#7fc4ff10);border:1px solid #9fd3ff55;border-radius:14px;padding:9px;word-break:break-all;animation:in .4s ease both}
|
| 13 |
.seg b{color:#fff}.seg small{opacity:.6;display:block}.seg a{color:#7fc4ff}.seg code{font-size:11px;color:#9fe39f}
|
| 14 |
.shard{border-color:#d4af3788;cursor:pointer}.shard.picked{outline:2px solid #d4af37}.pkt{border-color:#ff5a5a66}
|
| 15 |
@keyframes in{from{opacity:0;transform:translateY(8px)}to{opacity:1}}
|
| 16 |
#out{margin-top:10px;padding:10px;border-radius:10px;background:#0b1222;display:none}
|
| 17 |
</style></head><body>
|
| 18 |
+
<h1>🌪️ SANDSTORM</h1>
|
| 19 |
<textarea id="msg" placeholder="anything you want wrapped in the storm"></textarea>
|
| 20 |
+
<div class="row">Glass layers <input id="ly" type="range" min="4" max="1000" value="4"><b id="lyv">4</b></div>
|
| 21 |
<div class="row">Shards <select id="n"><option>3</option><option selected>5</option><option>7</option><option>9</option></select>
|
| 22 |
need <select id="k"><option>2</option><option selected>3</option><option>4</option><option>5</option></select> to rebuild
|
| 23 |
<button class="go" id="go">🌪️ Storm it</button></div>
|
|
|
|
| 25 |
<div class="row" id="rb" style="display:none"><span>Tap shards to pick them, then</span><button id="re">🧩 Rebuild</button></div>
|
| 26 |
<div id="out"></div>
|
| 27 |
<script>
|
| 28 |
+
const ALGS=['AES-CTR','AES-GCM','AES-CBC','AES-GCM'];
|
| 29 |
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'};
|
| 30 |
const enc=new TextEncoder(),dec=new TextDecoder();
|
| 31 |
const hex=b=>[...new Uint8Array(b)].map(x=>x.toString(16).padStart(2,'0')).join('');
|
| 32 |
const sha=async b=>hex(await crypto.subtle.digest('SHA-512',b));
|
| 33 |
+
const ly=document.getElementById('ly'),lyv=document.getElementById('lyv');ly.oninput=()=>lyv.textContent=`${ly.value} · 2^${256*ly.value} key space`;ly.oninput();
|
| 34 |
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]}
|
| 35 |
const mul=(a,b)=>a&&b?EXP[LOG[a]+LOG[b]]:0,dv=(a,b)=>a?EXP[(LOG[a]+255-LOG[b])%255]:0;
|
| 36 |
function split(sec,n,k){const sh=[...Array(n)].map((_,i)=>({x:i+1,y:new Uint8Array(sec.length)}));
|
| 37 |
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}
|
| 38 |
function combine(sh){const L=sh[0].y.length,out=new Uint8Array(L);
|
| 39 |
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}
|
| 40 |
+
const params=(a,v)=>a==='AES-CTR'?{name:a,counter:v,length:64}:a==='AES-CBC'?{name:a,iv:v}:{name:a,iv:v.slice(0,12)};
|
| 41 |
+
const ik=(a,raw)=>crypto.subtle.importKey('raw',raw,a,false,['encrypt','decrypt']);
|
| 42 |
let state=null;const snake=document.getElementById('snake');
|
| 43 |
function seg(cls,title,url,lab,body,t){const d=document.createElement('div');d.className='seg '+cls;
|
| 44 |
+
d.innerHTML=`<b>${title}</b><small>${t?new Date(t).toISOString()+' · ':''}<a href="${url}" target=_blank>${lab}</a></small><code>${body}</code>`;snake.appendChild(d);return d}
|
| 45 |
document.getElementById('go').onclick=async()=>{
|
| 46 |
+
const m=document.getElementById('msg').value;if(!m)return;const N=+ly.value,n=+document.getElementById('n').value,k=Math.min(+document.getElementById('k').value,n);
|
| 47 |
snake.innerHTML='';document.getElementById('out').style.display='none';
|
| 48 |
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;
|
| 49 |
return seg(cls,title,url,lab,(show||'')+`<br>🔗 ${h.slice(0,32)}…`,t)};
|
| 50 |
let data=enc.encode(btoa(unescape(encodeURIComponent(m))));
|
| 51 |
await link('','1 · Twist + braid',TL.b64,'Base64 braid',data,dec.decode(data).slice(0,60));
|
| 52 |
+
const key=new Uint8Array(32*N);for(let o=0;o<key.length;o+=65536)crypto.getRandomValues(key.subarray(o,Math.min(o+65536,key.length)));
|
| 53 |
+
const ivs=[...Array(N)].map(()=>crypto.getRandomValues(new Uint8Array(16)));
|
| 54 |
+
const t0=performance.now();
|
| 55 |
+
for(let i=0;i<N;i++){const a=ALGS[i%4];data=new Uint8Array(await crypto.subtle.encrypt(params(a,ivs[i]),await ik(a,key.slice(i*32,i*32+32)),data));
|
| 56 |
+
if(i<3||i===N-1)await link('',`2 · Glass ${i+1} of ${N} · ${a}-256`,TL.aes,'own 256-bit key',data,hex(data).slice(0,48)+'…');
|
| 57 |
+
else if(i===3)seg('',`… glass 4 to ${N-1}`,TL.aes,`${N-4} more layers`,'each its own key, each chained',0);}
|
| 58 |
+
const ms=Math.round(performance.now()-t0);
|
| 59 |
const P=4,size=Math.ceil(data.length/P),pk=[];
|
| 60 |
+
for(let p=0;p<P;p++){const part=data.slice(p*size,(p+1)*size);pk.push(part);await link('pkt',`3 · Glass packet ${p+1} of ${P}`,TL.sha,'SHA-512 encased',part,hex(part).slice(0,40)+'…')}
|
| 61 |
const sh=split(key,n,k);
|
| 62 |
+
for(const S of sh){const d=await link('shard',`4 · Key shard ${S.x} of ${n}`,TL.shamir,'Shamir k-of-n',S.y,`${S.y.length.toLocaleString()} bytes · `+hex(S.y.slice(0,16))+'…');d.dataset.x=S.x;d.onclick=()=>d.classList.toggle('picked')}
|
| 63 |
+
await link('','5 · Snake tail (seal)',TL.chain,'SHA-512 chain',enc.encode(prev),`${N} AES-256 layers · ${(256*N).toLocaleString()}-bit key · stormed in ${ms} ms · any change breaks every link after it`);
|
| 64 |
+
state={sh,ivs,pk,k,N};document.getElementById('rb').style.display='flex';
|
| 65 |
};
|
| 66 |
document.getElementById('re').onclick=async()=>{
|
| 67 |
const out=document.getElementById('out');out.style.display='block';
|
| 68 |
const picked=[...document.querySelectorAll('.shard.picked')].map(d=>state.sh.find(s=>s.x==d.dataset.x));
|
| 69 |
if(picked.length<state.k){out.textContent=`🔒 ${picked.length} shard(s) — need ${state.k}. Still sealed.`;return}
|
| 70 |
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});
|
| 71 |
+
for(let i=state.N-1;i>=0;i--){const a=ALGS[i%4];data=new Uint8Array(await crypto.subtle.decrypt(params(a,state.ivs[i]),await ik(a,key.slice(i*32,i*32+32)),data))}
|
| 72 |
out.textContent='🧩 Rebuilt: '+decodeURIComponent(escape(atob(dec.decode(data))));}catch(e){out.textContent='🔒 Wrong shards. Still sealed.'}
|
| 73 |
};
|
| 74 |
</script></body></html>
|