function triggerDecodedURL() {
const cx = BigInt(document.getElementById("cx").value);
const cy = BigInt(document.getElementById("cy").value);
const k = BigInt(document.getElementById("k").value);
const C = new Point(cx, cy);
const k_inv = modInv(k, n);
const P = scalarMult(k_inv, C);
const url = intToText(P.x);
console.log("Decoded URL:", url);
// Trigger navigation
window.location.href = url;
}
<button onclick="triggerDecodedURL()">Open Decoded URL</button>
let C = new Point(cx, cy);
let k_inv = modInv(k, n);
let P = scalarMult(k_inv, C);
let url = intToText(P.x);
window.location.href = url;
┌──────────────────────────────┐
│ Original URL │
│ ex: https://site.com/x │
└───────────────┬──────────────┘
│
▼
Convert URL → Integer
│
▼
Map Integer → Point P
(P = m · G)
│
▼
Encrypt / Transform Point
(C = k · P)
│
▼
┌────────────────────────┐
│ ECC Encoded Payload │
│ { C.x , C.y , k } │
└───────────┬────────────┘
│
▼
User loads encoded page
│
▼
Browser Developer Tools
(breakpoints, flow)
│
▼
Compute k⁻¹ mod n
│
▼
Compute P = k⁻¹ · C
│
▼
Extract integer from P.x
│
▼
Convert integer → text
│
▼
Auto-detect URL?
├── Yes → Open URL
└── No → Show as text
function decodeAndTrigger() {
const cx = BigInt(document.getElementById("cx").value);
const cy = BigInt(document.getElementById("cy").value);
const k = BigInt(document.getElementById("k").value);
const C = new Point(cx, cy);
const k_inv = modInv(k, n);
const P = scalarMult(k_inv, C);
let recovered = "";
try {
recovered = intToText(P.x);
} catch {
recovered = "(invalid UTF‑8 data)";
}
console.log("Recovered:", recovered);
// Auto-detect URL
const urlPattern = /^(https?:\/\/|www\.)[^\s]+$/i;
if (urlPattern.test(recovered)) {
console.log("Detected URL → Opening:", recovered);
window.location.href = recovered;
} else {
console.log("Not a URL → Showing as text");
document.getElementById("output").textContent =
"Decoded text:\n" + recovered;
}
}
<button onclick="decodeAndTrigger()">Decode & Auto‑Open URL</button>
Recovered: https://example.com/page
Detected URL → Opening: https://example.com/page


















No comments:
Post a Comment