@quantovainc/qcore 0.2.1 → 0.2.3

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quantovainc/qcore",
3
- "version": "0.2.1",
3
+ "version": "0.2.3",
4
4
  "description": "Quantova's post quantum client core for JavaScript. Signs with ML-DSA-65 and builds Q1 addresses.",
5
5
  "scripts": {
6
6
  "build": "bash scripts/build.sh",
package/pkg/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "qcore-js",
3
3
  "type": "module",
4
4
  "description": "The JavaScript binding for the Quantova client core, generated over QCore with wasm-bindgen. The core does the key derivation, the post quantum signing, and the wire, the page does the fetch.",
5
- "version": "0.2.1",
5
+ "version": "0.2.3",
6
6
  "license": "Apache-2.0 OR MIT",
7
7
  "repository": {
8
8
  "type": "git",
Binary file
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "qcore-js",
3
3
  "description": "The JavaScript binding for the Quantova client core, generated over QCore with wasm-bindgen. The core does the key derivation, the post quantum signing, and the wire, the page does the fetch.",
4
- "version": "0.2.1",
4
+ "version": "0.2.3",
5
5
  "license": "Apache-2.0 OR MIT",
6
6
  "repository": {
7
7
  "type": "git",
Binary file
package/shared.js CHANGED
@@ -63,6 +63,7 @@ const VALIDITY_BLOCKS = 300n;
63
63
  const MAX_PLAUSIBLE_HEAD = 1n << 40n;
64
64
  const HEAD_BLOCKS_PER_SEC = 4n;
65
65
  const HEAD_SLACK_SECS = 60n;
66
+ const GENESIS_FLOOR_SECS = 1735689600n;
66
67
  const U64_MAX = 0xffffffffffffffffn;
67
68
  const U128_MAX = (1n << 128n) - 1n;
68
69
 
@@ -435,9 +436,6 @@ function makeClient(core) {
435
436
  const next = BigInt(used) + 1n;
436
437
  const local = this._nextNonces.get(key);
437
438
  if (local == null || local < next) this._nextNonces.set(key, next);
438
- } else if (verdict === 'rejected') {
439
- const held = this._signedNonces && this._signedNonces.get(key);
440
- if (held) held.delete(String(used));
441
439
  }
442
440
  }
443
441
 
@@ -445,6 +443,10 @@ function makeClient(core) {
445
443
  const until = validUntil(info);
446
444
  const head = until - VALIDITY_BLOCKS;
447
445
  const now = BigInt(Math.floor(Date.now() / 1000));
446
+ if (now > GENESIS_FLOOR_SECS) {
447
+ const maxHead = (now - GENESIS_FLOOR_SECS + HEAD_SLACK_SECS) * HEAD_BLOCKS_PER_SEC;
448
+ if (head > maxHead) throw new Error(`the gateway reports head ${head} further ahead than wall-clock time allows, refusing to sign`);
449
+ }
448
450
  if (this._headFloor) {
449
451
  const { height, at } = this._headFloor;
450
452
  if (head < height) throw new Error(`the gateway reports head ${head} below the ${height} it reported earlier, refusing to sign`);
package/shared.mjs CHANGED
@@ -63,6 +63,7 @@ const VALIDITY_BLOCKS = 300n;
63
63
  const MAX_PLAUSIBLE_HEAD = 1n << 40n;
64
64
  const HEAD_BLOCKS_PER_SEC = 4n;
65
65
  const HEAD_SLACK_SECS = 60n;
66
+ const GENESIS_FLOOR_SECS = 1735689600n;
66
67
  const U64_MAX = 0xffffffffffffffffn;
67
68
  const U128_MAX = (1n << 128n) - 1n;
68
69
 
@@ -435,9 +436,6 @@ function makeClient(core) {
435
436
  const next = BigInt(used) + 1n;
436
437
  const local = this._nextNonces.get(key);
437
438
  if (local == null || local < next) this._nextNonces.set(key, next);
438
- } else if (verdict === 'rejected') {
439
- const held = this._signedNonces && this._signedNonces.get(key);
440
- if (held) held.delete(String(used));
441
439
  }
442
440
  }
443
441
 
@@ -445,6 +443,10 @@ function makeClient(core) {
445
443
  const until = validUntil(info);
446
444
  const head = until - VALIDITY_BLOCKS;
447
445
  const now = BigInt(Math.floor(Date.now() / 1000));
446
+ if (now > GENESIS_FLOOR_SECS) {
447
+ const maxHead = (now - GENESIS_FLOOR_SECS + HEAD_SLACK_SECS) * HEAD_BLOCKS_PER_SEC;
448
+ if (head > maxHead) throw new Error(`the gateway reports head ${head} further ahead than wall-clock time allows, refusing to sign`);
449
+ }
448
450
  if (this._headFloor) {
449
451
  const { height, at } = this._headFloor;
450
452
  if (head < height) throw new Error(`the gateway reports head ${head} below the ${height} it reported earlier, refusing to sign`);