@calimero-network/mero-js 33.3.0 → 33.3.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.
@@ -112,10 +112,12 @@ export declare function holderRecoveryBody(holder: BackupHolder, files: ListedRe
112
112
  /** The nonce a node's recovery attestation binds (core's `recovery::attestation_nonce`), hex. */
113
113
  export declare function recoveryAttestationNonce(cluster: string, node: number): Promise<string>;
114
114
  /**
115
- * What a receipt-key quote binds after its nonce (core's `receipt_key_binding`),
116
- * hex: the key and the cluster's governance, as the node serialized it.
115
+ * What a receipt-key quote binds after its nonce (core's `receipt_key_binding`,
116
+ * `receipt-key.v3`), hex: the key, the cluster's governance as the node
117
+ * serialized it, and the cluster (u32-BE length-prefixed) and node id (u64 BE),
118
+ * so one node's quote never stands for another node's or another cluster's.
117
119
  */
118
- export declare function receiptKeyBinding(receiptKey: Uint8Array, governance: unknown): Promise<string>;
120
+ export declare function receiptKeyBinding(receiptKey: Uint8Array, governance: unknown, cluster: string, node: number): Promise<string>;
119
121
  /**
120
122
  * Check that the key that signed `header` is a node's receipt key, attested
121
123
  * (`purpose=receipts`) by a quote `verifyQuote` accepts: attested hardware
@@ -164,12 +164,19 @@ export async function recoveryAttestationNonce(cluster, node) {
164
164
  return hex(await sha256(concat(utf8('calimero.recovery-backup.attest.v1\0'), len, name, id)));
165
165
  }
166
166
  /**
167
- * What a receipt-key quote binds after its nonce (core's `receipt_key_binding`),
168
- * hex: the key and the cluster's governance, as the node serialized it.
167
+ * What a receipt-key quote binds after its nonce (core's `receipt_key_binding`,
168
+ * `receipt-key.v3`), hex: the key, the cluster's governance as the node
169
+ * serialized it, and the cluster (u32-BE length-prefixed) and node id (u64 BE),
170
+ * so one node's quote never stands for another node's or another cluster's.
169
171
  */
170
- export async function receiptKeyBinding(receiptKey, governance) {
172
+ export async function receiptKeyBinding(receiptKey, governance, cluster, node) {
171
173
  const g = await sha256(utf8(JSON.stringify(governance)));
172
- return hex(await sha256(concat(utf8('calimero.tee-attest.receipt-key.v2'), receiptKey, g)));
174
+ const name = utf8(cluster);
175
+ const len = new Uint8Array(4);
176
+ new DataView(len.buffer).setUint32(0, name.length, false);
177
+ const id = new Uint8Array(8);
178
+ new DataView(id.buffer).setBigUint64(0, BigInt(node), false);
179
+ return hex(await sha256(concat(utf8('calimero.tee-attest.receipt-key.v3'), receiptKey, g, len, name, id)));
173
180
  }
174
181
  /**
175
182
  * Check that the key that signed `header` is a node's receipt key, attested
@@ -189,7 +196,7 @@ export async function verifyRecoveryAttestation(header, verifyQuote) {
189
196
  const nonce = await recoveryAttestationNonce(header.cluster, header.node);
190
197
  if (doc.nonce !== nonce)
191
198
  throw new Error('the attestation is not over the recovery nonce');
192
- const reportDataSuffix = await receiptKeyBinding(fromHex(header.signingKey, 'signing key', 32), doc.governance);
199
+ const reportDataSuffix = await receiptKeyBinding(fromHex(header.signingKey, 'signing key', 32), doc.governance, header.cluster, header.node);
193
200
  const ok = await verifyQuote({ quoteB64: doc.quote, nonce, reportDataSuffix });
194
201
  if (!ok)
195
202
  throw new Error('the quote was not accepted');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@calimero-network/mero-js",
3
- "version": "33.3.0",
3
+ "version": "33.3.1",
4
4
  "description": "JavaScript client for Calimero 1.0: attested TEE nodes, a sealed channel, passkeys and API keys",
5
5
  "type": "module",
6
6
  "exports": {