@333eco/origin-verify 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/primitives.mjs +2 -2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@333eco/origin-verify",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Checks a B-Origin record with no help from its operator: signatures, its place in the public log, witness cosignatures, RFC 3161 tokens, OpenTimestamps proofs against Bitcoin, and a signer's reveal. Browser or Node, no runtime dependencies.",
5
5
  "license": "CC0-1.0",
6
6
  "author": "Thon Ly",
package/primitives.mjs CHANGED
@@ -64,7 +64,7 @@ export function hmacSha256(key, ...parts) {
64
64
  // ── Ed25519 ──────────────────────────────────────────────────────────────────────────────────────────────────────
65
65
  // RFC 8032 verification by hand, for browsers whose WebCrypto lacks it (Chrome before 137, and the Android floor is Chrome 113).
66
66
  // It handles only public values, so a timing leak gives nothing away.
67
- const P = 2n ** 255n - 19n, L = 2n ** 252n + 27742317777372353535851937790883648493n, D = 37095705934669439343138083508754565189542113879843219016388785533085940283555n, I = 19681161376707505956807079304988542015446066515923890162744021073123829784752n;
67
+ const P = (1n << 255n) - 19n, L = (1n << 252n) + 27742317777372353535851937790883648493n, D = 37095705934669439343138083508754565189542113879843219016388785533085940283555n, I = 19681161376707505956807079304988542015446066515923890162744021073123829784752n;
68
68
  const mod = (a, m = P) => { const r = a % m; return r < 0n ? r + m : r; };
69
69
  const pow = (b, e, m = P) => { let r = 1n; b = mod(b, m); while (e > 0n) { if (e & 1n) r = (r * b) % m; b = (b * b) % m; e >>= 1n; } return r; };
70
70
  const addPt = ([x1, y1, z1, t1], [x2, y2, z2, t2]) => {
@@ -75,7 +75,7 @@ const mulPt = (s, pt) => { let q = [0n, 1n, 1n, 0n]; while (s > 0n) { if (s & 1n
75
75
  const leInt = (b) => { let n = 0n; for (let i = b.length - 1; i >= 0; i--) n = (n << 8n) + BigInt(b[i]); return n; };
76
76
  function decodePt(b) {
77
77
  if (b.length !== 32) return null;
78
- const y = leInt(b) & (2n ** 255n - 1n), sign = b[31] >> 7;
78
+ const y = leInt(b) & ((1n << 255n) - 1n), sign = b[31] >> 7;
79
79
  if (y >= P) return null;
80
80
  const y2 = mod(y * y), u = mod(y2 - 1n), v = mod(D * y2 + 1n);
81
81
  let x = pow(mod(u * pow(v, P - 2n)), (P + 3n) / 8n);