AxiomECC is a bare-metal implementation of Elliptic Curve Cryptography running entirely in vanilla JavaScript. It demonstrates how to perform arbitrary-precision arithmetic and Diffie-Hellman key exchanges without external libraries.
Core Features
- Zero Dependencies: No `crypto.subtle`, no `elliptic.js`, no frameworks.
- Native BigInt: Utilizes ES2020 `BigInt` for 311-bit and 521-bit integer math.
- Visual Engineering: A "Mission Control" style dashboard for inspecting massive parameters.
The Math Under the Hood
1. Modular Inverse
Implemented via the Extended Euclidean Algorithm for finite fields.
function modInverse(a, m) {
let m0 = m, t, q, x0 = 0n, x1 = 1n;
if (m === 1n) return 0n;
while (a > 1n) {
q = a / m; t = m; m = a % m; a = t; t = x0; x0 = x1 - q * x0; x1 = t;
}
return x1 < 0n ? x1 + m0 : x1;
}
2. Scalar Multiplication
Uses the Double-and-Add algorithm for O(log n) performance on Weierstrass curves.
function multiplyPoint(P, scalar, A, p) {
let res = null, base = P, k = scalar;
while (k > 0n) {
if (k % 2n === 1n) res = addPoints(res, base, A, p);
base = addPoints(base, base, A, p);
k /= 2n;
}
return res;
}