iod-ecc-auth / index.html
greatkoko's picture
Update index.html
d9242b4 verified
Raw History Blame Contribute Delete
37.8 kB
<!doctype html>
<html lang="en">
<head>
<!-- Google Analytics (GA4) - HF Spaces 공통 -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-NH9V300E0S"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
var spaceName = location.hostname
.replace(/\.static\.hf\.space$/, '')
.replace(/\.hf\.space$/, '')
.replace(/^greatkoko-/, '');
gtag('config', 'G-NH9V300E0S', {
cookie_flags: 'SameSite=None;Secure',
space_name: spaceName
});
</script>
<!-- End Google Analytics -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="color-scheme" content="light">
<title>Military IoD Authentication</title>
<meta name="description" content="Interactive walkthrough of an ECC-based authentication protocol for the military Internet of Drones (Choe & Kang, IEEE Access 2025).">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link href="https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;500;600&family=Inter:wght@400;500;600;700&display=swap" rel="stylesheet">
<style>
:root{
--bg:#ffffff; --panel:#ffffff; --panel2:#f5f7fa; --line:#e2e7ee; --ink:#18212d; --muted:#5f6b7b;
--ca:#7c3aed; --drone:#2563eb; --soldier:#16a34a; --atk:#dc2626; --amber:#b45309; --ok:#15803d; --bad:#dc2626;
}
*{box-sizing:border-box;margin:0;padding:0}
body{background:var(--bg);color:var(--ink);font-family:Inter,system-ui,sans-serif;line-height:1.55;font-size:15px}
.wrap{max-width:1180px;margin:0 auto;padding:0 18px}
.mono{font-family:"IBM Plex Mono",monospace}
a{color:#2563eb}
header{padding:44px 0 26px;border-bottom:1px solid var(--line)}
.kicker{font-family:"IBM Plex Mono",monospace;font-size:12px;letter-spacing:.14em;color:var(--amber);text-transform:uppercase}
h1{font-size:clamp(26px,4.2vw,40px);line-height:1.15;margin:10px 0 8px;font-weight:700;letter-spacing:-.01em}
.sub{color:var(--muted);max-width:860px}
.hbtns{margin-top:16px;display:flex;flex-wrap:wrap;gap:8px}
.btn{font:600 14px Inter,sans-serif;border:1px solid var(--line);background:var(--panel2);color:var(--ink);padding:8px 14px;border-radius:6px;cursor:pointer;text-decoration:none;display:inline-block}
.btn:hover{border-color:#b6c0ce}
.btn.primary{background:var(--drone);border-color:var(--drone);color:#fff}
.btn:disabled{opacity:.5;cursor:default}
section{padding:30px 0;border-bottom:1px solid var(--line)}
h2{font-size:20px;margin-bottom:6px}
.lead{color:var(--muted);margin-bottom:18px;max-width:880px}
.label{font-family:"IBM Plex Mono",monospace;font-size:12px;color:var(--muted);letter-spacing:.12em;text-transform:uppercase;margin-bottom:8px}
.card{background:var(--panel);border:1px solid var(--line);border-radius:10px;padding:16px;box-shadow:0 1px 2px rgba(16,24,40,.04)}
/* architecture */
.arch{display:grid;grid-template-columns:1.2fr 1fr;gap:18px;align-items:start}
svg text{font-family:Inter,sans-serif}
.segs{display:grid;gap:10px}
.seg{border-left:3px solid var(--line);padding:8px 12px;background:var(--panel2);border-radius:0 8px 8px 0}
.seg b{display:block;font-size:14px}
.seg span{color:var(--muted);font-size:13px}
/* protocol */
.tabs{display:flex;gap:6px;flex-wrap:wrap;margin-bottom:14px}
.tab{font:600 13px Inter,sans-serif;padding:8px 14px;border-radius:999px;border:1px solid var(--line);background:var(--panel);color:var(--muted);cursor:pointer}
.tab.on{color:#fff;border-color:var(--drone);background:var(--drone)}
.proto{display:grid;grid-template-columns:300px 1fr;gap:18px}
.ctrl label{display:block;font-size:12px;color:var(--muted);margin:10px 0 5px}
select{width:100%;background:#fff;border:1px solid var(--line);color:var(--ink);border-radius:6px;padding:8px 9px;font:500 13px Inter,sans-serif}
.side .btn{width:100%;margin-top:8px}
.hint{font-size:12px;color:var(--muted);margin-top:8px}
.lanes{display:flex;justify-content:space-between;align-items:center;background:var(--panel);border:1px solid var(--line);border-radius:10px;padding:12px 16px;margin-bottom:12px;position:relative}
.actor{display:flex;align-items:center;gap:8px;font-weight:600;font-size:14px}
.dot{width:12px;height:12px;border-radius:50%}
.wire{flex:1;margin:0 14px;height:2px;background:var(--line);position:relative}
.pkt{position:absolute;top:-6px;width:14px;height:14px;border-radius:3px;background:var(--amber);left:0;opacity:0;transition:left .55s ease,opacity .2s}
.atkbadge{position:absolute;left:50%;top:-24px;transform:translateX(-50%);font:600 11px "IBM Plex Mono",monospace;color:var(--atk);display:none}
.steps{display:grid;gap:10px}
.step{background:var(--panel);border:1px solid var(--line);border-radius:10px;padding:12px 14px;opacity:.45;transition:.25s}
.step.on{opacity:1;border-color:#b6c0ce}
.step.cur{border-color:var(--amber);box-shadow:0 0 0 1px var(--amber) inset}
.step .hd{display:flex;justify-content:space-between;gap:10px;align-items:baseline;flex-wrap:wrap}
.step .hd b{font-size:14px}
.step .ch{font:11px "IBM Plex Mono",monospace;color:var(--muted)}
.msg{font:12px "IBM Plex Mono",monospace;color:var(--amber);margin:6px 0 2px}
.calc{font:12px/1.7 "IBM Plex Mono",monospace;color:#334155;margin-top:6px;word-break:break-all}
.calc .k{color:var(--muted)}
.calc .ok{color:var(--ok)} .calc .bad{color:var(--bad)} .calc .atk{color:var(--atk)}
.result{margin-top:12px;padding:12px 14px;border-radius:10px;font-weight:600;display:none}
.result.ok{display:block;background:#e8f6ee;border:1px solid #a7dcbf;color:var(--ok)}
.result.bad{display:block;background:#fdecec;border:1px solid #f3b4b4;color:var(--bad)}
.result .calc{font-weight:400}
.setup{font:12px/1.7 "IBM Plex Mono",monospace;color:#334155;word-break:break-all}
.setup .k{color:var(--muted)}
details summary{cursor:pointer;color:var(--muted);font-size:13px;margin-top:10px}
/* tables & charts */
.two{display:grid;grid-template-columns:1fr 1fr;gap:18px}
table.sec{border-collapse:collapse;width:100%;font-size:13px}
table.sec th,table.sec td{border-bottom:1px solid var(--line);padding:7px 6px;text-align:center}
table.sec th:first-child,table.sec td:first-child{text-align:left}
table.sec th{color:var(--muted);font-weight:500;font-family:"IBM Plex Mono",monospace;font-size:12px}
table.sec td.y{color:var(--ok)} table.sec td.n{color:var(--bad)}
table.sec .our{background:#eaf1ff}
.bars{display:grid;gap:7px}
.br{display:grid;grid-template-columns:62px 1fr 70px;gap:8px;align-items:center;font-size:12.5px}
.br .nm{font-family:"IBM Plex Mono",monospace;color:var(--muted)}
.br .tr{height:18px;background:var(--panel2);border-radius:4px;overflow:hidden;display:flex}
.br .fl{height:100%}
.br .v{font-family:"IBM Plex Mono",monospace;text-align:right}
.br.our .nm,.br.our .v{color:var(--ink);font-weight:600}
.legend{display:flex;gap:14px;flex-wrap:wrap;font-size:12px;color:var(--muted);margin-top:10px}
.legend i{display:inline-block;width:12px;height:12px;border-radius:2px;vertical-align:-2px;margin-right:5px}
.pv{font:12.5px/1.9 "IBM Plex Mono",monospace}
.pv .t{color:var(--ok)}
.pv h4{font:600 12px Inter,sans-serif;color:var(--muted);text-transform:uppercase;letter-spacing:.08em;margin:10px 0 2px}
.note{font-size:12.5px;color:var(--muted);margin-top:10px}
.scale{display:flex;gap:10px;align-items:center;margin-top:12px;font-size:13px;flex-wrap:wrap}
input[type=range]{accent-color:var(--drone);width:200px}
.cite{font-family:"IBM Plex Mono",monospace;font-size:12.5px;background:var(--panel);border:1px solid var(--line);border-radius:6px;padding:12px}
footer{padding:26px 0 50px;color:var(--muted);font-size:13px}
@media (max-width:900px){
.arch,.proto,.two{grid-template-columns:1fr}
}
</style>
</head>
<body>
<div class="wrap">
<header>
<div class="kicker">IEEE Access · Vol. 13 · 2025 · Interactive explainer</div>
<h1>ECC-Based Authentication for the Military Internet of Drones</h1>
<p class="sub">Every link — soldier to drone, drone to command (CA), drone to drone — gets its own authentication and session key, so a breach on one segment does not spread across the network. This page runs the protocol live in your browser on a real elliptic curve. Based on Hyeon Choe &amp; Dongsu Kang, Korea National Defense University.</p>
<div class="hbtns">
<a class="btn" href="https://doi.org/10.1109/ACCESS.2025.3536014" target="_blank" rel="noopener">Paper (DOI)</a>
<a class="btn" href="https://ieeexplore.ieee.org/document/10857293/" target="_blank" rel="noopener">IEEE Xplore</a>
<a class="btn" href="https://huggingface.co/greatkoko" target="_blank" rel="noopener">More Spaces</a>
</div>
</header>
<section>
<div class="label">// Architecture</div>
<h2>Three segments, three independent keys</h2>
<p class="lead">Keys are issued by the CA over a private channel before deployment. In the field, each segment authenticates with the method that fits its constraints.</p>
<div class="arch">
<div class="card">
<svg viewBox="0 0 560 330" width="100%" role="img" aria-label="CA, drones and soldiers connected by three authenticated segments">
<defs><marker id="ah" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="6" markerHeight="6" orient="auto-start-reverse"><path d="M0,0L10,5L0,10z" fill="#64748b"/></marker></defs>
<!-- CA -->
<rect x="210" y="18" width="140" height="58" rx="10" fill="#f3efff" stroke="#7c3aed"/>
<text x="280" y="43" text-anchor="middle" fill="#18212d" font-weight="600" font-size="15">Command · CA</text>
<text x="280" y="62" text-anchor="middle" fill="#7c3aed" font-size="11">CAK · issues GK, SK</text>
<!-- drones -->
<g>
<circle cx="150" cy="180" r="30" fill="#e8f0ff" stroke="#2563eb"/><text x="150" y="185" text-anchor="middle" fill="#18212d" font-size="13" font-weight="600">Drone A</text>
<circle cx="410" cy="180" r="30" fill="#e8f0ff" stroke="#2563eb"/><text x="410" y="185" text-anchor="middle" fill="#18212d" font-size="13" font-weight="600">Drone B</text>
</g>
<!-- soldier -->
<rect x="85" y="262" width="130" height="46" rx="10" fill="#e8f6ee" stroke="#16a34a"/>
<text x="150" y="290" text-anchor="middle" fill="#18212d" font-size="13" font-weight="600">Soldier device</text>
<!-- links -->
<line x1="160" y1="152" x2="245" y2="80" stroke="#7c3aed" stroke-width="2" marker-end="url(#ah)" marker-start="url(#ah)"/>
<text x="128" y="112" fill="#7c3aed" font-size="11.5">② Drone ↔ CA</text>
<text x="112" y="127" fill="#64748b" font-size="10.5">pre-shared GK · ECDH · UWB</text>
<line x1="183" y1="180" x2="377" y2="180" stroke="#2563eb" stroke-width="2" marker-end="url(#ah)" marker-start="url(#ah)"/>
<text x="280" y="170" text-anchor="middle" fill="#2563eb" font-size="11.5">③ Drone ↔ Drone</text>
<text x="280" y="200" text-anchor="middle" fill="#64748b" font-size="10.5">implicit key · GK + nonce · hashes only</text>
<line x1="150" y1="212" x2="150" y2="258" stroke="#16a34a" stroke-width="2" marker-end="url(#ah)" marker-start="url(#ah)"/>
<text x="162" y="236" fill="#16a34a" font-size="11.5">① Soldier ↔ Drone</text>
<text x="162" y="250" fill="#64748b" font-size="10.5">trust anchor · CA public key</text>
<line x1="400" y1="152" x2="318" y2="80" stroke="#7c3aed" stroke-width="1.5" stroke-dasharray="4 4"/>
<text x="552" y="240" text-anchor="end" fill="#64748b" font-size="10.5">GPS-denied: position via UWB</text>
<text x="552" y="254" text-anchor="end" fill="#64748b" font-size="10.5">(timestamp · hop · AoA)</text>
</svg>
</div>
<div class="segs">
<div class="seg" style="border-color:var(--soldier)"><b>① Soldier ↔ Drone · trust anchor</b><span>Both sides derive the same session key from ephemeral ECC keys plus keys the CA signed with its private key. Only the CA's public key is needed in the field.</span></div>
<div class="seg" style="border-color:var(--ca)"><b>② Drone ↔ CA · group key + ECDH</b><span>The pre-shared group key authenticates the exchange; an ECDH step sets a fresh session key. Hop count and timestamp feed UWB position checks where GPS is unavailable.</span></div>
<div class="seg" style="border-color:var(--drone)"><b>③ Drone ↔ Drone · implicit key</b><span>Hash-only authentication with the group key and timestamps — 8 hash operations per link (≈ 0.456 ms), constant as the swarm grows.</span></div>
<div class="seg" style="border-color:var(--atk)"><b>Threats addressed</b><span>Replay, man-in-the-middle, spoofing, key reuse, clogging (DoS), physical capture, GPS spoofing.</span></div>
</div>
</div>
</section>
<section>
<div class="label">// Live protocol run</div>
<h2>Run the handshake — or attack it</h2>
<p class="lead">Each run uses fresh random values on the secp256k1 curve with SHA-256. Pick an attack to see which check stops it.</p>
<div class="tabs" id="tabs">
<button class="tab on" data-seg="SD">① Soldier ↔ Drone</button>
<button class="tab" data-seg="DC">② Drone ↔ CA</button>
<button class="tab" data-seg="DD">③ Drone ↔ Drone</button>
</div>
<div class="proto">
<aside class="side">
<div class="card ctrl">
<div class="label" style="margin:0">Adversary</div>
<label for="atk">Attack on the public channel</label>
<select id="atk"></select>
<button class="btn primary" id="bNext">Next step ▸</button>
<button class="btn" id="bAll">Run all steps</button>
<button class="btn" id="bReset">↺ New session</button>
<p class="hint" id="atkHint"></p>
<details>
<summary>Setup &amp; registration values</summary>
<div class="setup" id="setup" style="margin-top:8px"></div>
<button class="btn" id="bRekey" style="margin-top:8px">Re-run setup</button>
</details>
</div>
</aside>
<div>
<div class="lanes">
<div class="actor" id="aL"></div>
<div class="wire"><div class="pkt" id="pkt"></div><div class="atkbadge" id="atkBadge">⚠ adversary</div></div>
<div class="actor" id="aR"></div>
</div>
<div class="steps" id="steps"></div>
<div class="result" id="result"></div>
</div>
</div>
</section>
<section>
<div class="label">// Security analysis</div>
<h2>Security features compared</h2>
<p class="lead">From the paper's comparison with related IoD schemes (Table 5). ✓ = provided, ✗ = not provided.</p>
<div class="two">
<div class="card" style="overflow-x:auto">
<table class="sec" id="secTable"></table>
<p class="note" id="secRefs"></p>
</div>
<div class="card pv">
<div class="label" style="margin:0">Formal verification · ProVerif</div>
<h4>Drone ↔ Soldier</h4>
<div>not attacker(SEK) <span class="t">is true</span></div>
<div>inj-event(end_S(SID)) ⇒ inj-event(start_S(SID)) <span class="t">is true</span></div>
<div>inj-event(end_D(GID)) ⇒ inj-event(start_D(GID)) <span class="t">is true</span></div>
<h4>Drone ↔ CA</h4>
<div>not attacker(LK) <span class="t">is true</span></div>
<div>inj-event(end_CA(CAID)) ⇒ inj-event(start_CA(CAID)) <span class="t">is true</span></div>
<div>inj-event(end_D(DID)) ⇒ inj-event(start_D(DID)) <span class="t">is true</span></div>
<h4>Drone ↔ Drone</h4>
<div>not attacker(GK) <span class="t">is true</span></div>
<div>inj-event(end_A(DID_A)) ⇒ inj-event(start_A(DID_A)) <span class="t">is true</span></div>
<div>inj-event(end_B(DID_B)) ⇒ inj-event(start_B(DID_B)) <span class="t">is true</span></div>
<p class="note">Session keys stay secret and every authentication end-event is preceded by a matching start-event. The paper also derives the same goals with BAN logic.</p>
</div>
</div>
</section>
<section>
<div class="label">// Military practicality</div>
<h2>Memory, bandwidth and computation</h2>
<p class="lead">Figures as reported in the paper (Tables 6, 8, 10, 11), assuming 160-bit ECC, SHA-1 and 32-bit IDs / timestamps, with operation times measured on an NXP LPC1788 microcontroller.</p>
<div class="two">
<div class="card">
<div class="label">Drone memory (bits)</div>
<div class="bars" id="memBars"></div>
<p class="note">Drone stores R<sub>G</sub> (320) + GK (160) + GID (32) + DID (32) = 544 bits.</p>
</div>
<div class="card">
<div class="label">Communication per authentication (bits)</div>
<div class="bars" id="comBars"></div>
<div class="legend"><span><i style="background:#2563eb"></i>Drone–Drone</span><span><i style="background:#7c3aed"></i>Drone–CA</span><span><i style="background:#16a34a"></i>Drone–Soldier</span><span><i style="background:#64748b"></i>CA–Soldier</span></div>
</div>
<div class="card">
<div class="label">Computation time (ms)</div>
<div class="bars" id="cmpBars"></div>
<div class="legend"><span><i style="background:#2563eb"></i>Drone side</span><span><i style="background:#16a34a"></i>Soldier (mobile) side</span></div>
</div>
<div class="card">
<div class="label">Drone-to-drone scaling</div>
<p style="font-size:14px">Each drone-to-drone link needs only hash operations, about <b class="mono">0.456 ms</b> per link, so cost grows linearly with the number of links and stays constant per link.</p>
<div class="scale"><span>Links in the swarm</span><input type="range" id="links" min="1" max="1000" value="100"><b class="mono" id="linksV">100</b></div>
<div class="kv mono" style="margin-top:10px;font-size:14px">Total ≈ <b id="linksT" style="color:var(--amber)">45.6 ms</b> of hashing</div>
<p class="note">Operation times used in the paper: point multiplication 72 ms · point addition 0.3 ms · ECC sign 136 ms · verify 214 ms · SHA 0.057 ms · random number 36 ms.</p>
</div>
</div>
</section>
<footer>
<div class="cite">H. Choe and D. Kang, "ECC-Based Authentication Protocol for Military Internet of Drone (IoD): A Holistic Security Framework," IEEE Access, vol. 13, pp. 21503–21519, 2025, doi: 10.1109/ACCESS.2025.3536014.</div>
<p style="margin-top:12px">The live demo uses secp256k1 and SHA-256 via the Web Crypto API for illustration; the paper sizes the protocol for 160-bit ECC and SHA-1. Timestamps, UWB positioning and the adversary are simulated. Interactive companion to our paper, built by the authors (published under CC BY-NC-ND 4.0).</p>
</footer>
</div>
<script>
/* ===================== secp256k1 (BigInt, Jacobian) ===================== */
const P=0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2fn;
const N=0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141n;
const G={x:0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798n,y:0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8n};
const mod=(a,m=P)=>{const r=a%m;return r>=0n?r:r+m;};
function inv(a,m=P){let [o,r]=[mod(a,m),m],[s,t]=[1n,0n];while(r){const q=o/r;[o,r]=[r,o-q*r];[s,t]=[t,s-q*t];}return mod(s,m);}
const J=p=>p?{X:p.x,Y:p.y,Z:1n}:null;
function jdbl(p){ if(!p||p.Y===0n)return null; const {X,Y,Z}=p;
const A=mod(X*X),B=mod(Y*Y),C=mod(B*B),D=mod(2n*(mod((X+B)**2n)-A-C)),E=mod(3n*A),F=mod(E*E);
const X3=mod(F-2n*D),Y3=mod(E*(D-X3)-8n*C),Z3=mod(2n*Y*Z); return {X:X3,Y:Y3,Z:Z3}; }
function jadd(p,q){ if(!p)return q; if(!q)return p;
const Z1Z1=mod(p.Z*p.Z),Z2Z2=mod(q.Z*q.Z),U1=mod(p.X*Z2Z2),U2=mod(q.X*Z1Z1),S1=mod(p.Y*q.Z*Z2Z2),S2=mod(q.Y*p.Z*Z1Z1);
if(U1===U2){ return S1===S2?jdbl(p):null; }
const H=mod(U2-U1),I=mod((2n*H)**2n),Jj=mod(H*I),r=mod(2n*(S2-S1)),V=mod(U1*I);
const X3=mod(r*r-Jj-2n*V),Y3=mod(r*(V-X3)-2n*S1*Jj),Z3=mod((mod((p.Z+q.Z)**2n)-Z1Z1-Z2Z2)*H); return {X:X3,Y:Y3,Z:Z3}; }
function aff(p){ if(!p)return null; const zi=inv(p.Z),zi2=mod(zi*zi); return {x:mod(p.X*zi2),y:mod(p.Y*zi2*zi)}; }
function mul(k,pt){ k=mod(k,N); let R=null,Q=J(pt); while(k>0n){ if(k&1n)R=jadd(R,Q); Q=jdbl(Q); k>>=1n; } return aff(R); }
function add(a,b){ return aff(jadd(J(a),J(b))); }
const eq=(a,b)=>a&&b&&a.x===b.x&&a.y===b.y;
function rnd(){ const b=new Uint8Array(32); crypto.getRandomValues(b); let v=0n; for(const x of b)v=(v<<8n)|BigInt(x); return mod(v,N-1n)+1n; }
const hex=v=>v.toString(16).padStart(64,'0');
const ser=v=>typeof v==='bigint'?hex(v):(v&&v.x!==undefined)?hex(v.x)+hex(v.y):String(v);
async function H(tag,...parts){ const d=new TextEncoder().encode(tag+'|'+parts.map(ser).join('|')); const h=new Uint8Array(await crypto.subtle.digest('SHA-256',d)); let v=0n; for(const x of h)v=(v<<8n)|BigInt(x); return v; }
const h =(...p)=>H('h',...p).then(v=>mod(v,N));
const h1=(...p)=>H('h1',...p), h2=(...p)=>H('h2',...p);
const xorPt=(k,pt)=>k^pt.x; // GK ⊕ eG : scalar XOR x-coordinate
const sh=v=>{const s=typeof v==='bigint'?hex(v):(v&&v.x!==undefined)?'('+hex(v.x).slice(0,10)+'…, '+hex(v.y).slice(0,6)+'…)':String(v); return typeof v==='bigint'?s.slice(0,12)+'…'+s.slice(-6):s;};
/* ===================== setup & registration ===================== */
let K={};
async function setup(){
const CAK=rnd(), CAKP=mul(CAK,G);
// drone registration
const IDG='GRP-07', NM='M-2025-031', GID=await h(IDG,NM), a=rnd(), RG=mul(a,G);
const GK=mod(a+(await h(GID,RG))*CAK,N);
// soldier registration
const IDS='SOLDIER-1123', Nn=rnd(), SID=await h(IDS,Nn), b=rnd(), RS=mul(b,G);
const SK=mod(b+(await h(SID,RS))*CAK,N);
K={CAK,CAKP,IDG,NM,GID,a,RG,GK,IDS,SID,b,RS,SK,DIDA:'DRONE-A17',DIDB:'DRONE-B04',CAID:'CA-HQ'};
$('setup').innerHTML=[
['CA private key CAK',CAK],['CA public key CAKP = CAK·G',CAKP],
['GID = h(IDG ∥ NM)',GID],['R_G = a·G',RG],['GK = a + h(GID ∥ R_G)·CAK',GK],
['SID = h(IDS ∥ N)',SID],['R_S = b·G',RS],['SK = b + h(SID ∥ R_S)·CAK',SK]
].map(([k,v])=>`<div><span class="k">${k}</span><br>${sh(v)}</div>`).join('');
}
/* ===================== simulated channel ===================== */
const DTS=3; // allowed timestamp difference (s)
let clock=1000;
const now=()=>clock;
function tsOk(ts,t){ return Math.abs(t-ts)<=DTS; }
/* ===================== segments ===================== */
const ATTACKS={
SD:[['none','No attack'],['replay','Replay an old soldier request'],['tamper','Man-in-the-middle: swap X_S in transit'],['imp','Fake drone without a CA-issued GK']],
DC:[['none','No attack'],['replay','Replay an old drone request'],['tamper','Modify eG inside M1'],['imp','Fake drone without GK']],
DD:[['none','No attack'],['replay','Replay Drone A\'s hello'],['tamper','Modify M_Req in transit'],['imp','Rogue drone without GK']]
};
const HINT={none:'Honest run: every check passes and both sides end with the same key.',replay:'The adversary resends a message captured 45 s earlier.',tamper:'The adversary alters a value on the public channel.',imp:'The adversary pretends to be a legitimate node but holds no key issued by the CA.'};
const ACT={SD:[['Soldier','var(--soldier)'],['Drone','var(--drone)']],DC:[['Drone A','var(--drone)'],['CA','var(--ca)']],DD:[['Drone A','var(--drone)'],['Drone B','var(--drone)']]};
const line=(k,v,cls='')=>`<div class="${cls}"><span class="k">${k}</span> ${v}</div>`;
const chk=(name,ok)=>`<div class="${ok?'ok':'bad'}">${ok?'✓':'✗'} ${name}</div>`;
function stepsSD(atk){ const s={};
return [
{t:'Step 1 · Soldier → Drone',ch:'public channel',dir:1,msg:'{ SID, X_S, R_S, TS₁ }',run:async()=>{
s.c=rnd(); s.XS=mul(s.c,G); s.TS1=now(); let out=line('c ←','random')+line('X_S = c·G',sh(s.XS))+line('TS₁ =',s.TS1+' s');
s.rx={SID:K.SID,XS:s.XS,RS:K.RS,TS1:s.TS1};
if(atk==='replay'){ clock+=45; out+=`<div class="atk">⚠ adversary captured this message and replays it 45 s later</div>`; }
if(atk==='tamper'){ s.fake=rnd(); s.rx.XS=mul(s.fake,G); out+=`<div class="atk">⚠ X_S replaced in transit by ${sh(s.rx.XS)}</div>`; }
clock+=0.4; return out; }},
{t:'Step 2 · Drone verifies, derives SEK, replies',ch:'Drone → Soldier · public channel',dir:-1,msg:'{ GID, X_D, R_G, CHK, TS₂ }',run:async()=>{
const r=s.rx, TSC=now(); let out=line('TS_C − TS₁ =',(TSC-r.TS1).toFixed(1)+' s (ΔTS ≤ '+DTS+' s)');
const ok=tsOk(r.TS1,TSC); out+=chk('timestamp fresh',ok); if(!ok) return {out,fail:'Drone rejected the request: the timestamp is outside ΔTS, so the replayed message is discarded.'};
let GK=K.GK, RG=K.RG; if(atk==='imp'){ GK=rnd(); RG=mul(rnd(),G); out+=`<div class="atk">⚠ fake drone uses a self-made GK′ and R_G′ (no CA signature)</div>`; }
s.d=rnd(); s.XD=mul(s.d,G);
const SKP=add(r.RS,mul(await h(r.SID,r.RS),K.CAKP));
const K1=add(mul(GK,r.XS),mul(s.d,SKP)), K2=mul(s.d,r.XS);
s.SEKd=await h(K1,K2); const CHK=await h(s.SEKd,r.XS); s.TS2=now();
out+=line('d ←','random')+line('X_D = d·G',sh(s.XD))+line('SK_P = R_S + h(SID∥R_S)·CAKP',sh(SKP))
+line('K₁ = GK·X_S + d·SK_P',sh(K1))+line('K₂ = d·X_S',sh(K2))+line('SEK = h(K₁∥K₂)',sh(s.SEKd))+line('CHK = h(SEK∥X_S)',sh(CHK));
s.rx2={GID:K.GID,XD:s.XD,RG,CHK,TS2:s.TS2}; s.K1=K1; s.K2=K2; clock+=0.4; return out; }},
{t:'Step 3 · Soldier verifies and derives the same SEK',ch:'local',dir:0,msg:'',run:async()=>{
const r=s.rx2, TSC=now(); let out=chk('timestamp fresh ('+(TSC-r.TS2).toFixed(1)+' s)',tsOk(r.TS2,TSC));
const GKP=add(r.RG,mul(await h(r.GID,r.RG),K.CAKP));
const K3=add(mul(K.SK,r.XD),mul(s.c,GKP)), K4=mul(s.c,r.XD);
const SEKs=await h(K3,K4), CHKs=await h(SEKs,s.XS);
out+=line('GK_P = R_G + h(GID∥R_G)·CAKP',sh(GKP))+line('K₃ = SK·X_D + c·GK_P',sh(K3))+line('K₄ = c·X_D',sh(K4))+line('SEK′ = h(K₃∥K₄)',sh(SEKs));
const ok=CHKs===r.CHK; out+=chk('CHK = h(SEK′∥X_S)',ok);
if(!ok) return {out,fail: atk==='tamper'?'Soldier rejected the reply: the drone built its key from the swapped X_S, so CHK does not match. The man-in-the-middle is detected.':'Soldier rejected the reply: without a GK issued by the CA, the fake drone cannot produce a matching K₁, so CHK fails.'};
return {out,done:`Mutual authentication complete. K₁ = K₃ ${eq(s.K1,K3)?'✓':'✗'} · K₂ = K₄ = c·d·G ${eq(s.K2,K4)?'✓':'✗'}`,key:SEKs}; }}
];
}
function stepsDC(atk){ const s={};
return [
{t:'Step 1 · Drone → CA',ch:'public channel',dir:1,msg:'{ M₁ = (H₁ ⊕ H₂) ∥ DID_A ∥ eG, Hop, TS₁ }',run:async()=>{
let GK=K.GK; if(atk==='imp'){ GK=rnd(); }
s.e=rnd(); s.eG=mul(s.e,G); s.TS1=now(); s.hop=1;
const H1=await h1(xorPt(GK,s.eG)), H2=await h2(GK,K.DIDA,s.TS1), M=H1^H2;
let out=line('e ←','random · Hop = 1')+line('H₁ = h₁(GK ⊕ eG)',sh(H1))+line('H₂ = h₂(GK ∥ DID_A ∥ TS₁)',sh(H2))+line('M₁ = H₁ ⊕ H₂ ∥ DID_A ∥ eG',sh(M));
if(atk==='imp') out=`<div class="atk">⚠ rogue drone computes M₁ with a guessed GK′</div>`+out;
s.rx={M,DID:K.DIDA,eG:s.eG,hop:s.hop,TS1:s.TS1};
if(atk==='replay'){ clock+=45; out+=`<div class="atk">⚠ adversary replays this message 45 s later</div>`; }
if(atk==='tamper'){ s.rx.eG=mul(rnd(),G); out+=`<div class="atk">⚠ eG replaced in transit</div>`; }
clock+=0.4; return out; }},
{t:'Step 2 · CA verifies M₁, checks location, replies',ch:'CA → Drone · public channel',dir:-1,msg:'{ M₂ = (H₃ ⊕ H₄) ∥ fG }',run:async()=>{
const r=s.rx, TSC=now(); let out=chk('timestamp fresh ('+(TSC-r.TS1).toFixed(1)+' s)',tsOk(r.TS1,TSC));
if(!tsOk(r.TS1,TSC)) return {out,fail:'CA discarded the request: the timestamp is outside ΔTS, so the replay is rejected.'};
const exp=(await h1(xorPt(K.GK,r.eG)))^(await h2(K.GK,r.DID,r.TS1)); const ok=exp===r.M;
out+=line('h₁(GK ⊕ eG) ⊕ h₂(GK ∥ DID_A ∥ TS₁)',sh(exp))+chk('M₁ matches',ok);
if(!ok) return {out,fail: atk==='imp'?'CA rejected the drone: M₁ cannot be reproduced without the real group key.':'CA rejected the request: the altered eG changes H₁, so M₁ no longer verifies.'};
const aoa=(37+Math.random()*2).toFixed(1); out+=line('L_A = UWB(TS₁, Hop, AoA, DID_A)','AoA '+aoa+'° · hop 1 · within expected sector')+chk('location consistent (UWB, GPS-independent)',true);
s.f=rnd(); s.fG=mul(s.f,G); s.LKca=mul(s.f,r.eG);
const H3=await h1(xorPt(K.GK,s.fG)), H4=await h2(xorPt(K.GK,r.eG)); s.M2=H3^H4;
out+=line('f ←','random')+line('LK_A = f·(eG)',sh(s.LKca))+line('M₂ = h₁(GK ⊕ fG) ⊕ h₂(GK ⊕ eG) ∥ fG',sh(s.M2));
clock+=0.4; return out; }},
{t:'Step 3 · Drone verifies M₂ and stores LK_A',ch:'local',dir:0,msg:'',run:async()=>{
const H5=await h1(xorPt(K.GK,s.fG)), H6=await h2(xorPt(K.GK,s.eG)); const ok=(H5^H6)===s.M2;
const LKd=mul(s.e,s.fG);
let out=line('H₅ ⊕ H₆',sh(H5^H6))+chk('M₂ matches',ok)+line('LK_A = e·(fG)',sh(LKd));
return {out,done:`Drone and CA share LK_A = e·f·G ${eq(LKd,s.LKca)?'✓':'✗'} (ECDH), authenticated by the group key.`,key:LKd}; }}
];
}
function stepsDD(atk){ const s={};
return [
{t:'Step 1 · Drone A → Drone B',ch:'public channel',dir:1,msg:'{ DID_A, TS₁, M_Hello }',run:async()=>{
let GK=K.GK; if(atk==='imp')GK=rnd();
s.TS1=now(); s.MH=await h1(K.DIDA,s.TS1,GK);
let out=line('M_Hello = h₁(DID_A ∥ TS₁ ∥ GK)',sh(s.MH));
if(atk==='imp') out=`<div class="atk">⚠ rogue drone claims to be DID_A but uses a guessed GK′</div>`+out;
s.rx={DID:K.DIDA,TS1:s.TS1,MH:s.MH};
if(atk==='replay'){ clock+=45; out+=`<div class="atk">⚠ adversary replays this hello 45 s later</div>`; }
clock+=0.4; return out; }},
{t:'Step 2 · Drone B verifies, sends request',ch:'Drone B → Drone A · public channel',dir:-1,msg:'{ DID_B, TS₂, M_Req }',run:async()=>{
const r=s.rx, TSC=now(); const tok=tsOk(r.TS1,TSC); let out=chk('timestamp fresh ('+(TSC-r.TS1).toFixed(1)+' s)',tok);
if(!tok) return {out,fail:'Drone B dropped the hello: the timestamp is stale, so the replay is rejected.'};
const ok=(await h1(r.DID,r.TS1,K.GK))===r.MH; out+=chk('M_Hello = h₁(DID_A ∥ TS₁ ∥ GK)',ok);
if(!ok) return {out,fail:'Drone B rejected the hello: it cannot be reproduced with the real group key, so the rogue drone never enters the routing table.'};
out+=line('routing table','DID_A not present → authenticate');
s.TS2=now(); s.MR=r.MH^(await h1(K.DIDB,s.TS2,K.GK)); s.rx2={DID:K.DIDB,TS2:s.TS2,MR:s.MR};
out+=line('M_Req = M_Hello ⊕ h₁(DID_B ∥ TS₂ ∥ GK)',sh(s.MR));
if(atk==='tamper'){ s.rx2.MR=s.MR^1n; out+=`<div class="atk">⚠ one bit of M_Req flipped in transit</div>`; }
clock+=0.4; return out; }},
{t:'Step 3 · Drone A verifies, sends response',ch:'Drone A → Drone B · public channel',dir:1,msg:'{ DID_A, M_Resp }',run:async()=>{
const r=s.rx2; let out=chk('timestamp fresh ('+(now()-r.TS2).toFixed(1)+' s)',tsOk(r.TS2,now()));
const ok=(s.MH^(await h1(r.DID,r.TS2,K.GK)))===r.MR; out+=chk('M_Req verifies',ok);
if(!ok) return {out,fail:'Drone A rejected the request: the altered M_Req fails the hash check.'};
s.Resp=(await h1(K.DIDA,K.GK))^(await h2(K.GID,K.NM)); out+=line('M_Resp = h₁(DID_A ∥ GK) ⊕ h₂(GID ∥ N_M)',sh(s.Resp));
clock+=0.4; return out; }},
{t:'Step 4 · Drone B verifies and updates routing',ch:'local',dir:0,msg:'',run:async()=>{
const ok=s.Resp===((await h1(K.DIDA,K.GK))^(await h2(K.GID,K.NM)));
return {out:chk('M_Resp verifies',ok)+line('routing table','+ '+K.DIDA),done:'Drone A and Drone B authenticated each other with hash operations only — no point multiplications on this link.'}; }}
];
}
const BUILD={SD:stepsSD,DC:stepsDC,DD:stepsDD};
/* ===================== UI engine ===================== */
const $=id=>document.getElementById(id);
let seg='SD', steps=[], idx=0, busy=false, ended=false;
function fillAttacks(){ $('atk').innerHTML=ATTACKS[seg].map(([v,l])=>`<option value="${v}">${l}</option>`).join(''); }
function newSession(){
clock=1000+Math.floor(Math.random()*100); idx=0; ended=false;
const atk=$('atk').value; steps=BUILD[seg](atk);
const [L,R]=ACT[seg];
$('aL').innerHTML=`<span class="dot" style="background:${L[1]}"></span>${L[0]}`;
$('aR').innerHTML=`${R[0]}<span class="dot" style="background:${R[1]}"></span>`;
$('atkHint').textContent=HINT[atk]; $('atkBadge').style.display=atk==='none'?'none':'block';
$('steps').innerHTML=steps.map((st,i)=>`<div class="step" id="st${i}"><div class="hd"><b>${st.t}</b><span class="ch">${st.ch}</span></div>${st.msg?`<div class="msg">${st.msg}</div>`:''}<div class="calc" id="c${i}"></div></div>`).join('');
$('result').className='result'; $('result').innerHTML='';
$('bNext').disabled=false; $('bAll').disabled=false;
}
const sleep=ms=>new Promise(r=>setTimeout(r,ms));
async function animate(dir){
const p=$('pkt'); if(!dir)return; p.style.transition='none'; p.style.left=dir>0?'0%':'calc(100% - 14px)'; p.style.opacity=1;
await sleep(30); p.style.transition='left .55s ease,opacity .2s'; p.style.left=dir>0?'calc(100% - 14px)':'0%'; await sleep(600); p.style.opacity=0;
}
async function next(){
if(busy||ended||idx>=steps.length)return; busy=true; $('bNext').disabled=$('bAll').disabled=true;
document.querySelectorAll('.step').forEach(e=>e.classList.remove('cur'));
const el=$('st'+idx); el.classList.add('on','cur');
const st=steps[idx]; const res=await st.run();
const r=typeof res==='string'?{out:res}:res;
$('c'+idx).innerHTML=r.out;
await animate(st.dir);
idx++;
if(r.fail){ ended=true; $('result').className='result bad'; $('result').innerHTML='✗ Attack stopped — '+r.fail; }
else if(r.done){ ended=true; $('result').className='result ok'; $('result').innerHTML='✓ '+r.done+(r.key?`<div class="calc">session key ${sh(r.key)}</div>`:''); }
busy=false; if(!ended){$('bNext').disabled=$('bAll').disabled=false;}
}
async function runAll(){ while(!ended&&idx<steps.length){ await next(); await sleep(200); } }
document.querySelectorAll('.tab').forEach(t=>t.onclick=()=>{ if(busy)return; document.querySelectorAll('.tab').forEach(x=>x.classList.toggle('on',x===t)); seg=t.dataset.seg; fillAttacks(); newSession(); });
$('atk').onchange=newSession; $('bNext').onclick=next; $('bAll').onclick=runAll; $('bReset').onclick=newSession;
$('bRekey').onclick=async()=>{ await setup(); newSession(); };
/* ===================== tables & charts (values from the paper) ===================== */
const SEC={cols:['[21]','[22]','[23]','[24]','[25]','Ours'],rows:[
['Insider threat', [0,1,0,1,1,1]],['Spoofing attack',[0,1,0,1,1,1]],['Replay attack',[1,1,1,1,1,1]],
['Clogging attack', [1,1,0,1,1,1]],['Key secrecy',[1,0,0,1,1,1]],['Anonymity',[1,0,1,0,1,1]],
['Physical capture', [1,1,1,1,1,1]],['GPS spoofing',[0,1,0,0,1,1]],['Formal verification',[0,1,1,1,0,1]]]};
$('secTable').innerHTML='<tr><th>Feature</th>'+SEC.cols.map((c,i)=>`<th class="${i===5?'our':''}">${c}</th>`).join('')+'</tr>'+
SEC.rows.map(([n,v])=>`<tr><td>${n}</td>`+v.map((x,i)=>`<td class="${x?'y':'n'} ${i===5?'our':''}">${x?'✓':'✗'}</td>`).join('')+'</tr>').join('');
$('secRefs').textContent='[21] Liu et al. 2019 · [22] Srinivas et al. 2019 · [23] Wazid et al. 2019 · [24] Bera et al. 2020 · [25] Ever 2020 (numbering as in the paper\'s reference list).';
function bars(id,rows,max,fmt){
$(id).innerHTML=rows.map(r=>`<div class="br ${r.our?'our':''}"><span class="nm">${r.n}</span><div class="tr">${r.parts.map(p=>`<div class="fl" style="width:${p.v/max*100}%;background:${p.c}" title="${p.v}"></div>`).join('')}</div><span class="v">${fmt(r.parts.reduce((a,p)=>a+p.v,0))}</span></div>`).join('');
}
const C={dd:'#2563eb',dca:'#7c3aed',ds:'#16a34a',cas:'#64748b'};
bars('memBars',[{n:'[7]',parts:[{v:832,c:'#64748b'}]},{n:'[25]',parts:[{v:864,c:'#64748b'}]},{n:'[26]',parts:[{v:864,c:'#64748b'}]},{n:'[27]',parts:[{v:992,c:'#64748b'}]},{n:'Ours',our:1,parts:[{v:544,c:C.dd}]}],1000,v=>v+' b');
bars('comBars',[
{n:'[7]',parts:[{v:0,c:C.dd},{v:1248,c:C.dca},{v:2304,c:C.ds},{v:1248,c:C.cas}]},
{n:'[25]',parts:[{v:1184,c:C.dd},{v:1824,c:C.dca}]},
{n:'[26]',parts:[{v:352,c:C.dd},{v:1728,c:C.dca},{v:352,c:C.ds},{v:1184,c:C.cas}]},
{n:'[27]',parts:[{v:704,c:C.dca},{v:1440,c:C.ds},{v:608,c:C.cas}]},
{n:'Ours',our:1,parts:[{v:672,c:C.dd},{v:1040,c:C.dca},{v:1568,c:C.ds}]}],4800,v=>v+' b');
(()=>{ const D=[['[7]',997.485,470.013],['[25]',289.656,397.113],['[26]',350.942,145.056],['[27]',936.628,1072.4],['Ours',469.227,432.771]];
$('cmpBars').innerHTML=D.map(([n,d,s])=>`<div class="br ${n==='Ours'?'our':''}"><span class="nm">${n}</span><div style="display:grid;gap:3px"><div class="tr" style="height:10px"><div class="fl" style="width:${d/1100*100}%;background:#2563eb"></div></div><div class="tr" style="height:10px"><div class="fl" style="width:${s/1100*100}%;background:#16a34a"></div></div></div><span class="v" style="font-size:11.5px">${d.toFixed(0)} / ${s.toFixed(0)}</span></div>`).join('');
})();
$('links').oninput=e=>{const n=+e.target.value;$('linksV').textContent=n;$('linksT').textContent=(n*0.456).toFixed(1)+' ms';};
/* ===================== boot ===================== */
fillAttacks();
setup().then(newSession);
</script>
</body>
</html>