@provenonce/beats-client 0.3.0 → 0.4.0

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 (3) hide show
  1. package/index.d.ts +2 -0
  2. package/index.mjs +8 -1
  3. package/package.json +1 -1
package/index.d.ts CHANGED
@@ -64,6 +64,8 @@ export interface BeatAnchor {
64
64
  difficulty: number;
65
65
  epoch: number;
66
66
  tx_signature: string;
67
+ /** A-4: Finalized Solana blockhash used as external entropy. Present on v2 anchors. */
68
+ solana_entropy?: string;
67
69
  }
68
70
 
69
71
  export interface ReceiptEnvelope {
package/index.mjs CHANGED
@@ -79,7 +79,11 @@ async function verifyEd25519(payload, signatureBase64, publicKey) {
79
79
  * Recompute an anchor's hash from its fields (B-3).
80
80
  * Requires Node.js crypto — not available in browsers.
81
81
  * Returns true if the recomputed hash matches anchor.hash.
82
+ *
83
+ * A-4: If solana_entropy is present, uses the v2 domain-prefixed nonce.
82
84
  */
85
+ const ANCHOR_DOMAIN_PREFIX = 'provenonce:anchor:v2';
86
+
83
87
  async function recomputeAnchorHash(anchor) {
84
88
  if (!anchor || !HEX64.test(anchor.hash) || !HEX64.test(anchor.prev_hash)) return false;
85
89
  if (!Number.isInteger(anchor.beat_index) || anchor.beat_index < 0) return false;
@@ -88,7 +92,10 @@ async function recomputeAnchorHash(anchor) {
88
92
  if (!Number.isInteger(anchor.epoch) || anchor.epoch < 0) return false;
89
93
 
90
94
  const { createHash } = await import('node:crypto');
91
- const nonce = `anchor:${anchor.utc}:${anchor.epoch}`;
95
+ // A-4: v2 nonce includes solana_entropy; legacy nonce for pre-A4 anchors
96
+ const nonce = anchor.solana_entropy
97
+ ? `${ANCHOR_DOMAIN_PREFIX}:${anchor.utc}:${anchor.epoch}:${anchor.solana_entropy}`
98
+ : `anchor:${anchor.utc}:${anchor.epoch}`;
92
99
  const seed = `${anchor.prev_hash}:${anchor.beat_index}:${nonce}`;
93
100
  let current = createHash('sha256').update(seed, 'utf8').digest('hex');
94
101
  for (let i = 0; i < anchor.difficulty; i++) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@provenonce/beats-client",
3
- "version": "0.3.0",
3
+ "version": "0.4.0",
4
4
  "description": "Minimal client for the public Provenonce Beats service",
5
5
  "type": "module",
6
6
  "main": "index.mjs",