@openzeppelin/miden-multisig-client 0.16.2 → 0.17.0-rc.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 (150) hide show
  1. package/README.md +144 -7
  2. package/dist/account/builder.d.ts.map +1 -1
  3. package/dist/account/builder.js +32 -25
  4. package/dist/account/builder.js.map +1 -1
  5. package/dist/account/builder.test.js +73 -21
  6. package/dist/account/builder.test.js.map +1 -1
  7. package/dist/account/layout.d.ts +31 -0
  8. package/dist/account/layout.d.ts.map +1 -0
  9. package/dist/account/layout.js +31 -0
  10. package/dist/account/layout.js.map +1 -0
  11. package/dist/account/masm/account-components/auth.d.ts +1 -4
  12. package/dist/account/masm/account-components/auth.d.ts.map +1 -1
  13. package/dist/account/masm/account-components/auth.js +36 -53
  14. package/dist/account/masm/account-components/auth.js.map +1 -1
  15. package/dist/account/masm/index.d.ts +0 -1
  16. package/dist/account/masm/index.d.ts.map +1 -1
  17. package/dist/account/masm/index.js +0 -1
  18. package/dist/account/masm/index.js.map +1 -1
  19. package/dist/account/storage.d.ts +4 -0
  20. package/dist/account/storage.d.ts.map +1 -1
  21. package/dist/account/storage.js +9 -20
  22. package/dist/account/storage.js.map +1 -1
  23. package/dist/client.d.ts.map +1 -1
  24. package/dist/client.js +5 -3
  25. package/dist/client.js.map +1 -1
  26. package/dist/client.test.js +68 -15
  27. package/dist/client.test.js.map +1 -1
  28. package/dist/index.d.ts +4 -3
  29. package/dist/index.d.ts.map +1 -1
  30. package/dist/index.js +3 -3
  31. package/dist/index.js.map +1 -1
  32. package/dist/inspector.d.ts +59 -1
  33. package/dist/inspector.d.ts.map +1 -1
  34. package/dist/inspector.js +157 -29
  35. package/dist/inspector.js.map +1 -1
  36. package/dist/inspector.test.js +246 -37
  37. package/dist/inspector.test.js.map +1 -1
  38. package/dist/multisig.d.ts +106 -32
  39. package/dist/multisig.d.ts.map +1 -1
  40. package/dist/multisig.js +289 -95
  41. package/dist/multisig.js.map +1 -1
  42. package/dist/multisig.test.js +581 -58
  43. package/dist/multisig.test.js.map +1 -1
  44. package/dist/procedures.d.ts +6 -7
  45. package/dist/procedures.d.ts.map +1 -1
  46. package/dist/procedures.js +6 -7
  47. package/dist/procedures.js.map +1 -1
  48. package/dist/proposal/metadata.d.ts.map +1 -1
  49. package/dist/proposal/metadata.js +13 -2
  50. package/dist/proposal/metadata.js.map +1 -1
  51. package/dist/proposal/metadata.test.js +57 -0
  52. package/dist/proposal/metadata.test.js.map +1 -1
  53. package/dist/prover/workflow.d.ts +3 -2
  54. package/dist/prover/workflow.d.ts.map +1 -1
  55. package/dist/prover/workflow.js +5 -2
  56. package/dist/prover/workflow.js.map +1 -1
  57. package/dist/prover/workflow.test.js +6 -4
  58. package/dist/prover/workflow.test.js.map +1 -1
  59. package/dist/transaction/index.d.ts +1 -1
  60. package/dist/transaction/index.d.ts.map +1 -1
  61. package/dist/transaction/index.js +1 -1
  62. package/dist/transaction/index.js.map +1 -1
  63. package/dist/transaction/p2id.d.ts +17 -6
  64. package/dist/transaction/p2id.d.ts.map +1 -1
  65. package/dist/transaction/p2id.js +22 -31
  66. package/dist/transaction/p2id.js.map +1 -1
  67. package/dist/transaction/p2id.test.js +62 -24
  68. package/dist/transaction/p2id.test.js.map +1 -1
  69. package/dist/transaction/summary.d.ts +45 -2
  70. package/dist/transaction/summary.d.ts.map +1 -1
  71. package/dist/transaction/summary.js +42 -2
  72. package/dist/transaction/summary.js.map +1 -1
  73. package/dist/transaction/summary.test.d.ts +2 -0
  74. package/dist/transaction/summary.test.d.ts.map +1 -0
  75. package/dist/transaction/summary.test.js +26 -0
  76. package/dist/transaction/summary.test.js.map +1 -0
  77. package/dist/transaction/updateGuardian.d.ts.map +1 -1
  78. package/dist/transaction/updateGuardian.js +16 -18
  79. package/dist/transaction/updateGuardian.js.map +1 -1
  80. package/dist/transaction/updateProcedureThreshold.d.ts.map +1 -1
  81. package/dist/transaction/updateProcedureThreshold.js +15 -17
  82. package/dist/transaction/updateProcedureThreshold.js.map +1 -1
  83. package/dist/transaction/updateSigners.d.ts +6 -1
  84. package/dist/transaction/updateSigners.d.ts.map +1 -1
  85. package/dist/transaction/updateSigners.js +20 -17
  86. package/dist/transaction/updateSigners.js.map +1 -1
  87. package/dist/transaction.d.ts +2 -2
  88. package/dist/transaction.d.ts.map +1 -1
  89. package/dist/transaction.js +1 -1
  90. package/dist/transaction.js.map +1 -1
  91. package/dist/types/proposal.d.ts +28 -4
  92. package/dist/types/proposal.d.ts.map +1 -1
  93. package/dist/types/proposal.js +18 -0
  94. package/dist/types/proposal.js.map +1 -1
  95. package/dist/types.d.ts +0 -1
  96. package/dist/types.d.ts.map +1 -1
  97. package/dist/utils/signature.d.ts +11 -7
  98. package/dist/utils/signature.d.ts.map +1 -1
  99. package/dist/utils/signature.js +24 -58
  100. package/dist/utils/signature.js.map +1 -1
  101. package/dist/utils/word.d.ts +7 -0
  102. package/dist/utils/word.d.ts.map +1 -1
  103. package/dist/utils/word.js +15 -0
  104. package/dist/utils/word.js.map +1 -1
  105. package/masm/account_components/auth/guarded_multisig.masm +42 -0
  106. package/package.json +7 -4
  107. package/src/account/builder.test.ts +111 -45
  108. package/src/account/builder.ts +45 -33
  109. package/src/account/layout.ts +33 -0
  110. package/src/account/masm/account-components/auth.ts +36 -56
  111. package/src/account/masm/index.ts +0 -1
  112. package/src/account/storage.ts +9 -22
  113. package/src/client.test.ts +80 -15
  114. package/src/client.ts +5 -3
  115. package/src/index.ts +26 -1
  116. package/src/inspector.test.ts +330 -38
  117. package/src/inspector.ts +196 -33
  118. package/src/multisig.test.ts +679 -63
  119. package/src/multisig.ts +361 -107
  120. package/src/procedures.ts +6 -7
  121. package/src/proposal/metadata.test.ts +76 -0
  122. package/src/proposal/metadata.ts +13 -2
  123. package/src/prover/workflow.test.ts +9 -4
  124. package/src/prover/workflow.ts +15 -3
  125. package/src/transaction/index.ts +7 -1
  126. package/src/transaction/p2id.test.ts +112 -31
  127. package/src/transaction/p2id.ts +39 -38
  128. package/src/transaction/summary.test.ts +32 -0
  129. package/src/transaction/summary.ts +83 -4
  130. package/src/transaction/updateGuardian.ts +15 -25
  131. package/src/transaction/updateProcedureThreshold.ts +13 -29
  132. package/src/transaction/updateSigners.ts +38 -30
  133. package/src/transaction.ts +8 -1
  134. package/src/types/proposal.ts +43 -4
  135. package/src/types.ts +0 -1
  136. package/src/utils/signature.ts +32 -65
  137. package/src/utils/word.ts +17 -0
  138. package/dist/account/masm/auth.d.ts +0 -5
  139. package/dist/account/masm/auth.d.ts.map +0 -1
  140. package/dist/account/masm/auth.js +0 -1509
  141. package/dist/account/masm/auth.js.map +0 -1
  142. package/masm/account_components/auth/multisig.masm +0 -12
  143. package/masm/account_components/auth/multisig_ecdsa.masm +0 -12
  144. package/masm/account_components/auth/multisig_guardian.masm +0 -16
  145. package/masm/account_components/auth/multisig_guardian_ecdsa.masm +0 -16
  146. package/masm/auth/guardian.masm +0 -199
  147. package/masm/auth/guardian_ecdsa.masm +0 -195
  148. package/masm/auth/multisig.masm +0 -554
  149. package/masm/auth/multisig_ecdsa.masm +0 -554
  150. package/src/account/masm/auth.ts +0 -1512
package/README.md CHANGED
@@ -17,9 +17,30 @@ Miden multisig accounts store their authentication logic on-chain, but **their s
17
17
  ## Installation
18
18
 
19
19
  ```bash
20
- npm install @openzeppelin/miden-multisig-client @miden-sdk/miden-sdk
20
+ npm install @openzeppelin/miden-multisig-client @miden-sdk/miden-sdk@0.16.0-rc.3
21
21
  ```
22
22
 
23
+ > **Why the peer version is exact**: no stable `0.16.0` is published, so a
24
+ > `0.16.x`/`^0.16.0` range resolves to nothing, and the transaction-summary
25
+ > layout and procedure roots are only byte-compatible within one pre-release
26
+ > pair. Package releases wait for upstream 0.16 to stabilize.
27
+
28
+ ## Miden compatibility
29
+
30
+ This package's version and Miden's are **not** aligned. Pick the release that
31
+ matches your Miden node:
32
+
33
+ | This package | Miden protocol |
34
+ |---|---|
35
+ | 0.17.x | 0.16.x (pre-release) |
36
+ | 0.16.x | 0.15.x |
37
+ | 0.15.x | 0.15.x |
38
+
39
+ Adopting a new Miden line has twice required an irreversible reset of
40
+ Guardian-stored account data, so an upgrade is not a drop-in. Full matrix, the
41
+ breaking changes per line, and what each upgrade does to stored data:
42
+ [MIDEN_COMPATIBILITY.md](https://github.com/OpenZeppelin/guardian/blob/main/docs/MIDEN_COMPATIBILITY.md).
43
+
23
44
  ## Setup
24
45
 
25
46
  ```typescript
@@ -139,6 +160,47 @@ The configuration is automatically detected from the account's on-chain storage:
139
160
  const multisig = await client.load(accountId, signer);
140
161
  ```
141
162
 
163
+ ### Read Signer Public-Key Commitments
164
+
165
+ Since accounts use the upstream `AuthGuardedMultisig` component, the Miden
166
+ SDK's `Account.getPublicKeyCommitments()` returns the approver commitments
167
+ natively. The `AccountInspector` accessors are the strict, layout-insulated
168
+ alternative (issue #306): they validate the complete set against the
169
+ configured signer count and throw instead of silently omitting unreadable
170
+ entries, and they shield consumers from storage-layout changes across
171
+ contract versions.
172
+
173
+ Holding only a fetched Miden SDK `Account` (e.g. a wallet or dApp):
174
+
175
+ ```typescript
176
+ import { AccountInspector } from '@openzeppelin/miden-multisig-client';
177
+
178
+ const commitments = AccountInspector.getSignerPublicKeyCommitments(account);
179
+ const guardianKey = AccountInspector.getGuardianPublicKeyCommitment(account);
180
+ ```
181
+
182
+ Or from a loaded `Multisig` instance (reads current store-backed state):
183
+
184
+ ```typescript
185
+ const signerKeys = await multisig.getSignerPublicKeyCommitments();
186
+ ```
187
+
188
+ Commitments are ordered by signer index as currently stored; indices re-pack
189
+ when signers are removed, so index 0 is the key listed first at creation (by
190
+ convention the creating client's own key) only until the first membership
191
+ change. Hot/cold roles are a consumer-side convention, not part of on-chain
192
+ state. `getSignerPublicKeyCommitments` throws rather than silently returning
193
+ a truncated list when any signer entry is absent; `getGuardianPublicKeyCommitment`
194
+ throws when the guardian entry is missing (the guarded-multisig always
195
+ includes a guardian). Both are gated on this SDK's pinned contract version
196
+ and reject accounts built from a different miden-standards release.
197
+
198
+ The `Account` passed to `AccountInspector` must come from the same copy of
199
+ `@miden-sdk/miden-sdk` that this package links. An application bundling its
200
+ own SDK copy (common in wallets) will get a descriptive error from the SDK's
201
+ instance checks; construct the account with this package's SDK instance
202
+ instead.
203
+
142
204
  ### Recover An Account By Key
143
205
 
144
206
  When the wallet only holds a signing key from the account's authorization
@@ -179,18 +241,52 @@ console.log('Commitment:', state.commitment);
179
241
  console.log('Created:', state.createdAt);
180
242
  ```
181
243
 
244
+ ### Creating Proposals
245
+
246
+ Every `create*Proposal` method takes its required arguments followed by a
247
+ single optional options object (issue #387) — there are no positional
248
+ optional parameters:
249
+
250
+ ```typescript
251
+ createP2idProposal(recipientId, faucetId, amount, { nonce, noteType, reclaimHeight, timelockHeight }?)
252
+ createConsumeNotesProposal(noteIds, { nonce }?)
253
+ createAddSignerProposal(commitment, { nonce, newThreshold }?)
254
+ createRemoveSignerProposal(commitment, { nonce, newThreshold }?)
255
+ createChangeThresholdProposal(threshold, { nonce }?)
256
+ createUpdateProcedureThresholdProposal(procedure, threshold, { nonce }?)
257
+ createSwitchGuardianProposal(endpoint, pubkey, { nonce }?)
258
+ createCustomProposal(requestBytes, label, { nonce }?)
259
+ ```
260
+
261
+ All methods accept `nonce` (identifies the proposal; defaults to
262
+ `Date.now()`). `newThreshold` defaults to the current threshold on add and to
263
+ the min of the current threshold and the remaining signer count on remove.
264
+ The option shapes are exported as `CreateProposalOptions`,
265
+ `CreateSignerProposalOptions`, and `CreateP2idProposalOptions`.
266
+
267
+ > **Breaking change (issue #387):** these methods previously took `nonce` (and
268
+ > `newThreshold`) as positional parameters. Passing the old positional form
269
+ > now throws at runtime instead of silently applying defaults.
270
+
182
271
  ### Create a Proposal (Add Signer)
183
272
 
184
273
  ```typescript
185
274
  // Create a proposal to add a new signer
186
275
  const proposal = await multisig.createAddSignerProposal(
187
276
  newSignerCommitment, // Commitment of signer to add
188
- undefined,
189
- 3,
277
+ { newThreshold: 3 }, // Options: nonce, newThreshold
190
278
  );
191
279
  console.log('Proposal ID:', proposal.id);
192
280
  ```
193
281
 
282
+ Per-procedure threshold overrides are absolute signature counts and are never
283
+ re-scaled on-chain, so growing the signer set silently lowers every override's
284
+ effective signing ratio (a 2-of-2 override becomes 2-of-n).
285
+ `createAddSignerProposal` logs a `console.warn` per affected override, and
286
+ `multisig.overridesDilutedBySignerGrowth(newNumSigners)` returns them for UIs
287
+ that want to prompt before proposing. Raise the affected overrides via an
288
+ update-procedure-threshold proposal alongside the growth.
289
+
194
290
  ### Sign a Proposal
195
291
 
196
292
  ```typescript
@@ -226,6 +322,26 @@ const status = await multisig.abandonStatus(nonce);
226
322
  // 'waiting' | 'landed' | 'abandoned' | 'unexpected'
227
323
  ```
228
324
 
325
+ ### Delta History
326
+
327
+ Render the account's confirmed history after recovery. One page
328
+ per call, newest-first by nonce, with server-decoded note summaries:
329
+
330
+ ```typescript
331
+ let cursor: string | undefined;
332
+ do {
333
+ const page = await multisig.deltaHistory({ limit: 50, cursor });
334
+ for (const entry of page.entries) {
335
+ console.log(entry.nonce, entry.timestamp, entry.outputNotes);
336
+ }
337
+ cursor = page.nextCursor;
338
+ } while (cursor !== undefined);
339
+ ```
340
+
341
+ Only canonical (confirmed) deltas appear — pending proposals live on
342
+ `syncProposals()` — and only transactions pushed through Guardian are
343
+ visible to it.
344
+
229
345
  ### Check Proposal Status
230
346
 
231
347
  Returns cached proposals without making a network request:
@@ -292,8 +408,11 @@ import { buildP2idTransactionRequest } from '@openzeppelin/miden-multisig-client
292
408
  // The options object accepts `noteType` (`NoteType.Public` (default) or
293
409
  // `NoteType.Private`, from `@miden-sdk/miden-sdk`); a private note publishes
294
410
  // only its hash on chain, so the recipient needs the note shared out-of-band.
295
- // The typed path is `createP2idProposal(recipient, faucet, amount, nonce?,
296
- // { noteType })`, which persists the choice in signed metadata.
411
+ // It also accepts `reclaimHeight`/`timelockHeight` (absolute block heights,
412
+ // issue #366); presence of either builds a P2IDE note instead of plain P2ID.
413
+ // The typed path is `createP2idProposal(recipient, faucet, amount,
414
+ // { nonce, noteType, reclaimHeight, timelockHeight })`, which persists the
415
+ // choices in signed metadata.
297
416
  const { request, salt } = buildP2idTransactionRequest(senderId, recipientId, faucetId, amount);
298
417
  const proposal = await multisig.createCustomProposal(request.serialize(), 'b2agg');
299
418
 
@@ -305,11 +424,13 @@ const proposal = await multisig.createCustomProposal(request.serialize(), 'b2agg
305
424
  const advice = await multisig.prepareCustomExecution(proposal.id, request.serialize());
306
425
 
307
426
  // The browser TransactionRequest is immutable, so rebuild from the same recipe
308
- // (inputs + salt) with the advice, then submit.
427
+ // (inputs + salt) with the advice, then submit. `submitTransaction` takes the
428
+ // proposal id to execute at the proposal's anchored reference block, since the
429
+ // collected signatures only authorize the summary produced there.
309
430
  const { request: finalRequest } = buildP2idTransactionRequest(
310
431
  senderId, recipientId, faucetId, amount, { salt, signatureAdviceMap: advice },
311
432
  );
312
- await multisig.submitTransaction(finalRequest);
433
+ await multisig.submitTransaction(proposal.id, finalRequest);
313
434
  ```
314
435
 
315
436
  The integration keeps only its own recipe (build inputs + salt) so it can
@@ -317,6 +438,22 @@ reproduce the exact transaction at execute time — the SDK does not store the
317
438
  serialized request. The binding check guarantees the rebuilt transaction matches the
318
439
  commitment the cosigners signed.
319
440
 
441
+ If a recipe was not retained, recover the salt from the proposal's transaction
442
+ summary with `summarySalt`:
443
+
444
+ ```typescript
445
+ import { summarySalt } from '@openzeppelin/miden-multisig-client';
446
+ import { TransactionSummary } from '@miden-sdk/miden-sdk';
447
+
448
+ const salt = summarySalt(TransactionSummary.deserialize(bytes));
449
+ ```
450
+
451
+ On the Miden 0.16 pre-release line a summary no longer carries a dedicated salt
452
+ word: it binds seven user-defined elements, and the guarded-multisig auth
453
+ component zeroes the leading three and passes the auth-arg salt as the trailing
454
+ four. `summarySalt` reads that convention, so prefer it over indexing
455
+ `userParams()` by hand.
456
+
320
457
  > **Rust ↔ TS parity:** both SDKs expose the same producer surface —
321
458
  > `createCustomProposal` / `propose_custom_transaction`, `prepareCustomExecution` /
322
459
  > `prepare_custom_execution`, and `submitTransaction` / `submit_transaction`. The
@@ -1 +1 @@
1
- {"version":3,"file":"builder.d.ts","sourceRoot":"","sources":["../../src/account/builder.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAIL,KAAK,WAAW,EACjB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAevE;;;;;;;GAOG;AACH,wBAAsB,qBAAqB,CACzC,WAAW,EAAE,WAAW,EACxB,MAAM,EAAE,cAAc,EACtB,gBAAgB,EAAE,MAAM,GACvB,OAAO,CAAC,mBAAmB,CAAC,CAqD9B;AAED;;;;;GAKG;AACH,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,cAAc,GAAG,IAAI,CA6CnE"}
1
+ {"version":3,"file":"builder.d.ts","sourceRoot":"","sources":["../../src/account/builder.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAIL,KAAK,WAAW,EAEjB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAqBvE;;;;;;;GAOG;AACH,wBAAsB,qBAAqB,CACzC,WAAW,EAAE,WAAW,EACxB,MAAM,EAAE,cAAc,EACtB,gBAAgB,EAAE,MAAM,GACvB,OAAO,CAAC,mBAAmB,CAAC,CAgC9B;AAED;;;;;GAKG;AACH,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,cAAc,GAAG,IAAI,CAuEnE"}
@@ -6,9 +6,17 @@
6
6
  import { AccountBuilder, AccountComponent, AccountStorageMode, } from '@miden-sdk/miden-sdk';
7
7
  import { getRawMidenClient } from '../raw-client.js';
8
8
  import { buildMultisigStorageSlots, buildGuardianStorageSlots } from './storage.js';
9
- import { MULTISIG_ECDSA_MASM, MULTISIG_MASM, GUARDIAN_ECDSA_MASM, GUARDIAN_MASM, } from './masm/auth.js';
10
- import { MULTISIG_GUARDIAN_ACCOUNT_COMPONENT_MASM, MULTISIG_GUARDIAN_ECDSA_ACCOUNT_COMPONENT_MASM, } from './masm/account-components/auth.js';
9
+ import { GUARDED_MULTISIG_ACCOUNT_COMPONENT_MASM } from './masm/account-components/auth.js';
11
10
  import { normalizeSignerCommitment } from '../utils/signature.js';
11
+ /** Builds the guarded-multisig component without relinking assembler-provided libraries. */
12
+ function buildGuardedMultisigComponent(authBuilder, config) {
13
+ const authSlots = [
14
+ ...buildMultisigStorageSlots(config),
15
+ ...buildGuardianStorageSlots(config),
16
+ ];
17
+ const authComponentCode = authBuilder.compileAccountComponentCode(GUARDED_MULTISIG_ACCOUNT_COMPONENT_MASM);
18
+ return AccountComponent.compile(authComponentCode, authSlots).withSupportsAllTypes();
19
+ }
12
20
  /**
13
21
  * Creates a multisig account with GUARDIAN authentication.
14
22
  *
@@ -19,30 +27,9 @@ import { normalizeSignerCommitment } from '../utils/signature.js';
19
27
  */
20
28
  export async function createMultisigAccount(midenClient, config, midenRpcEndpoint) {
21
29
  validateMultisigConfig(config);
22
- const signatureScheme = config.signatureScheme ?? 'falcon';
23
30
  const rawClient = await getRawMidenClient(midenClient, midenRpcEndpoint);
24
- const authSlots = [
25
- ...buildMultisigStorageSlots(config),
26
- ...buildGuardianStorageSlots(config),
27
- ];
28
- const guardianMasm = signatureScheme === 'ecdsa' ? GUARDIAN_ECDSA_MASM : GUARDIAN_MASM;
29
- const multisigMasm = signatureScheme === 'ecdsa' ? MULTISIG_ECDSA_MASM : MULTISIG_MASM;
30
- const authComponentMasm = signatureScheme === 'ecdsa'
31
- ? MULTISIG_GUARDIAN_ECDSA_ACCOUNT_COMPONENT_MASM
32
- : MULTISIG_GUARDIAN_ACCOUNT_COMPONENT_MASM;
33
- const guardianLibraryPath = signatureScheme === 'ecdsa'
34
- ? 'openzeppelin::auth::guardian_ecdsa'
35
- : 'openzeppelin::auth::guardian';
36
- const multisigLibraryPath = signatureScheme === 'ecdsa'
37
- ? 'openzeppelin::auth::multisig_ecdsa'
38
- : 'openzeppelin::auth::multisig';
39
31
  const authBuilder = await rawClient.createCodeBuilder();
40
- authBuilder.linkModule(guardianLibraryPath, guardianMasm);
41
- authBuilder.linkModule(multisigLibraryPath, multisigMasm);
42
- const authComponentCode = authBuilder.compileAccountComponentCode(authComponentMasm);
43
- const authComponent = AccountComponent
44
- .compile(authComponentCode, authSlots)
45
- .withSupportsAllTypes();
32
+ const authComponent = buildGuardedMultisigComponent(authBuilder, config);
46
33
  let seed = config.seed;
47
34
  // Generate random seed if not provided
48
35
  if (!seed) {
@@ -57,7 +44,7 @@ export async function createMultisigAccount(midenClient, config, midenRpcEndpoin
57
44
  .storageMode(storageMode)
58
45
  .withAuthComponent(authComponent)
59
46
  .withBasicWalletComponent();
60
- const result = accountBuilder.build();
47
+ const result = accountBuilder.buildWithoutSchemaCommitment();
61
48
  await midenClient.accounts.insert({ account: result.account, overwrite: false });
62
49
  return {
63
50
  account: result.account,
@@ -91,6 +78,9 @@ export function validateMultisigConfig(config) {
91
78
  if (!config.guardianCommitment) {
92
79
  throw new Error('GUARDIAN commitment is required');
93
80
  }
81
+ if (signerCommitments.has(normalizeSignerCommitment(config.guardianCommitment))) {
82
+ throw new Error('GUARDIAN commitment must be different from all signer commitments');
83
+ }
94
84
  // Validate procedure thresholds if provided
95
85
  if (config.procedureThresholds) {
96
86
  const seen = new Set();
@@ -106,6 +96,23 @@ export function validateMultisigConfig(config) {
106
96
  }
107
97
  seen.add(pt.procedure);
108
98
  }
99
+ // An override is only enforceable if lowering it costs at least as many
100
+ // signatures as the override itself demands. `update_procedure_threshold`
101
+ // is the procedure that edits overrides, so anything above its own
102
+ // effective threshold can be lowered by a smaller quorum and then used:
103
+ // a 2-of-5 with `send_asset: 4` is a 2-of-5 spend lock, not a 4-of-5 one.
104
+ // Mirrors `AuthMultisig::new` in miden-standards, which rejects the same
105
+ // shape, so Rust cannot build an account TypeScript would otherwise allow.
106
+ const setterOverride = config.procedureThresholds.find((pt) => pt.procedure === 'update_procedure_threshold')?.threshold;
107
+ const setterThreshold = setterOverride ?? config.threshold;
108
+ for (const pt of config.procedureThresholds) {
109
+ if (pt.threshold > setterThreshold) {
110
+ throw new Error(`procedure threshold override for ${pt.procedure} (${pt.threshold}) exceeds the ` +
111
+ `threshold of ${setterThreshold} that guards update_procedure_threshold; such an ` +
112
+ `override can be removed by a smaller quorum. Raise the update_procedure_threshold ` +
113
+ `override to at least ${pt.threshold} to make it enforceable`);
114
+ }
115
+ }
109
116
  }
110
117
  }
111
118
  //# sourceMappingURL=builder.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"builder.js","sourceRoot":"","sources":["../../src/account/builder.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACL,cAAc,EACd,gBAAgB,EAChB,kBAAkB,GAEnB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,yBAAyB,EAAE,yBAAyB,EAAE,MAAM,cAAc,CAAC;AACpF,OAAO,EACL,mBAAmB,EACnB,aAAa,EACb,mBAAmB,EACnB,aAAa,GACd,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,wCAAwC,EACxC,8CAA8C,GAC/C,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAAE,yBAAyB,EAAE,MAAM,uBAAuB,CAAC;AAElE;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,qBAAqB,CACzC,WAAwB,EACxB,MAAsB,EACtB,gBAAwB;IAExB,sBAAsB,CAAC,MAAM,CAAC,CAAC;IAC/B,MAAM,eAAe,GAAG,MAAM,CAAC,eAAe,IAAI,QAAQ,CAAC;IAC3D,MAAM,SAAS,GAAG,MAAM,iBAAiB,CAAC,WAAW,EAAE,gBAAgB,CAAC,CAAC;IACzE,MAAM,SAAS,GAAG;QAChB,GAAG,yBAAyB,CAAC,MAAM,CAAC;QACpC,GAAG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AAI,CACpD,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,SAAS,KAAK,4BAA4B,CACtD,EAAE,SAAS,CAAC;QACb,MAAM,eAAe,GAAG,cAAc,IAAI,MAAM,CAAC,SAAS,CAAC;QAE3D,KAAK,MAAM,EAAE,IAAI,MAAM,CAAC,mBAAmB,EAAE,CAAC;YAC5C,IAAI,EAAE,CAAC,SAAS,GAAG,eAAe,EAAE,CAAC;gBACnC,MAAM,IAAI,KAAK,CACb,oCAAoC,EAAE,CAAC,SAAS,KAAK,EAAE,CAAC,SAAS,gBAAgB;oBAC/E,gBAAgB,eAAe,mDAAmD;oBAClF,oFAAoF;oBACpF,wBAAwB,EAAE,CAAC,SAAS,yBAAyB,CAChE,CAAC;YACJ,CAAC;QACH,CAAC;IACH,CAAC;AACH,CAAC"}
@@ -1,7 +1,6 @@
1
1
  import { beforeEach, describe, expect, it, vi } from 'vitest';
2
- import { createMultisigAccount } from './builder.js';
3
- import { MULTISIG_ECDSA_MASM, MULTISIG_MASM, GUARDIAN_ECDSA_MASM, GUARDIAN_MASM, } from './masm/auth.js';
4
- import { MULTISIG_GUARDIAN_ACCOUNT_COMPONENT_MASM, MULTISIG_GUARDIAN_ECDSA_ACCOUNT_COMPONENT_MASM, } from './masm/account-components/auth.js';
2
+ import { createMultisigAccount, validateMultisigConfig } from './builder.js';
3
+ import { GUARDED_MULTISIG_ACCOUNT_COMPONENT_MASM } from './masm/account-components/auth.js';
5
4
  const { buildMultisigStorageSlots, buildGuardianStorageSlots, withSupportsAllTypes, compileComponent, MockAccountBuilder, } = vi.hoisted(() => {
6
5
  const buildMultisigStorageSlots = vi.fn(() => ['multisig-slots']);
7
6
  const buildGuardianStorageSlots = vi.fn(() => ['guardian-slots']);
@@ -32,6 +31,11 @@ const { buildMultisigStorageSlots, buildGuardianStorageSlots, withSupportsAllTyp
32
31
  account: { id: () => ({ toString: () => '0x' + 'a'.repeat(30) }) },
33
32
  };
34
33
  }
34
+ buildWithoutSchemaCommitment() {
35
+ return {
36
+ account: { id: () => ({ toString: () => '0x' + 'a'.repeat(30) }) },
37
+ };
38
+ }
35
39
  }
36
40
  return {
37
41
  buildMultisigStorageSlots,
@@ -67,7 +71,7 @@ describe('createMultisigAccount', () => {
67
71
  withSupportsAllTypes.mockClear();
68
72
  compileComponent.mockClear();
69
73
  });
70
- it('uses Falcon MASM by default', async () => {
74
+ function makeClient() {
71
75
  const authBuilder = {
72
76
  linkModule: vi.fn(),
73
77
  compileAccountComponentCode: vi.fn((source) => ({ source })),
@@ -78,37 +82,85 @@ describe('createMultisigAccount', () => {
78
82
  insert: vi.fn().mockResolvedValue(undefined),
79
83
  },
80
84
  };
85
+ return { authBuilder, webClient };
86
+ }
87
+ it('compiles the guarded component without re-linking SDK-provided modules (Falcon)', async () => {
88
+ const { authBuilder, webClient } = makeClient();
81
89
  await createMultisigAccount(webClient, {
82
90
  threshold: 1,
83
91
  signerCommitments: ['0x' + '1'.repeat(64)],
84
92
  guardianCommitment: '0x' + '2'.repeat(64),
85
93
  }, 'http://localhost:57291');
86
- expect(authBuilder.linkModule).toHaveBeenNthCalledWith(1, 'openzeppelin::auth::guardian', GUARDIAN_MASM);
87
- expect(authBuilder.linkModule).toHaveBeenNthCalledWith(2, 'openzeppelin::auth::multisig', MULTISIG_MASM);
88
- expect(authBuilder.compileAccountComponentCode).toHaveBeenCalledWith(MULTISIG_GUARDIAN_ACCOUNT_COMPONENT_MASM);
94
+ // The web SDK assembler already provides `miden::standards::auth::*`; re-linking would
95
+ // raise a duplicate-definition error, so the builder must NOT call linkModule.
96
+ expect(authBuilder.linkModule).not.toHaveBeenCalled();
97
+ expect(authBuilder.compileAccountComponentCode).toHaveBeenCalledWith(GUARDED_MULTISIG_ACCOUNT_COMPONENT_MASM);
89
98
  expect(webClient.accounts.insert).toHaveBeenCalledTimes(1);
90
99
  });
91
- it('uses ECDSA MASM when requested', async () => {
92
- const authBuilder = {
93
- linkModule: vi.fn(),
94
- compileAccountComponentCode: vi.fn((source) => ({ source })),
95
- };
96
- const webClient = {
97
- createCodeBuilder: vi.fn().mockReturnValue(authBuilder),
98
- accounts: {
99
- insert: vi.fn().mockResolvedValue(undefined),
100
- },
101
- };
100
+ it('uses the same scheme-agnostic component for ECDSA', async () => {
101
+ const { authBuilder, webClient } = makeClient();
102
102
  await createMultisigAccount(webClient, {
103
103
  threshold: 1,
104
104
  signerCommitments: ['0x' + '1'.repeat(64)],
105
105
  guardianCommitment: '0x' + '2'.repeat(64),
106
106
  signatureScheme: 'ecdsa',
107
107
  }, 'http://localhost:57291');
108
- expect(authBuilder.linkModule).toHaveBeenNthCalledWith(1, 'openzeppelin::auth::guardian_ecdsa', GUARDIAN_ECDSA_MASM);
109
- expect(authBuilder.linkModule).toHaveBeenNthCalledWith(2, 'openzeppelin::auth::multisig_ecdsa', MULTISIG_ECDSA_MASM);
110
- expect(authBuilder.compileAccountComponentCode).toHaveBeenCalledWith(MULTISIG_GUARDIAN_ECDSA_ACCOUNT_COMPONENT_MASM);
108
+ expect(authBuilder.linkModule).not.toHaveBeenCalled();
109
+ expect(authBuilder.compileAccountComponentCode).toHaveBeenCalledWith(GUARDED_MULTISIG_ACCOUNT_COMPONENT_MASM);
111
110
  expect(webClient.accounts.insert).toHaveBeenCalledTimes(1);
112
111
  });
113
112
  });
113
+ describe('validateMultisigConfig', () => {
114
+ const signer = '0x' + '1'.repeat(64);
115
+ it('rejects a guardian commitment equal to a signer (matches upstream Rust invariant)', () => {
116
+ expect(() => validateMultisigConfig({
117
+ threshold: 1,
118
+ signerCommitments: [signer],
119
+ guardianCommitment: signer,
120
+ })).toThrow(/different from all signer commitments/);
121
+ });
122
+ it('accepts a distinct guardian commitment', () => {
123
+ expect(() => validateMultisigConfig({
124
+ threshold: 1,
125
+ signerCommitments: [signer],
126
+ guardianCommitment: '0x' + '2'.repeat(64),
127
+ })).not.toThrow();
128
+ });
129
+ describe('procedure threshold overrides vs update_procedure_threshold', () => {
130
+ const signers = Array.from({ length: 5 }, (_, i) => '0x' + String(i + 1).repeat(64));
131
+ const guardian = '0x' + '9'.repeat(64);
132
+ const config = (threshold, procedureThresholds) => ({
133
+ threshold,
134
+ signerCommitments: signers,
135
+ guardianCommitment: guardian,
136
+ procedureThresholds,
137
+ });
138
+ it('rejects an override above the default threshold that guards the setter', () => {
139
+ expect(() => validateMultisigConfig(config(2, [{ procedure: 'send_asset', threshold: 4 }]))).toThrow(/exceeds the threshold of 2 that guards update_procedure_threshold/);
140
+ });
141
+ it('accepts the same override once the setter is raised to match', () => {
142
+ expect(() => validateMultisigConfig(config(2, [
143
+ { procedure: 'send_asset', threshold: 4 },
144
+ { procedure: 'update_procedure_threshold', threshold: 4 },
145
+ ]))).not.toThrow();
146
+ });
147
+ it('rejects an override above an explicitly raised setter', () => {
148
+ expect(() => validateMultisigConfig(config(2, [
149
+ { procedure: 'send_asset', threshold: 4 },
150
+ { procedure: 'update_procedure_threshold', threshold: 3 },
151
+ ]))).toThrow(/exceeds the threshold of 3 that guards update_procedure_threshold/);
152
+ });
153
+ it('accepts overrides at or below the default threshold', () => {
154
+ expect(() => validateMultisigConfig(config(3, [
155
+ { procedure: 'send_asset', threshold: 3 },
156
+ { procedure: 'receive_asset', threshold: 1 },
157
+ ]))).not.toThrow();
158
+ });
159
+ it('allows the setter override to exceed the default threshold', () => {
160
+ // Raising only the setter is always safe: it makes overrides harder to
161
+ // edit, never easier.
162
+ expect(() => validateMultisigConfig(config(2, [{ procedure: 'update_procedure_threshold', threshold: 5 }]))).not.toThrow();
163
+ });
164
+ });
165
+ });
114
166
  //# sourceMappingURL=builder.test.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"builder.test.js","sourceRoot":"","sources":["../../src/account/builder.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAC9D,OAAO,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AACrD,OA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,EAAE;gBACR,EAAE,SAAS,EAAE,YAAY,EAAE,SAAS,EAAE,CAAC,EAAE;gBACzC,EAAE,SAAS,EAAE,eAAe,EAAE,SAAS,EAAE,CAAC,EAAE;aAC7C,CAAC,CACH,CACF,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC;QAClB,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,4DAA4D,EAAE,GAAG,EAAE;YACpE,uEAAuE;YACvE,sBAAsB;YACtB,MAAM,CAAC,GAAG,EAAE,CACV,sBAAsB,CACpB,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,SAAS,EAAE,4BAA4B,EAAE,SAAS,EAAE,CAAC,EAAE,CAAC,CAAC,CACvE,CACF,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC;QAClB,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -0,0 +1,31 @@
1
+ /**
2
+ * `AuthGuardedMultisig` storage slot names (`miden::standards::auth::*`),
3
+ * shared by the writer (`account/storage.ts`) and the readers
4
+ * (`inspector.ts`). Single source of truth so the two cannot drift. These
5
+ * must match the Rust `miden-standards` component exactly: account ID and
6
+ * commitment derive from the storage layout, so any divergence breaks
7
+ * cross-SDK determinism (guarded by the parity test).
8
+ *
9
+ * Deliberately not re-exported from the package index: consumers should use
10
+ * the `AccountInspector` accessors rather than reading storage directly
11
+ * (issue #306).
12
+ */
13
+ export declare const MULTISIG_SLOT_NAMES: {
14
+ readonly THRESHOLD_CONFIG: "miden::standards::auth::multisig::threshold_config";
15
+ readonly SIGNER_PUBLIC_KEYS: "miden::standards::auth::multisig::approver_public_keys";
16
+ readonly SIGNER_SCHEME_IDS: "miden::standards::auth::multisig::approver_schemes";
17
+ readonly EXECUTED_TRANSACTIONS: "miden::standards::auth::multisig::executed_transactions";
18
+ readonly PROCEDURE_THRESHOLDS: "miden::standards::auth::multisig::procedure_thresholds";
19
+ };
20
+ export declare const GUARDIAN_SLOT_NAMES: {
21
+ readonly PUBLIC_KEY: "miden::standards::auth::guardian::pub_key";
22
+ readonly SCHEME_ID: "miden::standards::auth::guardian::scheme";
23
+ };
24
+ /**
25
+ * Sanity ceiling for the signer count read from `threshold_config`. The
26
+ * contract has no on-chain maximum (the felt is only asserted to be a u32),
27
+ * so a corrupt or adversarial account could report an arbitrarily large
28
+ * count; readers bound their loops with this instead of trusting it.
29
+ */
30
+ export declare const MAX_SIGNERS = 1000;
31
+ //# sourceMappingURL=layout.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"layout.d.ts","sourceRoot":"","sources":["../../src/account/layout.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,eAAO,MAAM,mBAAmB;;;;;;CAMtB,CAAC;AAEX,eAAO,MAAM,mBAAmB;;;CAGtB,CAAC;AAEX;;;;;GAKG;AACH,eAAO,MAAM,WAAW,OAAO,CAAC"}
@@ -0,0 +1,31 @@
1
+ /**
2
+ * `AuthGuardedMultisig` storage slot names (`miden::standards::auth::*`),
3
+ * shared by the writer (`account/storage.ts`) and the readers
4
+ * (`inspector.ts`). Single source of truth so the two cannot drift. These
5
+ * must match the Rust `miden-standards` component exactly: account ID and
6
+ * commitment derive from the storage layout, so any divergence breaks
7
+ * cross-SDK determinism (guarded by the parity test).
8
+ *
9
+ * Deliberately not re-exported from the package index: consumers should use
10
+ * the `AccountInspector` accessors rather than reading storage directly
11
+ * (issue #306).
12
+ */
13
+ export const MULTISIG_SLOT_NAMES = {
14
+ THRESHOLD_CONFIG: 'miden::standards::auth::multisig::threshold_config',
15
+ SIGNER_PUBLIC_KEYS: 'miden::standards::auth::multisig::approver_public_keys',
16
+ SIGNER_SCHEME_IDS: 'miden::standards::auth::multisig::approver_schemes',
17
+ EXECUTED_TRANSACTIONS: 'miden::standards::auth::multisig::executed_transactions',
18
+ PROCEDURE_THRESHOLDS: 'miden::standards::auth::multisig::procedure_thresholds',
19
+ };
20
+ export const GUARDIAN_SLOT_NAMES = {
21
+ PUBLIC_KEY: 'miden::standards::auth::guardian::pub_key',
22
+ SCHEME_ID: 'miden::standards::auth::guardian::scheme',
23
+ };
24
+ /**
25
+ * Sanity ceiling for the signer count read from `threshold_config`. The
26
+ * contract has no on-chain maximum (the felt is only asserted to be a u32),
27
+ * so a corrupt or adversarial account could report an arbitrarily large
28
+ * count; readers bound their loops with this instead of trusting it.
29
+ */
30
+ export const MAX_SIGNERS = 1000;
31
+ //# sourceMappingURL=layout.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"layout.js","sourceRoot":"","sources":["../../src/account/layout.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,MAAM,CAAC,MAAM,mBAAmB,GAAG;IACjC,gBAAgB,EAAE,oDAAoD;IACtE,kBAAkB,EAAE,wDAAwD;IAC5E,iBAAiB,EAAE,oDAAoD;IACvE,qBAAqB,EAAE,yDAAyD;IAChF,oBAAoB,EAAE,wDAAwD;CACtE,CAAC;AAEX,MAAM,CAAC,MAAM,mBAAmB,GAAG;IACjC,UAAU,EAAE,2CAA2C;IACvD,SAAS,EAAE,0CAA0C;CAC7C,CAAC;AAEX;;;;;GAKG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,IAAI,CAAC"}
@@ -1,5 +1,2 @@
1
- export declare const MULTISIG_ACCOUNT_COMPONENT_MASM = "# Multi-Signature RPO Falcon 512 Authentication Component\n\nuse openzeppelin::auth::multisig\n\npub use multisig::update_signers_and_threshold\npub use multisig::update_procedure_threshold\n\n@auth_script\npub proc auth_tx_multisig(salt: word)\n exec.multisig::auth_tx\n exec.multisig::assert_new_tx\nend\n";
2
- export declare const MULTISIG_GUARDIAN_ACCOUNT_COMPONENT_MASM = "# Multi-Signature RPO Falcon 512 Authentication Component With GUARDIAN\n\nuse openzeppelin::auth::multisig\nuse openzeppelin::auth::guardian\n\npub use multisig::update_signers_and_threshold\npub use multisig::update_procedure_threshold\npub use guardian::update_guardian_public_key\npub use guardian::verify_guardian_signature\n\n@auth_script\npub proc auth_tx_multisig_guardian(salt: word)\n exec.multisig::auth_tx\n exec.guardian::verify_guardian_signature\n exec.multisig::assert_new_tx\nend\n";
3
- export declare const MULTISIG_ECDSA_ACCOUNT_COMPONENT_MASM = "# Multi-Signature ECDSA secp256k1 Authentication Component\n\nuse openzeppelin::auth::multisig_ecdsa\n\npub use multisig_ecdsa::update_signers_and_threshold\npub use multisig_ecdsa::update_procedure_threshold\n\n@auth_script\npub proc auth_tx_multisig_ecdsa(salt: word)\n exec.multisig_ecdsa::auth_tx\n exec.multisig_ecdsa::assert_new_tx\nend\n";
4
- export declare const MULTISIG_GUARDIAN_ECDSA_ACCOUNT_COMPONENT_MASM = "# Multi-Signature ECDSA secp256k1 Authentication Component With GUARDIAN\n\nuse openzeppelin::auth::multisig_ecdsa\nuse openzeppelin::auth::guardian_ecdsa\n\npub use multisig_ecdsa::update_signers_and_threshold\npub use multisig_ecdsa::update_procedure_threshold\npub use guardian_ecdsa::update_guardian_public_key\npub use guardian_ecdsa::verify_guardian_signature\n\n@auth_script\npub proc auth_tx_multisig_guardian_ecdsa(salt: word)\n exec.multisig_ecdsa::auth_tx\n exec.guardian_ecdsa::verify_guardian_signature\n exec.multisig_ecdsa::assert_new_tx\nend\n";
1
+ export declare const GUARDED_MULTISIG_ACCOUNT_COMPONENT_MASM = "# The MASM code of the Multi-Signature Authentication component integrated with a state guardian.\n#\n# See the `AuthGuardedMultisig` Rust type's documentation for more details.\n\nuse miden::standards::auth::multisig\nuse miden::standards::auth::guardian\n\npub use {update_signers_and_threshold} from miden::standards::auth::multisig\npub use {get_threshold_and_num_approvers} from miden::standards::auth::multisig\npub use {set_procedure_threshold} from miden::standards::auth::multisig\npub use {get_signer_at} from miden::standards::auth::multisig\npub use {is_signer} from miden::standards::auth::multisig\n\npub use {update_guardian_public_key} from miden::standards::auth::guardian\n\n#! Authenticate a transaction with multi-signature support and optional guardian verification.\n#!\n#! Inputs:\n#! Operand stack: [SALT]\n#! Outputs:\n#! Operand stack: []\n#!\n#! Invocation: call\n@auth_script\npub proc auth_tx_guarded_multisig(salt: word)\n # zero the leading user params (not exposed through this component's interface); the SALT\n # occupies the trailing four\n push.0.0.0\n # => [0, 0, 0, SALT]\n\n exec.multisig::auth_tx\n # => [TX_SUMMARY_COMMITMENT]\n\n dupw\n # => [TX_SUMMARY_COMMITMENT, TX_SUMMARY_COMMITMENT]\n \n exec.guardian::verify_signature\n # => [TX_SUMMARY_COMMITMENT]\n\n exec.multisig::record_and_assert_new_tx\n # => []\nend\n";
5
2
  //# sourceMappingURL=auth.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../../../src/account/masm/account-components/auth.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,+BAA+B,8TAY3C,CAAC;AAEF,eAAO,MAAM,wCAAwC,ggBAgBpD,CAAC;AAEF,eAAO,MAAM,qCAAqC,mWAYjD,CAAC;AAEF,eAAO,MAAM,8CAA8C,6jBAgB1D,CAAC"}
1
+ {"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../../../src/account/masm/account-components/auth.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,uCAAuC,+3CA0CnD,CAAC"}