@openzeppelin/miden-multisig-client 0.13.4 → 0.14.5

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 (145) hide show
  1. package/README.md +10 -13
  2. package/dist/account/builder.d.ts +3 -3
  3. package/dist/account/builder.d.ts.map +1 -1
  4. package/dist/account/builder.js +10 -10
  5. package/dist/account/builder.js.map +1 -1
  6. package/dist/account/builder.test.js +16 -14
  7. package/dist/account/builder.test.js.map +1 -1
  8. package/dist/account/masm/account-components/auth.d.ts +4 -4
  9. package/dist/account/masm/account-components/auth.d.ts.map +1 -1
  10. package/dist/account/masm/account-components/auth.js +8 -12
  11. package/dist/account/masm/account-components/auth.js.map +1 -1
  12. package/dist/account/masm/auth.d.ts +4 -4
  13. package/dist/account/masm/auth.d.ts.map +1 -1
  14. package/dist/account/masm/auth.js +226 -124
  15. package/dist/account/masm/auth.js.map +1 -1
  16. package/dist/account/storage.d.ts.map +1 -1
  17. package/dist/account/storage.js +24 -6
  18. package/dist/account/storage.js.map +1 -1
  19. package/dist/account/storage.test.d.ts +2 -0
  20. package/dist/account/storage.test.d.ts.map +1 -0
  21. package/dist/account/storage.test.js +73 -0
  22. package/dist/account/storage.test.js.map +1 -0
  23. package/dist/client.d.ts +9 -9
  24. package/dist/client.d.ts.map +1 -1
  25. package/dist/client.js +24 -14
  26. package/dist/client.js.map +1 -1
  27. package/dist/client.test.js +45 -8
  28. package/dist/client.test.js.map +1 -1
  29. package/dist/index.d.ts +6 -12
  30. package/dist/index.d.ts.map +1 -1
  31. package/dist/index.js +6 -12
  32. package/dist/index.js.map +1 -1
  33. package/dist/multisig/proposal/execution.d.ts +3 -2
  34. package/dist/multisig/proposal/execution.d.ts.map +1 -1
  35. package/dist/multisig/proposal/execution.js +8 -12
  36. package/dist/multisig/proposal/execution.js.map +1 -1
  37. package/dist/multisig.d.ts +7 -4
  38. package/dist/multisig.d.ts.map +1 -1
  39. package/dist/multisig.js +53 -35
  40. package/dist/multisig.js.map +1 -1
  41. package/dist/multisig.test.js +17 -29
  42. package/dist/multisig.test.js.map +1 -1
  43. package/dist/procedures.d.ts +8 -8
  44. package/dist/procedures.js +8 -8
  45. package/dist/raw-client.d.ts +13 -0
  46. package/dist/raw-client.d.ts.map +1 -0
  47. package/dist/raw-client.js +42 -0
  48. package/dist/raw-client.js.map +1 -0
  49. package/dist/raw-client.test.d.ts +2 -0
  50. package/dist/raw-client.test.d.ts.map +1 -0
  51. package/dist/raw-client.test.js +89 -0
  52. package/dist/raw-client.test.js.map +1 -0
  53. package/dist/signers/ecdsa.d.ts +3 -1
  54. package/dist/signers/ecdsa.d.ts.map +1 -1
  55. package/dist/signers/ecdsa.js +15 -1
  56. package/dist/signers/ecdsa.js.map +1 -1
  57. package/dist/signers/ecdsa.test.js +27 -4
  58. package/dist/signers/ecdsa.test.js.map +1 -1
  59. package/dist/signers/falcon.d.ts +3 -1
  60. package/dist/signers/falcon.d.ts.map +1 -1
  61. package/dist/signers/falcon.js +15 -1
  62. package/dist/signers/falcon.js.map +1 -1
  63. package/dist/signers/falcon.test.js +39 -3
  64. package/dist/signers/falcon.test.js.map +1 -1
  65. package/dist/transaction/consumeNotes.d.ts +2 -2
  66. package/dist/transaction/consumeNotes.d.ts.map +1 -1
  67. package/dist/transaction/consumeNotes.js +5 -4
  68. package/dist/transaction/consumeNotes.js.map +1 -1
  69. package/dist/transaction/options.d.ts +1 -0
  70. package/dist/transaction/options.d.ts.map +1 -1
  71. package/dist/transaction/p2id.d.ts.map +1 -1
  72. package/dist/transaction/p2id.js +7 -10
  73. package/dist/transaction/p2id.js.map +1 -1
  74. package/dist/transaction/p2id.test.js +19 -9
  75. package/dist/transaction/p2id.test.js.map +1 -1
  76. package/dist/transaction/summary.d.ts +2 -2
  77. package/dist/transaction/summary.d.ts.map +1 -1
  78. package/dist/transaction/summary.js +4 -2
  79. package/dist/transaction/summary.js.map +1 -1
  80. package/dist/transaction/updateGuardian.d.ts +2 -2
  81. package/dist/transaction/updateGuardian.d.ts.map +1 -1
  82. package/dist/transaction/updateGuardian.js +8 -11
  83. package/dist/transaction/updateGuardian.js.map +1 -1
  84. package/dist/transaction/updateProcedureThreshold.d.ts +2 -2
  85. package/dist/transaction/updateProcedureThreshold.d.ts.map +1 -1
  86. package/dist/transaction/updateProcedureThreshold.js +8 -10
  87. package/dist/transaction/updateProcedureThreshold.js.map +1 -1
  88. package/dist/transaction/updateSigners.d.ts +2 -2
  89. package/dist/transaction/updateSigners.d.ts.map +1 -1
  90. package/dist/transaction/updateSigners.js +8 -10
  91. package/dist/transaction/updateSigners.js.map +1 -1
  92. package/dist/transaction.test.js +6 -6
  93. package/dist/transaction.test.js.map +1 -1
  94. package/dist/utils/key.d.ts.map +1 -1
  95. package/dist/utils/key.js +3 -3
  96. package/dist/utils/key.js.map +1 -1
  97. package/dist/utils/key.test.js +4 -2
  98. package/dist/utils/key.test.js.map +1 -1
  99. package/dist/utils/signature.d.ts +2 -0
  100. package/dist/utils/signature.d.ts.map +1 -1
  101. package/dist/utils/signature.js +11 -8
  102. package/dist/utils/signature.js.map +1 -1
  103. package/dist/utils/signature.test.js +9 -9
  104. package/dist/utils/signature.test.js.map +1 -1
  105. package/masm/account_components/auth/multisig.masm +2 -3
  106. package/masm/account_components/auth/multisig_ecdsa.masm +2 -3
  107. package/masm/account_components/auth/multisig_guardian.masm +2 -3
  108. package/masm/account_components/auth/multisig_guardian_ecdsa.masm +2 -3
  109. package/masm/auth/guardian.masm +30 -8
  110. package/masm/auth/guardian_ecdsa.masm +24 -7
  111. package/masm/auth/multisig.masm +86 -55
  112. package/masm/auth/multisig_ecdsa.masm +86 -54
  113. package/package.json +3 -3
  114. package/src/account/builder.test.ts +16 -14
  115. package/src/account/builder.ts +13 -12
  116. package/src/account/masm/account-components/auth.ts +8 -12
  117. package/src/account/masm/auth.ts +226 -124
  118. package/src/account/storage.test.ts +90 -0
  119. package/src/account/storage.ts +27 -6
  120. package/src/client.test.ts +52 -8
  121. package/src/client.ts +39 -16
  122. package/src/index.ts +6 -12
  123. package/src/multisig/proposal/execution.ts +18 -14
  124. package/src/multisig.test.ts +17 -29
  125. package/src/multisig.ts +61 -36
  126. package/src/procedures.ts +8 -8
  127. package/src/raw-client.test.ts +133 -0
  128. package/src/raw-client.ts +75 -0
  129. package/src/signers/ecdsa.test.ts +35 -4
  130. package/src/signers/ecdsa.ts +18 -2
  131. package/src/signers/falcon.test.ts +50 -3
  132. package/src/signers/falcon.ts +18 -2
  133. package/src/transaction/consumeNotes.ts +16 -5
  134. package/src/transaction/options.ts +1 -0
  135. package/src/transaction/p2id.test.ts +19 -9
  136. package/src/transaction/p2id.ts +8 -13
  137. package/src/transaction/summary.ts +11 -4
  138. package/src/transaction/updateGuardian.ts +22 -14
  139. package/src/transaction/updateProcedureThreshold.ts +20 -15
  140. package/src/transaction/updateSigners.ts +22 -14
  141. package/src/transaction.test.ts +6 -6
  142. package/src/utils/key.test.ts +4 -2
  143. package/src/utils/key.ts +7 -3
  144. package/src/utils/signature.test.ts +10 -10
  145. package/src/utils/signature.ts +14 -8
package/README.md CHANGED
@@ -17,26 +17,25 @@ 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 @demox-labs/miden-sdk
20
+ npm install @openzeppelin/miden-multisig-client @miden-sdk/miden-sdk
21
21
  ```
22
22
 
23
23
  ## Setup
24
24
 
25
25
  ```typescript
26
26
  import { MultisigClient, FalconSigner } from '@openzeppelin/miden-multisig-client';
27
- import { WebClient, SecretKey } from '@demox-labs/miden-sdk';
27
+ import { AuthSecretKey, MidenClient } from '@miden-sdk/miden-sdk';
28
28
 
29
- // Initialize Miden WebClient
30
- const webClient = await WebClient.createClient('https://rpc.testnet.miden.io:443');
29
+ const midenClient = await MidenClient.createDevnet();
31
30
 
32
31
  // Create a signer from your secret key
33
- const secretKey = SecretKey.rpoFalconWithRNG(seed);
32
+ const secretKey = AuthSecretKey.rpoFalconWithRNG(undefined);
34
33
  const signer = new FalconSigner(secretKey);
35
34
 
36
35
  // Create MultisigClient
37
- const client = new MultisigClient(webClient, {
36
+ const client = new MultisigClient(midenClient, {
38
37
  guardianEndpoint: 'http://localhost:3000',
39
- midenRpcEndpoint: 'https://rpc.testnet.miden.io:443',
38
+ midenRpcEndpoint: 'https://rpc.devnet.miden.io',
40
39
  });
41
40
  ```
42
41
 
@@ -94,12 +93,10 @@ console.log('Created:', state.createdAt);
94
93
 
95
94
  ```typescript
96
95
  // Create a proposal to add a new signer
97
- const nonce = Math.floor(Math.random() * 1_000_000_000);
98
96
  const proposal = await multisig.createAddSignerProposal(
99
- webClient,
100
97
  newSignerCommitment, // Commitment of signer to add
101
- nonce, // Optional nonce (random value)
102
- 3, // Optional new threshold
98
+ undefined,
99
+ 3,
103
100
  );
104
101
  console.log('Proposal ID:', proposal.id);
105
102
  ```
@@ -143,7 +140,7 @@ When a proposal has enough signatures:
143
140
 
144
141
  ```typescript
145
142
  if (proposal.status === 'ready') {
146
- await multisig.executeProposal(proposal.id, webClient);
143
+ await multisig.executeProposal(proposal.id);
147
144
  console.log('Transaction executed on-chain!');
148
145
  }
149
146
  ```
@@ -190,7 +187,7 @@ const bytes = hexToUint8Array('deadbeef');
190
187
 
191
188
  // Add auth scheme prefix to signature
192
189
  const sigBytes = signatureHexToBytes(signatureHex);
193
- // => Uint8Array with 0x00 prefix (RpoFalcon512)
190
+ // => Uint8Array with the Falcon Poseidon2 auth prefix
194
191
  ```
195
192
 
196
193
  ## Testing
@@ -3,16 +3,16 @@
3
3
  *
4
4
  * This module provides functionality to create multisig accounts.
5
5
  */
6
- import { type WebClient } from '@miden-sdk/miden-sdk';
6
+ import { type MidenClient } from '@miden-sdk/miden-sdk';
7
7
  import type { MultisigConfig, CreateAccountResult } from '../types.js';
8
8
  /**
9
9
  * Creates a multisig account with GUARDIAN authentication.
10
10
  *
11
- * @param webClient - Initialized Miden WebClient
11
+ * @param midenClient - Initialized MidenClient
12
12
  * @param config - Multisig configuration
13
13
  * @returns The created account and seed
14
14
  */
15
- export declare function createMultisigAccount(webClient: WebClient, config: MultisigConfig): Promise<CreateAccountResult>;
15
+ export declare function createMultisigAccount(midenClient: MidenClient, config: MultisigConfig, midenRpcEndpoint?: string): Promise<CreateAccountResult>;
16
16
  /**
17
17
  * Validates a multisig configuration.
18
18
  *
@@ -1 +1 @@
1
- {"version":3,"file":"builder.d.ts","sourceRoot":"","sources":["../../src/account/builder.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAKL,KAAK,SAAS,EACf,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAcvE;;;;;;GAMG;AACH,wBAAsB,qBAAqB,CACzC,SAAS,EAAE,SAAS,EACpB,MAAM,EAAE,cAAc,GACrB,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,EAKL,KAAK,WAAW,EACjB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAevE;;;;;;GAMG;AACH,wBAAsB,qBAAqB,CACzC,WAAW,EAAE,WAAW,EACxB,MAAM,EAAE,cAAc,EACtB,gBAAgB,CAAC,EAAE,MAAM,GACxB,OAAO,CAAC,mBAAmB,CAAC,CAoD9B;AAED;;;;;GAKG;AACH,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,cAAc,GAAG,IAAI,CA6CnE"}
@@ -4,6 +4,7 @@
4
4
  * This module provides functionality to create multisig accounts.
5
5
  */
6
6
  import { AccountBuilder, AccountComponent, AccountType, AccountStorageMode, } from '@miden-sdk/miden-sdk';
7
+ import { getRawMidenClient } from '../raw-client.js';
7
8
  import { buildMultisigStorageSlots, buildGuardianStorageSlots } from './storage.js';
8
9
  import { MULTISIG_ECDSA_MASM, MULTISIG_MASM, GUARDIAN_ECDSA_MASM, GUARDIAN_MASM, } from './masm/auth.js';
9
10
  import { MULTISIG_GUARDIAN_ACCOUNT_COMPONENT_MASM, MULTISIG_GUARDIAN_ECDSA_ACCOUNT_COMPONENT_MASM, } from './masm/account-components/auth.js';
@@ -11,13 +12,14 @@ import { normalizeSignerCommitment } from '../utils/signature.js';
11
12
  /**
12
13
  * Creates a multisig account with GUARDIAN authentication.
13
14
  *
14
- * @param webClient - Initialized Miden WebClient
15
+ * @param midenClient - Initialized MidenClient
15
16
  * @param config - Multisig configuration
16
17
  * @returns The created account and seed
17
18
  */
18
- export async function createMultisigAccount(webClient, config) {
19
+ export async function createMultisigAccount(midenClient, config, midenRpcEndpoint) {
19
20
  validateMultisigConfig(config);
20
21
  const signatureScheme = config.signatureScheme ?? 'falcon';
22
+ const rawClient = await getRawMidenClient(midenClient, midenRpcEndpoint);
21
23
  const authSlots = [
22
24
  ...buildMultisigStorageSlots(config),
23
25
  ...buildGuardianStorageSlots(config),
@@ -33,14 +35,12 @@ export async function createMultisigAccount(webClient, config) {
33
35
  const multisigLibraryPath = signatureScheme === 'ecdsa'
34
36
  ? 'openzeppelin::auth::multisig_ecdsa'
35
37
  : 'openzeppelin::auth::multisig';
36
- const authBuilder = webClient.createCodeBuilder();
37
- const guardianLib = authBuilder.buildLibrary(guardianLibraryPath, guardianMasm);
38
- authBuilder.linkStaticLibrary(guardianLib);
39
- const multisigLib = authBuilder.buildLibrary(multisigLibraryPath, multisigMasm);
40
- authBuilder.linkStaticLibrary(multisigLib);
41
- const authCode = authBuilder.compileAccountComponentCode(authComponentMasm);
38
+ const authBuilder = rawClient.createCodeBuilder();
39
+ authBuilder.linkModule(guardianLibraryPath, guardianMasm);
40
+ authBuilder.linkModule(multisigLibraryPath, multisigMasm);
41
+ const authComponentCode = authBuilder.compileAccountComponentCode(authComponentMasm);
42
42
  const authComponent = AccountComponent
43
- .compile(authCode, authSlots)
43
+ .compile(authComponentCode, authSlots)
44
44
  .withSupportsAllTypes();
45
45
  let seed = config.seed;
46
46
  // Generate random seed if not provided
@@ -56,7 +56,7 @@ export async function createMultisigAccount(webClient, config) {
56
56
  .withAuthComponent(authComponent)
57
57
  .withBasicWalletComponent();
58
58
  const result = accountBuilder.build();
59
- await webClient.newAccount(result.account, false);
59
+ await midenClient.accounts.insert({ account: result.account, overwrite: false });
60
60
  return {
61
61
  account: result.account,
62
62
  seed,
@@ -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,WAAW,EACX,kBAAkB,GAEnB,MAAM,sBAAsB,CAAC;AAE9B,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;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,qBAAqB,CACzC,SAAoB,EACpB,MAAsB;IAEtB,sBAAsB,CAAC,MAAM,CAAC,CAAC;IAC/B,MAAM,eAAe,GAAG,MAAM,CAAC,eAAe,IAAI,QAAQ,CAAC;IAC3D,MAAM,SAAS,GAAG;QAChB,GAAG,yBAAyB,CAAC,MAAM,CAAC;QACpC,GAAG,yBAAyB,CAAC,MAAM,CAAC;KACrC,CAAC;IACF,MAAM,YAAY,GAAG,eAAe,KAAK,OAAO,CAAC,CAAC,CAAC,mBAAmB,CAAC,CAAC,CAAC,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I,KAAK,CACb,wBAAwB,EAAE,CAAC,SAAS,sCAAsC,MAAM,CAAC,iBAAiB,CAAC,MAAM,GAAG,CAC7G,CAAC;YACJ,CAAC;YAED,IAAI,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,SAAS,CAAC,EAAE,CAAC;gBAC3B,MAAM,IAAI,KAAK,CAAC,sCAAsC,EAAE,CAAC,SAAS,EAAE,CAAC,CAAC;YACxE,CAAC;YACD,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,SAAS,CAAC,CAAC;QACzB,CAAC;IACH,CAAC;AACH,CAAC"}
@@ -72,33 +72,35 @@ describe('createMultisigAccount', () => {
72
72
  });
73
73
  it('uses Falcon MASM by default', async () => {
74
74
  const authBuilder = {
75
- buildLibrary: vi.fn((libraryPath, source) => ({ libraryPath, source })),
76
- linkStaticLibrary: vi.fn(),
77
- compileAccountComponentCode: vi.fn((source) => `auth:${source.slice(0, 16)}`),
75
+ linkModule: vi.fn(),
76
+ compileAccountComponentCode: vi.fn((source) => ({ source })),
78
77
  };
79
78
  const webClient = {
80
79
  createCodeBuilder: vi.fn().mockReturnValue(authBuilder),
81
- newAccount: vi.fn(),
80
+ accounts: {
81
+ insert: vi.fn().mockResolvedValue(undefined),
82
+ },
82
83
  };
83
84
  await createMultisigAccount(webClient, {
84
85
  threshold: 1,
85
86
  signerCommitments: ['0x' + '1'.repeat(64)],
86
87
  guardianCommitment: '0x' + '2'.repeat(64),
87
88
  });
88
- expect(authBuilder.buildLibrary).toHaveBeenNthCalledWith(1, 'openzeppelin::auth::guardian', GUARDIAN_MASM);
89
- expect(authBuilder.buildLibrary).toHaveBeenNthCalledWith(2, 'openzeppelin::auth::multisig', MULTISIG_MASM);
89
+ expect(authBuilder.linkModule).toHaveBeenNthCalledWith(1, 'openzeppelin::auth::guardian', GUARDIAN_MASM);
90
+ expect(authBuilder.linkModule).toHaveBeenNthCalledWith(2, 'openzeppelin::auth::multisig', MULTISIG_MASM);
90
91
  expect(authBuilder.compileAccountComponentCode).toHaveBeenCalledWith(MULTISIG_GUARDIAN_ACCOUNT_COMPONENT_MASM);
91
- expect(webClient.newAccount).toHaveBeenCalledTimes(1);
92
+ expect(webClient.accounts.insert).toHaveBeenCalledTimes(1);
92
93
  });
93
94
  it('uses ECDSA MASM when requested', async () => {
94
95
  const authBuilder = {
95
- buildLibrary: vi.fn((libraryPath, source) => ({ libraryPath, source })),
96
- linkStaticLibrary: vi.fn(),
97
- compileAccountComponentCode: vi.fn((source) => `auth:${source.slice(0, 16)}`),
96
+ linkModule: vi.fn(),
97
+ compileAccountComponentCode: vi.fn((source) => ({ source })),
98
98
  };
99
99
  const webClient = {
100
100
  createCodeBuilder: vi.fn().mockReturnValue(authBuilder),
101
- newAccount: vi.fn(),
101
+ accounts: {
102
+ insert: vi.fn().mockResolvedValue(undefined),
103
+ },
102
104
  };
103
105
  await createMultisigAccount(webClient, {
104
106
  threshold: 1,
@@ -106,10 +108,10 @@ describe('createMultisigAccount', () => {
106
108
  guardianCommitment: '0x' + '2'.repeat(64),
107
109
  signatureScheme: 'ecdsa',
108
110
  });
109
- expect(authBuilder.buildLibrary).toHaveBeenNthCalledWith(1, 'openzeppelin::auth::guardian_ecdsa', GUARDIAN_ECDSA_MASM);
110
- expect(authBuilder.buildLibrary).toHaveBeenNthCalledWith(2, 'openzeppelin::auth::multisig_ecdsa', MULTISIG_ECDSA_MASM);
111
+ expect(authBuilder.linkModule).toHaveBeenNthCalledWith(1, 'openzeppelin::auth::guardian_ecdsa', GUARDIAN_ECDSA_MASM);
112
+ expect(authBuilder.linkModule).toHaveBeenNthCalledWith(2, 'openzeppelin::auth::multisig_ecdsa', MULTISIG_ECDSA_MASM);
111
113
  expect(authBuilder.compileAccountComponentCode).toHaveBeenCalledWith(MULTISIG_GUARDIAN_ECDSA_ACCOUNT_COMPONENT_MASM);
112
- expect(webClient.newAccount).toHaveBeenCalledTimes(1);
114
+ expect(webClient.accounts.insert).toHaveBeenCalledTimes(1);
113
115
  });
114
116
  });
115
117
  //# 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,OAAO,EACL,mBAAmB,EACnB,aAAa,EACb,mBAAmB,EACnB,aAAa,GACd,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,wCAAwC,EACxC,8CAA8C,GAC/C,MAAM,mCAAmC,CAAC;AAE3C,MAAM,EACJ,yBAAyB,EACzB,yBAAyB,EACzB,oBAAoB,EACpB,gBAAgB,EAChB,kBAAkB,GACnB,GAAG,EAAE,CAAC,OAAO,CAAC,GAAG,EAAE;IAClB,MAAM,yBAAyB,GAAG,EAAE,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC;IAClE,MAAM,yBAAyB,GAAG,EAAE,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC;IAClE,MAAM,oBAAoB,GAAG,EAAE,CAAC,EAAE,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,SAAS,CAAC,CAAC;IAC7D,MAAM,gBAAgB,GAAG,EAAE,CAAC,EAAE,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC;QAC/C,IAAI;QACJ,KAAK;QACL,oBAAoB,EAAE,GAAG,EAAE,CAAC,oBAAoB,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;KAClE,CAAC,CAAC,CAAC;IAEJ,MAAM,kBAAkB;QACtB,WAAW;YACT,OAAO,IAAI,CAAC;QACd,CAAC;QAED,WAAW;YACT,OAAO,IAAI,CAAC;QACd,CAAC;QAED,iBAAiB;YACf,OAAO,I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AAE;YACnB,2BAA2B,EAAE,EAAE,CAAC,EAAE,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC;SAC7D,CAAC;QACF,MAAM,SAAS,GAAG;YAChB,iBAAiB,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC,eAAe,CAAC,WAAW,CAAC;YACvD,QAAQ,EAAE;gBACR,MAAM,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC,iBAAiB,CAAC,SAAS,CAAC;aAC7C;SACF,CAAC;QAEF,MAAM,qBAAqB,CAAC,SAAkB,EAAE;YAC9C,SAAS,EAAE,CAAC;YACZ,iBAAiB,EAAE,CAAC,IAAI,GAAG,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;YAC1C,kBAAkB,EAAE,IAAI,GAAG,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC;YACzC,eAAe,EAAE,OAAO;SACzB,CAAC,CAAC;QAEH,MAAM,CAAC,WAAW,CAAC,UAAU,CAAC,CAAC,uBAAuB,CACpD,CAAC,EACD,oCAAoC,EACpC,mBAAmB,CACpB,CAAC;QACF,MAAM,CAAC,WAAW,CAAC,UAAU,CAAC,CAAC,uBAAuB,CACpD,CAAC,EACD,oCAAoC,EACpC,mBAAmB,CACpB,CAAC;QACF,MAAM,CAAC,WAAW,CAAC,2BAA2B,CAAC,CAAC,oBAAoB,CAClE,8CAA8C,CAC/C,CAAC;QACF,MAAM,CAAC,SAAS,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAC;IAC7D,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -1,5 +1,5 @@
1
- export declare const MULTISIG_ACCOUNT_COMPONENT_MASM = "# Multi-Signature RPO Falcon 512 Authentication Component\n\nuse openzeppelin::auth::multisig\n\ntype BeWord = struct @bigendian { a: felt, b: felt, c: felt, d: felt }\n\npub use multisig::update_signers_and_threshold\npub use multisig::update_procedure_threshold\n\npub proc auth_tx_multisig(salt: BeWord)\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\ntype BeWord = struct @bigendian { a: felt, b: felt, c: felt, d: felt }\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\npub proc auth_tx_multisig_guardian(salt: BeWord)\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\ntype BeWord = struct @bigendian { a: felt, b: felt, c: felt, d: felt }\n\npub use multisig_ecdsa::update_signers_and_threshold\npub use multisig_ecdsa::update_procedure_threshold\n\npub proc auth_tx_multisig_ecdsa(salt: BeWord)\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\ntype BeWord = struct @bigendian { a: felt, b: felt, c: felt, d: felt }\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\npub proc auth_tx_multisig_guardian_ecdsa(salt: BeWord)\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 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";
5
5
  //# 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,4XAa3C,CAAC;AAEF,eAAO,MAAM,wCAAwC,8jBAiBpD,CAAC;AAEF,eAAO,MAAM,qCAAqC,iaAajD,CAAC;AAEF,eAAO,MAAM,8CAA8C,2nBAiB1D,CAAC"}
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"}
@@ -4,12 +4,11 @@ export const MULTISIG_ACCOUNT_COMPONENT_MASM = `# Multi-Signature RPO Falcon 512
4
4
 
5
5
  use openzeppelin::auth::multisig
6
6
 
7
- type BeWord = struct @bigendian { a: felt, b: felt, c: felt, d: felt }
8
-
9
7
  pub use multisig::update_signers_and_threshold
10
8
  pub use multisig::update_procedure_threshold
11
9
 
12
- pub proc auth_tx_multisig(salt: BeWord)
10
+ @auth_script
11
+ pub proc auth_tx_multisig(salt: word)
13
12
  exec.multisig::auth_tx
14
13
  exec.multisig::assert_new_tx
15
14
  end
@@ -19,14 +18,13 @@ export const MULTISIG_GUARDIAN_ACCOUNT_COMPONENT_MASM = `# Multi-Signature RPO F
19
18
  use openzeppelin::auth::multisig
20
19
  use openzeppelin::auth::guardian
21
20
 
22
- type BeWord = struct @bigendian { a: felt, b: felt, c: felt, d: felt }
23
-
24
21
  pub use multisig::update_signers_and_threshold
25
22
  pub use multisig::update_procedure_threshold
26
23
  pub use guardian::update_guardian_public_key
27
24
  pub use guardian::verify_guardian_signature
28
25
 
29
- pub proc auth_tx_multisig_guardian(salt: BeWord)
26
+ @auth_script
27
+ pub proc auth_tx_multisig_guardian(salt: word)
30
28
  exec.multisig::auth_tx
31
29
  exec.guardian::verify_guardian_signature
32
30
  exec.multisig::assert_new_tx
@@ -36,12 +34,11 @@ export const MULTISIG_ECDSA_ACCOUNT_COMPONENT_MASM = `# Multi-Signature ECDSA se
36
34
 
37
35
  use openzeppelin::auth::multisig_ecdsa
38
36
 
39
- type BeWord = struct @bigendian { a: felt, b: felt, c: felt, d: felt }
40
-
41
37
  pub use multisig_ecdsa::update_signers_and_threshold
42
38
  pub use multisig_ecdsa::update_procedure_threshold
43
39
 
44
- pub proc auth_tx_multisig_ecdsa(salt: BeWord)
40
+ @auth_script
41
+ pub proc auth_tx_multisig_ecdsa(salt: word)
45
42
  exec.multisig_ecdsa::auth_tx
46
43
  exec.multisig_ecdsa::assert_new_tx
47
44
  end
@@ -51,14 +48,13 @@ export const MULTISIG_GUARDIAN_ECDSA_ACCOUNT_COMPONENT_MASM = `# Multi-Signature
51
48
  use openzeppelin::auth::multisig_ecdsa
52
49
  use openzeppelin::auth::guardian_ecdsa
53
50
 
54
- type BeWord = struct @bigendian { a: felt, b: felt, c: felt, d: felt }
55
-
56
51
  pub use multisig_ecdsa::update_signers_and_threshold
57
52
  pub use multisig_ecdsa::update_procedure_threshold
58
53
  pub use guardian_ecdsa::update_guardian_public_key
59
54
  pub use guardian_ecdsa::verify_guardian_signature
60
55
 
61
- pub proc auth_tx_multisig_guardian_ecdsa(salt: BeWord)
56
+ @auth_script
57
+ pub proc auth_tx_multisig_guardian_ecdsa(salt: word)
62
58
  exec.multisig_ecdsa::auth_tx
63
59
  exec.guardian_ecdsa::verify_guardian_signature
64
60
  exec.multisig_ecdsa::assert_new_tx
@@ -1 +1 @@
1
- {"version":3,"file":"auth.js","sourceRoot":"","sources":["../../../../src/account/masm/account-components/auth.ts"],"names":[],"mappings":"AAAA,sFAAsF;AACtF,0BAA0B;AAE1B,MAAM,CAAC,MAAM,+BAA+B,GAAG;;;;;;;;;;;;;CAa9C,CAAC;AAEF,MAAM,CAAC,MAAM,wCAAwC,GAAG;;;;;;;;;;;;;;;;;CAiBvD,CAAC;AAEF,MAAM,CAAC,MAAM,qCAAqC,GAAG;;;;;;;;;;;;;CAapD,CAAC;AAEF,MAAM,CAAC,MAAM,8CAA8C,GAAG;;;;;;;;;;;;;;;;;CAiB7D,CAAC"}
1
+ {"version":3,"file":"auth.js","sourceRoot":"","sources":["../../../../src/account/masm/account-components/auth.ts"],"names":[],"mappings":"AAAA,sFAAsF;AACtF,0BAA0B;AAE1B,MAAM,CAAC,MAAM,+BAA+B,GAAG;;;;;;;;;;;;CAY9C,CAAC;AAEF,MAAM,CAAC,MAAM,wCAAwC,GAAG;;;;;;;;;;;;;;;;CAgBvD,CAAC;AAEF,MAAM,CAAC,MAAM,qCAAqC,GAAG;;;;;;;;;;;;CAYpD,CAAC;AAEF,MAAM,CAAC,MAAM,8CAA8C,GAAG;;;;;;;;;;;;;;;;CAgB7D,CAAC"}
@@ -1,5 +1,5 @@
1
- export declare const MULTISIG_MASM = "# Multi-Signature RPO Falcon 512 Authentication Core Library\n#\n# This library provides the reusable multisig procedures used by account wrappers.\n\nuse miden::protocol::active_account\nuse miden::protocol::native_account\nuse miden::standards::auth\n\ntype BeWord = struct @bigendian { a: felt, b: felt, c: felt, d: felt }\n\n# CONSTANTS\n# =================================================================================================\n\n# Auth Request Constants\n\n# The event emitted when a signature is not found for a required signer.\nconst AUTH_UNAUTHORIZED_EVENT=event(\"miden::auth::unauthorized\")\n\n# Storage Layout Constants\n#\n# +-------------------------------+----------+--------------+-------------------+\n# | THRESHOLD & APPROVERS CONFIG | PUB KEYS | EXECUTED TXS | PROC THRESHOLDS |\n# | (slot) | (map) | (map) | (map) |\n# +-------------------------------+----------+--------------+-------------------+\n# | 0 | 1 | 2 | 3 |\n# +-------------------------------+----------+--------------+-------------------+\n\n# The slot in this component's storage layout where the default signature threshold and\n# number of approvers are stored as:\n# [default_threshold, num_approvers, 0, 0].\n# The threshold is guaranteed to be less than or equal to num_approvers.\nconst THRESHOLD_CONFIG_SLOT=word(\"openzeppelin::multisig::threshold_config\")\n\n# The slot in this component's storage layout where the public keys map is stored.\n# Map entries: [key_index, 0, 0, 0] => APPROVER_PUBLIC_KEY\nconst PUBLIC_KEYS_MAP_SLOT=word(\"openzeppelin::multisig::signer_public_keys\")\n\n# The slot in this component's storage layout where executed transactions are stored.\n# Map entries: transaction_message => [is_executed, 0, 0, 0]\nconst EXECUTED_TXS_SLOT=word(\"openzeppelin::multisig::executed_transactions\")\n\n# The slot in this component's storage layout where procedure thresholds are stored.\n# Map entries: PROC_ROOT => [proc_threshold, 0, 0, 0]\nconst PROC_THRESHOLD_ROOTS_SLOT=word(\"openzeppelin::multisig::procedure_thresholds\")\n\n# Executed Transaction Flag Constant\nconst IS_EXECUTED_FLAG=[1, 0, 0, 0]\n\n# ERRORS\nconst ERR_TX_ALREADY_EXECUTED=\"failed to approve multisig transaction as it was already executed\"\n\nconst ERR_MALFORMED_MULTISIG_CONFIG=\"number of approvers must be equal to or greater than threshold\"\n\nconst ERR_ZERO_IN_MULTISIG_CONFIG=\"number of approvers or threshold must not be zero\"\n\nconst ERR_PROC_THRESHOLD_NOT_U32=\"procedure threshold must be a u32 value\"\n\nconst ERR_NUM_APPROVERS_OR_PROC_THRESHOLD_NOT_U32=\"number of approvers and procedure threshold must be u32\"\n\nconst ERR_PROC_THRESHOLD_EXCEEDS_NUM_APPROVERS=\"procedure threshold exceeds number of approvers\"\n\n# MULTISIG PROCEDURES\n# =================================================================================================\n\n#! Check if transaction has already been executed and add it to executed transactions for replay protection.\n#!\n#! Inputs: [MSG]\n#! Outputs: []\n#!\n#! Panics if:\n#! - the same transaction has already been executed\npub proc assert_new_tx(msg: BeWord)\n push.IS_EXECUTED_FLAG\n # => [[0, 0, 0, is_executed], MSG]\n\n swapw\n # => [MSG, IS_EXECUTED_FLAG]\n\n push.EXECUTED_TXS_SLOT[0..2]\n # => [txs_slot_prefix, txs_slot_suffix, MSG, IS_EXECUTED_FLAG]\n\n # Set the key value pair in the map to mark transaction as executed\n exec.native_account::set_map_item\n # => [[0, 0, 0, is_executed]]\n\n drop drop drop\n # => [is_executed]\n\n assertz.err=ERR_TX_ALREADY_EXECUTED\n # => []\nend\n\n#! Remove old approver public keys from the approver public key mapping.\n#!\n#! This procedure cleans up the storage by removing public keys of approvers that are no longer\n#! part of the multisig configuration. This procedure assumes that init_num_of_approvers and\n#! new_num_of_approvers are u32 values.\n#!\n#! Inputs: [init_num_of_approvers, new_num_of_approvers]\n#! Outputs: []\n#!\n#! Where:\n#! - init_num_of_approvers is the original number of approvers before the update\n#! - new_num_of_approvers is the new number of approvers after the update\nproc cleanup_pubkey_mapping(init_num_of_approvers: u32, new_num_of_approvers: u32)\n dup.1 dup.1\n u32assert2 u32lt\n # => [should_loop, i = init_num_of_approvers, new_num_of_approvers]\n\n while.true\n # => [i, new_num_of_approvers]\n\n sub.1\n # => [i-1, new_num_of_approvers]\n\n dup\n # => [i-1, i-1, new_num_of_approvers]\n\n push.0.0.0\n # => [[0, 0, 0, i-1], i-1, new_num_of_approvers]\n\n padw swapw\n # => [[0, 0, 0, i-1], EMPTY_WORD, i-1, new_num_of_approvers]\n\n push.PUBLIC_KEYS_MAP_SLOT[0..2]\n # => [pub_key_slot_prefix, pub_key_slot_suffix, [0, 0, 0, i-1], EMPTY_WORD, i-1, new_num_of_approvers]\n\n exec.native_account::set_map_item\n # => [OLD_MAP_VALUE, i-1, new_num_of_approvers]\n\n dropw\n # => [i-1, new_num_of_approvers]\n\n dup.1 dup.1\n u32lt\n # => [should_loop, i-1, new_num_of_approvers]\n end\n\n drop drop\n # => []\nend\n\nproc get_threshold_and_num_approvers\n push.THRESHOLD_CONFIG_SLOT[0..2]\n exec.active_account::get_initial_item\n # => [0, 0, num_approvers, threshold]\n\n drop drop\n # => [num_approvers, threshold]\n\n swap\n # => [threshold, num_approvers]\nend\n\nproc assert_proc_thresholds_lte_num_approvers(num_approvers: u32)\n exec.active_account::get_num_procedures\n # => [num_procedures, num_approvers]\n\n dup neq.0\n # => [should_continue, num_procedures, num_approvers]\n while.true\n sub.1 dup\n # => [proc_index, proc_index, num_approvers]\n\n exec.active_account::get_procedure_root\n # => [PROC_ROOT, proc_index, num_approvers]\n\n push.PROC_THRESHOLD_ROOTS_SLOT[0..2]\n # => [proc_roots_slot_prefix, proc_roots_slot_suffix, PROC_ROOT, proc_index, num_approvers]\n\n exec.active_account::get_initial_map_item\n # => [[0, 0, 0, proc_threshold], proc_index, num_approvers]\n\n drop drop drop\n # => [proc_threshold, proc_index, num_approvers]\n\n dup.2\n # => [num_approvers, proc_threshold, proc_index, num_approvers]\n\n u32assert2.err=ERR_PROC_THRESHOLD_NOT_U32\n u32gt assertz.err=ERR_PROC_THRESHOLD_EXCEEDS_NUM_APPROVERS\n # => [proc_index, num_approvers]\n\n dup neq.0\n # => [should_continue, proc_index, num_approvers]\n end\n\n drop drop\n # => []\nend\n\n# Internal storage helper used by the public `update_procedure_threshold`\n# entrypoint after it receives direct stack arguments.\nproc set_procedure_threshold(proc_threshold: u32, proc_root: BeWord)\n exec.get_threshold_and_num_approvers\n # => [threshold, num_approvers, proc_threshold, PROC_ROOT]\n\n drop\n # => [num_approvers, proc_threshold, PROC_ROOT]\n\n dup.1 swap\n # => [num_approvers, proc_threshold, proc_threshold, PROC_ROOT]\n\n u32assert2.err=ERR_NUM_APPROVERS_OR_PROC_THRESHOLD_NOT_U32\n u32gt assertz.err=ERR_PROC_THRESHOLD_EXCEEDS_NUM_APPROVERS\n # => [proc_threshold, PROC_ROOT]\n\n push.0.0.0\n swapw\n # => [PROC_ROOT, PROC_THRESHOLD_WORD]\n\n push.PROC_THRESHOLD_ROOTS_SLOT[0..2]\n # => [proc_roots_slot_prefix, proc_roots_slot_suffix, PROC_ROOT, PROC_THRESHOLD_WORD]\n\n exec.native_account::set_map_item\n # => [OLD_VALUE]\n\n dropw\n # => []\nend\n\n#! Update threshold config and add / remove approvers\n#!\n#! Inputs:\n#! Operand stack: [MULTISIG_CONFIG_HASH, pad(12)]\n#! Advice map: {\n#! MULTISIG_CONFIG_HASH => [CONFIG, PUB_KEY_N, PUB_KEY_N-1, ..., PUB_KEY_0]\n#! }\n#! Outputs:\n#! Operand stack: [TX_SUMMARY_COMMITMENT]\n#!\n#! Where:\n#! - MULTISIG_CONFIG_HASH is the hash of the threshold and new public key vector\n#! - MULTISIG_CONFIG is [threshold, num_approvers, 0, 0]\n#! - PUB_KEY_i is the public key of the i-th signer\n#!\n#! Locals:\n#! 0: new_num_of_approvers\n#! 1: init_num_of_approvers\n@locals(2)\npub proc update_signers_and_threshold(multisig_config_hash: BeWord)\n adv.push_mapval\n # => [MULTISIG_CONFIG_HASH, pad(12)]\n\n adv_loadw\n # => [MULTISIG_CONFIG, pad(12)]\n\n # store new_num_of_approvers for later\n dup.2 loc_store.0\n # => [MULTISIG_CONFIG, pad(12)]\n\n dup.3 dup.3\n # => [num_approvers, threshold, MULTISIG_CONFIG, pad(12)]\n\n # make sure that the threshold is smaller than the number of approvers\n u32assert2.err=ERR_MALFORMED_MULTISIG_CONFIG\n u32gt assertz.err=ERR_MALFORMED_MULTISIG_CONFIG\n # => [MULTISIG_CONFIG, pad(12)]\n\n dup.3 dup.3\n # => [num_approvers, threshold, MULTISIG_CONFIG, pad(12)]\n\n # make sure that threshold or num_approvers are not zero\n eq.0 assertz.err=ERR_ZERO_IN_MULTISIG_CONFIG\n eq.0 assertz.err=ERR_ZERO_IN_MULTISIG_CONFIG\n # => [MULTISIG_CONFIG, pad(12)]\n\n loc_load.0\n # => [num_approvers, MULTISIG_CONFIG, pad(12)]\n\n exec.assert_proc_thresholds_lte_num_approvers\n # => [MULTISIG_CONFIG, pad(12)]\n\n push.THRESHOLD_CONFIG_SLOT[0..2]\n # => [config_slot_prefix, config_slot_suffix, MULTISIG_CONFIG, pad(12)]\n\n exec.native_account::set_item\n # => [OLD_THRESHOLD_CONFIG, pad(12)]\n\n # store init_num_of_approvers for later\n drop drop loc_store.1 drop\n # => [pad(12)]\n\n loc_load.0\n # => [num_approvers]\n\n dup neq.0\n while.true\n sub.1\n # => [i-1, pad(12)]\n\n dup push.0.0.0\n # => [[0, 0, 0, i-1], i-1, pad(12)]\n\n padw adv_loadw\n # => [PUB_KEY, [0, 0, 0, i-1], i-1, pad(12)]\n\n swapw\n # => [[0, 0, 0, i-1], PUB_KEY, i-1, pad(12)]\n\n push.PUBLIC_KEYS_MAP_SLOT[0..2]\n # => [pub_key_slot_prefix, pub_key_slot_suffix, [0, 0, 0, i-1], PUB_KEY, i-1, pad(12)]\n\n exec.native_account::set_map_item\n # => [OLD_VALUE, i-1, pad(12)]\n\n dropw\n # => [i-1, pad(12)]\n\n dup neq.0\n # => [is_non_zero, i-1, pad(12)]\n end\n # => [pad(13)]\n\n drop\n # => [pad(12)]\n\n # compare initial vs current multisig config\n\n # load init_num_of_approvers & new_num_of_approvers\n loc_load.0 loc_load.1\n # => [init_num_of_approvers, new_num_of_approvers, pad(12)]\n\n exec.cleanup_pubkey_mapping\n # => [pad(12)]\nend\n\n#! Update or clear the threshold override for a specific procedure.\n#!\n#! Inputs:\n#! Operand stack: [proc_threshold, PROC_ROOT]\n#! Outputs:\n#! Operand stack: []\n#! Invocation: call\npub proc update_procedure_threshold(proc_threshold: u32, proc_root: BeWord)\n exec.set_procedure_threshold\nend\n\n# Computes the effective transaction threshold based on called procedures and per-procedure\n# overrides stored in PROC_THRESHOLD_ROOTS_SLOT. Falls back to default_threshold if no\n# overrides apply.\n#\n#! Inputs: [default_threshold]\n#! Outputs: [transaction_threshold]\n@locals(1)\nproc compute_transaction_threshold(default_threshold: u32) -> u32\n # 1. initialize transaction_threshold = 0\n # 2. iterate through all account procedures\n # a. check if the procedure was called during the transaction\n # b. if called, get the override threshold of that procedure from the config map\n # c. if proc_threshold > transaction_threshold, set transaction_threshold = proc_threshold\n # 3. if transaction_threshold == 0 at the end, revert to using default_threshold\n\n # store default_threshold for later\n loc_store.0\n # => []\n\n # 1. initialize transaction_threshold = 0\n push.0\n # => [transaction_threshold]\n\n # get the number of account procedures\n exec.active_account::get_num_procedures\n # => [num_procedures, transaction_threshold]\n\n # 2. iterate through all account procedures\n dup neq.0\n # => [should_continue, num_procedures, transaction_threshold]\n while.true\n sub.1 dup\n # => [num_procedures-1, num_procedures-1, transaction_threshold]\n\n # get procedure root of the procedure with index i\n exec.active_account::get_procedure_root dupw\n # => [PROC_ROOT, PROC_ROOT, num_procedures-1, transaction_threshold]\n\n # 2a. check if this procedure has been called in the transaction\n exec.native_account::was_procedure_called\n # => [was_called, PROC_ROOT, num_procedures-1, transaction_threshold]\n\n # if it has been called, get the override threshold of that procedure\n if.true\n # => [PROC_ROOT, num_procedures-1, transaction_threshold]\n\n push.PROC_THRESHOLD_ROOTS_SLOT[0..2]\n # => [PROC_THRESHOLD_ROOTS_SLOT_prefix, PROC_THRESHOLD_ROOTS_SLOT_suffix, PROC_ROOT, num_procedures-1, transaction_threshold]\n\n # 2b. get the override proc_threshold of that procedure\n # if the procedure has no override threshold, the returned map item will be [0, 0, 0, 0]\n exec.active_account::get_initial_map_item\n # => [[0, 0, 0, proc_threshold], num_procedures-1, transaction_threshold]\n\n drop drop drop dup dup.3\n # => [transaction_threshold, proc_threshold, proc_threshold, num_procedures-1, transaction_threshold]\n\n u32assert2.err=\"transaction threshold or procedure threshold are not u32\"\n u32gt\n # => [is_gt, proc_threshold, num_procedures-1, transaction_threshold]\n # 2c. if proc_threshold > transaction_threshold, update transaction_threshold\n movup.2 movdn.3\n # => [is_gt, proc_threshold, transaction_threshold, num_procedures-1]\n cdrop\n # => [updated_transaction_threshold, num_procedures-1]\n swap\n # => [num_procedures-1, updated_transaction_threshold]\n # if it has not been called during this transaction, nothing to do, move to the next procedure\n else\n dropw\n # => [num_procedures-1, transaction_threshold]\n end\n\n dup neq.0\n # => [should_continue, num_procedures-1, transaction_threshold]\n end\n\n drop\n # => [transaction_threshold]\n\n loc_load.0\n # => [default_threshold, transaction_threshold]\n\n # 3. if transaction_threshold == 0 at the end, revert to using default_threshold\n dup.1 eq.0\n # => [is_zero, default_threshold, transaction_threshold]\n\n cdrop\n # => [effective_transaction_threshold]\nend\n\n#! Authenticate a transaction using the Falcon signature scheme with multi-signature support.\n#!\n#! This procedure implements multi-signature authentication by:\n#! 1. Computing the transaction summary message that needs to be signed\n#! 2. Verifying signatures from multiple required signers against their public keys\n#! 3. Ensuring the minimum threshold of valid signatures is met\n#! 4. Returning the transaction summary commitment for higher-level wrappers.\n#!\n#! Inputs:\n#! Operand stack: [SALT]\n#! Advice map: {\n#! h(SIG_0, MSG): SIG_0,\n#! h(SIG_1, MSG): SIG_1,\n#! h(SIG_n, MSG): SIG_n\n#! }\n#! Outputs:\n#! Operand stack: []\n#!\n#! Where:\n#! - SALT is a cryptographically random nonce that enables multiple concurrent\n#! multisig transactions while maintaining replay protection. Each transaction\n#! must use a unique SALT value to ensure transaction uniqueness.\n#! - SIG_i is the signature from the i-th signer.\n#! - MSG is the transaction message being signed.\n#! - h(SIG_i, MSG) is the hash of the signature and message used as the advice map key.\n#!\n#! Panics if:\n#! - insufficient number of valid signatures (below threshold).\n#! - insufficient number of valid signatures (below threshold).\n#!\n#! Invocation: exec\n@locals(1)\npub proc auth_tx(salt: BeWord) -> BeWord\n exec.native_account::incr_nonce drop\n # => [SALT]\n\n # ------ Computing transaction summary ------\n\n exec.auth::create_tx_summary\n # => [SALT, OUTPUT_NOTES_COMMITMENT, INPUT_NOTES_COMMITMENT, ACCOUNT_DELTA_COMMITMENT]\n\n # to build a tx_summary in the host, we need these four words in the advice provider\n exec.auth::adv_insert_hqword\n # => [SALT, OUTPUT_NOTES_COMMITMENT, INPUT_NOTES_COMMITMENT, ACCOUNT_DELTA_COMMITMENT]\n\n # the commitment to the tx summary is the message that is signed\n exec.auth::hash_tx_summary\n # => [TX_SUMMARY_COMMITMENT]\n\n # ------ Verifying approver signatures ------\n\n push.THRESHOLD_CONFIG_SLOT[0..2]\n # => [config_slot_prefix, config_slot_suffix, TX_SUMMARY_COMMITMENT]\n\n exec.active_account::get_initial_item\n # => [0, 0, num_of_approvers, default_threshold, TX_SUMMARY_COMMITMENT]\n\n drop drop\n # => [num_of_approvers, default_threshold, TX_SUMMARY_COMMITMENT]\n\n swap movdn.5\n # => [num_of_approvers, TX_SUMMARY_COMMITMENT, default_threshold]\n\n push.PUBLIC_KEYS_MAP_SLOT[0..2]\n # => [pub_key_slot_prefix, pub_key_slot_suffix, num_of_approvers, TX_SUMMARY_COMMITMENT, default_threshold]\n\n exec.::miden::standards::auth::falcon512_rpo::verify_signatures\n # => [num_verified_signatures, TX_SUMMARY_COMMITMENT, default_threshold]\n\n # ------ Checking threshold is >= num_verified_signatures ------\n\n movup.5\n # => [default_threshold, num_verified_signatures, TX_SUMMARY_COMMITMENT]\n\n exec.compute_transaction_threshold\n # => [transaction_threshold, num_verified_signatures, TX_SUMMARY_COMMITMENT]\n\n u32assert2 u32lt\n # => [is_unauthorized, TX_SUMMARY_COMMITMENT]\n\n # If signatures are non-existent the tx will fail here.\n if.true\n emit.AUTH_UNAUTHORIZED_EVENT\n push.0 assert.err=\"insufficient number of signatures\"\n end\n\n # => [TX_SUMMARY_COMMITMENT]\nend\n";
2
- export declare const MULTISIG_ECDSA_MASM = "# Multi-Signature ECDSA secp256k1 Authentication Core Library\n#\n# This library provides the reusable multisig procedures used by account wrappers.\n\nuse miden::protocol::active_account\nuse miden::protocol::native_account\nuse miden::standards::auth\ntype BeWord = struct @bigendian { a: felt, b: felt, c: felt, d: felt }\n\n# CONSTANTS\n# =================================================================================================\n\n# Auth Request Constants\n\n# The event emitted when a signature is not found for a required signer.\nconst AUTH_UNAUTHORIZED_EVENT=event(\"miden::auth::unauthorized\")\n\n# Storage Layout Constants\n#\n# +-------------------------------+----------+--------------+-------------------+\n# | THRESHOLD & APPROVERS CONFIG | PUB KEYS | EXECUTED TXS | PROC THRESHOLDS |\n# | (slot) | (map) | (map) | (map) |\n# +-------------------------------+----------+--------------+-------------------+\n# | 0 | 1 | 2 | 3 |\n# +-------------------------------+----------+--------------+-------------------+\n\n# The slot in this component's storage layout where the default signature threshold and\n# number of approvers are stored as:\n# [default_threshold, num_approvers, 0, 0].\n# The threshold is guaranteed to be less than or equal to num_approvers.\nconst THRESHOLD_CONFIG_SLOT=word(\"openzeppelin::multisig::threshold_config\")\n\n# The slot in this component's storage layout where the public keys map is stored.\n# Map entries: [key_index, 0, 0, 0] => APPROVER_PUBLIC_KEY\nconst PUBLIC_KEYS_MAP_SLOT=word(\"openzeppelin::multisig::signer_public_keys\")\n\n# The slot in this component's storage layout where executed transactions are stored.\n# Map entries: transaction_message => [is_executed, 0, 0, 0]\nconst EXECUTED_TXS_SLOT=word(\"openzeppelin::multisig::executed_transactions\")\n\n# The slot in this component's storage layout where procedure thresholds are stored.\n# Map entries: PROC_ROOT => [proc_threshold, 0, 0, 0]\nconst PROC_THRESHOLD_ROOTS_SLOT=word(\"openzeppelin::multisig::procedure_thresholds\")\n\n# Executed Transaction Flag Constant\nconst IS_EXECUTED_FLAG=[1, 0, 0, 0]\n\n# ERRORS\nconst ERR_TX_ALREADY_EXECUTED=\"failed to approve multisig transaction as it was already executed\"\n\nconst ERR_MALFORMED_MULTISIG_CONFIG=\"number of approvers must be equal to or greater than threshold\"\n\nconst ERR_ZERO_IN_MULTISIG_CONFIG=\"number of approvers or threshold must not be zero\"\n\nconst ERR_PROC_THRESHOLD_NOT_U32=\"procedure threshold must be a u32 value\"\n\nconst ERR_NUM_APPROVERS_OR_PROC_THRESHOLD_NOT_U32=\"number of approvers and procedure threshold must be u32\"\n\nconst ERR_PROC_THRESHOLD_EXCEEDS_NUM_APPROVERS=\"procedure threshold exceeds number of approvers\"\n\n# MULTISIG PROCEDURES\n# =================================================================================================\n\n#! Check if transaction has already been executed and add it to executed transactions for replay protection.\n#!\n#! Inputs: [MSG]\n#! Outputs: []\n#!\n#! Panics if:\n#! - the same transaction has already been executed\npub proc assert_new_tx(msg: BeWord)\n push.IS_EXECUTED_FLAG\n # => [[0, 0, 0, is_executed], MSG]\n\n swapw\n # => [MSG, IS_EXECUTED_FLAG]\n\n push.EXECUTED_TXS_SLOT[0..2]\n # => [txs_slot_prefix, txs_slot_suffix, MSG, IS_EXECUTED_FLAG]\n\n # Set the key value pair in the map to mark transaction as executed\n exec.native_account::set_map_item\n # => [[0, 0, 0, is_executed]]\n\n drop drop drop\n # => [is_executed]\n\n assertz.err=ERR_TX_ALREADY_EXECUTED\n # => []\nend\n\n#! Remove old approver public keys from the approver public key mapping.\n#!\n#! This procedure cleans up the storage by removing public keys of approvers that are no longer\n#! part of the multisig configuration. This procedure assumes that init_num_of_approvers and\n#! new_num_of_approvers are u32 values.\n#!\n#! Inputs: [init_num_of_approvers, new_num_of_approvers]\n#! Outputs: []\n#!\n#! Where:\n#! - init_num_of_approvers is the original number of approvers before the update\n#! - new_num_of_approvers is the new number of approvers after the update\nproc cleanup_pubkey_mapping(init_num_of_approvers: u32, new_num_of_approvers: u32)\n dup.1 dup.1\n u32assert2 u32lt\n # => [should_loop, i = init_num_of_approvers, new_num_of_approvers]\n\n while.true\n # => [i, new_num_of_approvers]\n\n sub.1\n # => [i-1, new_num_of_approvers]\n\n dup\n # => [i-1, i-1, new_num_of_approvers]\n\n push.0.0.0\n # => [[0, 0, 0, i-1], i-1, new_num_of_approvers]\n\n padw swapw\n # => [[0, 0, 0, i-1], EMPTY_WORD, i-1, new_num_of_approvers]\n\n push.PUBLIC_KEYS_MAP_SLOT[0..2]\n # => [pub_key_slot_prefix, pub_key_slot_suffix, [0, 0, 0, i-1], EMPTY_WORD, i-1, new_num_of_approvers]\n\n exec.native_account::set_map_item\n # => [OLD_MAP_VALUE, i-1, new_num_of_approvers]\n\n dropw\n # => [i-1, new_num_of_approvers]\n\n dup.1 dup.1\n u32lt\n # => [should_loop, i-1, new_num_of_approvers]\n end\n\n drop drop\n # => []\nend\n\nproc get_threshold_and_num_approvers\n push.THRESHOLD_CONFIG_SLOT[0..2]\n exec.active_account::get_initial_item\n # => [0, 0, num_approvers, threshold]\n\n drop drop\n # => [num_approvers, threshold]\n\n swap\n # => [threshold, num_approvers]\nend\n\nproc assert_proc_thresholds_lte_num_approvers(num_approvers: u32)\n exec.active_account::get_num_procedures\n # => [num_procedures, num_approvers]\n\n dup neq.0\n # => [should_continue, num_procedures, num_approvers]\n while.true\n sub.1 dup\n # => [proc_index, proc_index, num_approvers]\n\n exec.active_account::get_procedure_root\n # => [PROC_ROOT, proc_index, num_approvers]\n\n push.PROC_THRESHOLD_ROOTS_SLOT[0..2]\n # => [proc_roots_slot_prefix, proc_roots_slot_suffix, PROC_ROOT, proc_index, num_approvers]\n\n exec.active_account::get_initial_map_item\n # => [[0, 0, 0, proc_threshold], proc_index, num_approvers]\n\n drop drop drop\n # => [proc_threshold, proc_index, num_approvers]\n\n dup.2\n # => [num_approvers, proc_threshold, proc_index, num_approvers]\n\n u32assert2.err=ERR_PROC_THRESHOLD_NOT_U32\n u32gt assertz.err=ERR_PROC_THRESHOLD_EXCEEDS_NUM_APPROVERS\n # => [proc_index, num_approvers]\n\n dup neq.0\n # => [should_continue, proc_index, num_approvers]\n end\n\n drop drop\n # => []\nend\n\n# Internal storage helper used by the public `update_procedure_threshold`\n# entrypoint after it receives direct stack arguments.\nproc set_procedure_threshold(proc_threshold: u32, proc_root: BeWord)\n exec.get_threshold_and_num_approvers\n # => [threshold, num_approvers, proc_threshold, PROC_ROOT]\n\n drop\n # => [num_approvers, proc_threshold, PROC_ROOT]\n\n dup.1 swap\n # => [num_approvers, proc_threshold, proc_threshold, PROC_ROOT]\n\n u32assert2.err=ERR_NUM_APPROVERS_OR_PROC_THRESHOLD_NOT_U32\n u32gt assertz.err=ERR_PROC_THRESHOLD_EXCEEDS_NUM_APPROVERS\n # => [proc_threshold, PROC_ROOT]\n\n push.0.0.0\n swapw\n # => [PROC_ROOT, PROC_THRESHOLD_WORD]\n\n push.PROC_THRESHOLD_ROOTS_SLOT[0..2]\n # => [proc_roots_slot_prefix, proc_roots_slot_suffix, PROC_ROOT, PROC_THRESHOLD_WORD]\n\n exec.native_account::set_map_item\n # => [OLD_VALUE]\n\n dropw\n # => []\nend\n\n#! Update threshold config and add / remove approvers\n#!\n#! Inputs:\n#! Operand stack: [MULTISIG_CONFIG_HASH, pad(12)]\n#! Advice map: {\n#! MULTISIG_CONFIG_HASH => [CONFIG, PUB_KEY_N, PUB_KEY_N-1, ..., PUB_KEY_0]\n#! }\n#! Outputs:\n#! Operand stack: []\n#!\n#! Where:\n#! - MULTISIG_CONFIG_HASH is the hash of the threshold and new public key vector\n#! - MULTISIG_CONFIG is [threshold, num_approvers, 0, 0]\n#! - PUB_KEY_i is the public key of the i-th signer\n#!\n#! Locals:\n#! 0: new_num_of_approvers\n#! 1: init_num_of_approvers\n@locals(2)\npub proc update_signers_and_threshold(multisig_config_hash: BeWord)\n adv.push_mapval\n # => [MULTISIG_CONFIG_HASH, pad(12)]\n\n adv_loadw\n # => [MULTISIG_CONFIG, pad(12)]\n\n # store new_num_of_approvers for later\n dup.2 loc_store.0\n # => [MULTISIG_CONFIG, pad(12)]\n\n dup.3 dup.3\n # => [num_approvers, threshold, MULTISIG_CONFIG, pad(12)]\n\n # make sure that the threshold is smaller than the number of approvers\n u32assert2.err=ERR_MALFORMED_MULTISIG_CONFIG\n u32gt assertz.err=ERR_MALFORMED_MULTISIG_CONFIG\n # => [MULTISIG_CONFIG, pad(12)]\n\n dup.3 dup.3\n # => [num_approvers, threshold, MULTISIG_CONFIG, pad(12)]\n\n # make sure that threshold or num_approvers are not zero\n eq.0 assertz.err=ERR_ZERO_IN_MULTISIG_CONFIG\n eq.0 assertz.err=ERR_ZERO_IN_MULTISIG_CONFIG\n # => [MULTISIG_CONFIG, pad(12)]\n\n loc_load.0\n # => [num_approvers, MULTISIG_CONFIG, pad(12)]\n\n exec.assert_proc_thresholds_lte_num_approvers\n # => [MULTISIG_CONFIG, pad(12)]\n\n push.THRESHOLD_CONFIG_SLOT[0..2]\n # => [config_slot_prefix, config_slot_suffix, MULTISIG_CONFIG, pad(12)]\n\n exec.native_account::set_item\n # => [OLD_THRESHOLD_CONFIG, pad(12)]\n\n # store init_num_of_approvers for later\n drop drop loc_store.1 drop\n # => [pad(12)]\n\n loc_load.0\n # => [num_approvers]\n\n dup neq.0\n while.true\n sub.1\n # => [i-1, pad(12)]\n\n dup push.0.0.0\n # => [[0, 0, 0, i-1], i-1, pad(12)]\n\n padw adv_loadw\n # => [PUB_KEY, [0, 0, 0, i-1], i-1, pad(12)]\n\n swapw\n # => [[0, 0, 0, i-1], PUB_KEY, i-1, pad(12)]\n\n push.PUBLIC_KEYS_MAP_SLOT[0..2]\n # => [pub_key_slot_prefix, pub_key_slot_suffix, [0, 0, 0, i-1], PUB_KEY, i-1, pad(12)]\n\n exec.native_account::set_map_item\n # => [OLD_VALUE, i-1, pad(12)]\n\n dropw\n # => [i-1, pad(12)]\n\n dup neq.0\n # => [is_non_zero, i-1, pad(12)]\n end\n # => [pad(13)]\n\n drop\n # => [pad(12)]\n\n # compare initial vs current multisig config\n\n # load init_num_of_approvers & new_num_of_approvers\n loc_load.0 loc_load.1\n # => [init_num_of_approvers, new_num_of_approvers, pad(12)]\n\n exec.cleanup_pubkey_mapping\n # => [pad(12)]\nend\n\n#! Update or clear the threshold override for a specific procedure.\n#!\n#! Inputs:\n#! Operand stack: [proc_threshold, PROC_ROOT]\n#! Outputs:\n#! Operand stack: []\n#! Invocation: call\npub proc update_procedure_threshold(proc_threshold: u32, proc_root: BeWord)\n exec.set_procedure_threshold\nend\n\n# Computes the effective transaction threshold based on called procedures and per-procedure\n# overrides stored in PROC_THRESHOLD_ROOTS_SLOT. Falls back to default_threshold if no\n# overrides apply.\n#\n#! Inputs: [default_threshold]\n#! Outputs: [transaction_threshold]\n@locals(1)\nproc compute_transaction_threshold(default_threshold: u32) -> u32\n # 1. initialize transaction_threshold = 0\n # 2. iterate through all account procedures\n # a. check if the procedure was called during the transaction\n # b. if called, get the override threshold of that procedure from the config map\n # c. if proc_threshold > transaction_threshold, set transaction_threshold = proc_threshold\n # 3. if transaction_threshold == 0 at the end, revert to using default_threshold\n\n # store default_threshold for later\n loc_store.0\n # => []\n\n # 1. initialize transaction_threshold = 0\n push.0\n # => [transaction_threshold]\n\n # get the number of account procedures\n exec.active_account::get_num_procedures\n # => [num_procedures, transaction_threshold]\n\n # 2. iterate through all account procedures\n dup neq.0\n # => [should_continue, num_procedures, transaction_threshold]\n while.true\n sub.1 dup\n # => [num_procedures-1, num_procedures-1, transaction_threshold]\n\n # get procedure root of the procedure with index i\n exec.active_account::get_procedure_root dupw\n # => [PROC_ROOT, PROC_ROOT, num_procedures-1, transaction_threshold]\n\n # 2a. check if this procedure has been called in the transaction\n exec.native_account::was_procedure_called\n # => [was_called, PROC_ROOT, num_procedures-1, transaction_threshold]\n\n # if it has been called, get the override threshold of that procedure\n if.true\n # => [PROC_ROOT, num_procedures-1, transaction_threshold]\n\n push.PROC_THRESHOLD_ROOTS_SLOT[0..2]\n # => [PROC_THRESHOLD_ROOTS_SLOT_prefix, PROC_THRESHOLD_ROOTS_SLOT_suffix, PROC_ROOT, num_procedures-1, transaction_threshold]\n\n # 2b. get the override proc_threshold of that procedure\n # if the procedure has no override threshold, the returned map item will be [0, 0, 0, 0]\n exec.active_account::get_initial_map_item\n # => [[0, 0, 0, proc_threshold], num_procedures-1, transaction_threshold]\n\n drop drop drop dup dup.3\n # => [transaction_threshold, proc_threshold, proc_threshold, num_procedures-1, transaction_threshold]\n\n u32assert2.err=\"transaction threshold or procedure threshold are not u32\"\n u32gt\n # => [is_gt, proc_threshold, num_procedures-1, transaction_threshold]\n # 2c. if proc_threshold > transaction_threshold, update transaction_threshold\n movup.2 movdn.3\n # => [is_gt, proc_threshold, transaction_threshold, num_procedures-1]\n cdrop\n # => [updated_transaction_threshold, num_procedures-1]\n swap\n # => [num_procedures-1, updated_transaction_threshold]\n # if it has not been called during this transaction, nothing to do, move to the next procedure\n else\n dropw\n # => [num_procedures-1, transaction_threshold]\n end\n\n dup neq.0\n # => [should_continue, num_procedures-1, transaction_threshold]\n end\n\n drop\n # => [transaction_threshold]\n\n loc_load.0\n # => [default_threshold, transaction_threshold]\n\n # 3. if transaction_threshold == 0 at the end, revert to using default_threshold\n dup.1 eq.0\n # => [is_zero, default_threshold, transaction_threshold]\n\n cdrop\n # => [effective_transaction_threshold]\nend\n\n#! Authenticate a transaction using ECDSA secp256k1 with multi-signature support.\n#!\n#! This procedure implements multi-signature authentication by:\n#! 1. Computing the transaction summary message that needs to be signed\n#! 2. Verifying ECDSA signatures from multiple required signers against their public keys\n#! 3. Ensuring the minimum threshold of valid signatures is met\n#! 4. Returning the transaction summary commitment for higher-level wrappers.\n#!\n#! Inputs:\n#! Operand stack: [SALT]\n#! Advice map: {\n#! h(PUB_KEY_0, MSG): SIG_0,\n#! h(PUB_KEY_1, MSG): SIG_1,\n#! h(PUB_KEY_n, MSG): SIG_n\n#! }\n#! Outputs:\n#! Operand stack: [TX_SUMMARY_COMMITMENT]\n#!\n#! Where:\n#! - SALT is a cryptographically random nonce that enables multiple concurrent\n#! multisig transactions while maintaining replay protection. Each transaction\n#! must use a unique SALT value to ensure transaction uniqueness.\n#! - SIG_i is the ECDSA signature from the i-th signer.\n#! - MSG is the transaction message being signed.\n#! - h(PUB_KEY_i, MSG) is the hash of the public key and message used as the advice map key.\n#!\n#! Panics if:\n#! - insufficient number of valid signatures (below threshold).\n#! - insufficient number of valid signatures (below threshold).\n#!\n#! Invocation: exec\n@locals(1)\npub proc auth_tx(salt: BeWord) -> BeWord\n exec.native_account::incr_nonce drop\n # => [SALT]\n\n # ------ Computing transaction summary ------\n\n exec.auth::create_tx_summary\n # => [SALT, OUTPUT_NOTES_COMMITMENT, INPUT_NOTES_COMMITMENT, ACCOUNT_DELTA_COMMITMENT]\n\n # to build a tx_summary in the host, we need these four words in the advice provider\n exec.auth::adv_insert_hqword\n # => [SALT, OUTPUT_NOTES_COMMITMENT, INPUT_NOTES_COMMITMENT, ACCOUNT_DELTA_COMMITMENT]\n\n # the commitment to the tx summary is the message that is signed\n exec.auth::hash_tx_summary\n # => [TX_SUMMARY_COMMITMENT]\n\n # ------ Verifying approver signatures ------\n\n push.THRESHOLD_CONFIG_SLOT[0..2]\n # => [config_slot_prefix, config_slot_suffix, TX_SUMMARY_COMMITMENT]\n\n exec.active_account::get_initial_item\n # => [0, 0, num_of_approvers, default_threshold, TX_SUMMARY_COMMITMENT]\n\n drop drop\n # => [num_of_approvers, default_threshold, TX_SUMMARY_COMMITMENT]\n\n swap movdn.5\n # => [num_of_approvers, TX_SUMMARY_COMMITMENT, default_threshold]\n\n push.PUBLIC_KEYS_MAP_SLOT[0..2]\n # => [pub_key_slot_prefix, pub_key_slot_suffix, num_of_approvers, TX_SUMMARY_COMMITMENT, default_threshold]\n\n exec.::miden::standards::auth::ecdsa_k256_keccak::verify_signatures\n # => [num_verified_signatures, TX_SUMMARY_COMMITMENT, default_threshold]\n\n # ------ Checking threshold is >= num_verified_signatures ------\n\n movup.5\n # => [default_threshold, num_verified_signatures, TX_SUMMARY_COMMITMENT]\n\n exec.compute_transaction_threshold\n # => [transaction_threshold, num_verified_signatures, TX_SUMMARY_COMMITMENT]\n\n u32assert2 u32lt\n # => [is_unauthorized, TX_SUMMARY_COMMITMENT]\n\n # If signatures are non-existent the tx will fail here.\n if.true\n emit.AUTH_UNAUTHORIZED_EVENT\n push.0 assert.err=\"insufficient number of signatures\"\n end\n\n # => [TX_SUMMARY_COMMITMENT]\nend\n";
3
- export declare const GUARDIAN_MASM = "# Guardian Authentication Component\n#\n# This component provides GUARDIAN signature verification for accounts.\n# It can be used standalone or in conjunction with other auth components like multisig.\n\nuse miden::protocol::active_account\nuse miden::protocol::native_account\n\ntype BeWord = struct @bigendian { a: felt, b: felt, c: felt, d: felt }\n\n# IMPORTANT SECURITY NOTES\n# --------------------------------------------------------------------------------\n# - The selector in `GUARDIAN_SELECTOR_SLOT` controls whether the extra GUARDIAN signature\n# is enforced:\n# * GUARDIAN_ON => exactly one valid GUARDIAN signature is required.\n# * GUARDIAN_OFF => GUARDIAN signature is skipped for that call.\n#\n# - `verify_guardian_signature` reads the selector from initial storage state.\n# This means changes made during the same transaction won't affect the check.\n#\n# - `enable_guardian` / `disable_guardian` procedures allow explicit control over GUARDIAN state.\n#\n# - `update_guardian_public_key`:\n# * Installs a new GUARDIAN public key in the map at `GUARDIAN_PUBLIC_KEY_MAP_SLOT`.\n# * Does not itself perform any signature checks.\n# * To update the key without requiring GUARDIAN signature, ensure selector is OFF.\n#\n# Storage Layout\n# --------------------------------------------------------------------------------\n#\n# +---------------------+---------------+\n# | DESCRIPTION | SLOT |\n# +---------------------+---------------+\n# | GUARDIAN SELECTOR (word) | 0 |\n# | GUARDIAN PUBLIC KEY MAP | 1 |\n# +---------------------+---------------+\n#\n# - GUARDIAN_SELECTOR_SLOT (0):\n# * Stores a word that is compared against [1, 0, 0, 0] (GUARDIAN_ON).\n# * Any value != GUARDIAN_ON is treated as GUARDIAN_OFF.\n#\n# - GUARDIAN_PUBLIC_KEY_MAP_SLOT (1):\n# * A map from a fixed key [0, 0, 0, 0] to the single GUARDIAN public key:\n# [0, 0, 0, 0] => GUARDIAN_PUBLIC_KEY\n# * GUARDIAN_PUBLIC_KEY is a RPO Falcon 512 public key represented as a word.\n\n# CONSTANTS\n# =================================================================================================\n\n# Slot where the GUARDIAN selector flag is stored (using word() for named slot access):\n# - GUARDIAN_ON => GUARDIAN signature required\n# - GUARDIAN_OFF => GUARDIAN signature skipped\nconst GUARDIAN_SELECTOR_SLOT=word(\"openzeppelin::guardian::selector\")\n\n# Map slot for GUARDIAN public key\n# Uses exactly one GUARDIAN public key at index [0, 0, 0, 0]\n# [0, 0, 0, 0] => GUARDIAN_PUBLIC_KEY\nconst GUARDIAN_PUBLIC_KEY_MAP_SLOT=word(\"openzeppelin::guardian::public_key\")\n\n# Selector flag values\nconst GUARDIAN_ON=[1, 0, 0, 0]\nconst GUARDIAN_OFF=[0, 0, 0, 0]\n\n# The event emitted when a signature is not found for a required signer.\nconst AUTH_UNAUTHORIZED_EVENT=event(\"miden::auth::unauthorized\")\n\n# GUARDIAN PROCEDURES\n# =================================================================================================\n\n#! Enable GUARDIAN verification by setting the selector to ON.\n#!\n#! Operand stack inputs: []\n#! Outputs: []\n#!\n#! Notes:\n#! - Sets GUARDIAN_SELECTOR_SLOT to GUARDIAN_ON (1)\n#! - After this, transactions will require GUARDIAN signature verification\nproc enable_guardian\n push.GUARDIAN_ON\n # => [GUARDIAN_ON]\n\n push.GUARDIAN_SELECTOR_SLOT[0..2]\n # => [selector_slot_prefix, selector_slot_suffix, GUARDIAN_ON]\n\n exec.native_account::set_item\n # => [OLD_ROOT]\n\n dropw\n # => []\nend\n\n#! Disable GUARDIAN verification by setting the selector to OFF.\n#!\n#! Operand stack inputs: []\n#! Outputs: []\n#!\n#! Notes:\n#! - Sets GUARDIAN_SELECTOR_SLOT to GUARDIAN_OFF (0)\n#! - After this, transactions will NOT require GUARDIAN signature verification\nproc disable_guardian\n push.GUARDIAN_OFF\n # => [GUARDIAN_OFF]\n\n push.GUARDIAN_SELECTOR_SLOT[0..2]\n # => [selector_slot_prefix, selector_slot_suffix, GUARDIAN_OFF]\n\n exec.native_account::set_item\n # => [OLD_ROOT]\n\n dropw\n # => []\nend\n\n#! Update the GUARDIAN public key.\n#!\n#! Operand stack inputs: []\n#! Advice stack inputs: [PUB_KEY]\n#! - PUB_KEY is the new GUARDIAN RPO Falcon 512 public key\n#!\n#! Notes:\n#! - Stores PUB_KEY into GUARDIAN_PUBLIC_KEY_MAP_SLOT:\n#! [0, 0, 0, 0] => GUARDIAN_PUBLIC_KEY\n#! - To update the key without requiring GUARDIAN signature, ensure\n#! GUARDIAN_SELECTOR_SLOT = 0 (OFF) before calling this.\npub proc update_guardian_public_key\n exec.disable_guardian\n # ------ Update the GUARDIAN public key ------\n adv_loadw\n # => [PUB_KEY]\n\n push.0.0.0.0\n # => [MAP_KEY, PUB_KEY]\n # Note that MAP_KEY is [0, 0, 0, 0] for a single GUARDIAN_KEY\n\n push.GUARDIAN_PUBLIC_KEY_MAP_SLOT[0..2]\n # => [pub_key_slot_prefix, pub_key_slot_suffix, MAP_KEY, PUB_KEY]\n\n exec.native_account::set_map_item\n # => [OLD_MAP_VALUE]\n\n dropw\n # => []\nend\n\n#! Conditionally verify a \"GUARDIAN\" signature against a stored public key hash.\n#! The condition is controlled by the selector at GUARDIAN_SELECTOR_SLOT.\n#!\n#! Inputs: [MSG]\n#! Outputs: [MSG]\n#!\n#! Panics if:\n#! - Selector is ON but the provided GUARDIAN signature is invalid or missing.\n#!\n#! Notes:\n#! - MSG is TX_SUMMARY_COMMITMENT provided by auth procedure\n#! - If selector is OFF (0), GUARDIAN verification is skipped\n#! - Selector value is read from initial storage state\npub proc verify_guardian_signature(msg: BeWord) -> BeWord\n push.GUARDIAN_SELECTOR_SLOT[0..2]\n exec.active_account::get_item\n drop drop drop\n # => [selector, MSG]\n\n push.1 eq\n if.true\n push.1\n push.GUARDIAN_PUBLIC_KEY_MAP_SLOT[0..2]\n exec.::miden::standards::auth::falcon512_rpo::verify_signatures\n push.1 neq\n if.true\n emit.AUTH_UNAUTHORIZED_EVENT\n push.0 assert.err=\"invalid GUARDIAN signature\"\n end\n end\n # => [MSG]\n exec.enable_guardian\nend\n";
4
- export declare const GUARDIAN_ECDSA_MASM = "# Guardian Authentication Component (ECDSA)\n#\n# This component provides GUARDIAN signature verification for accounts using\n# ECDSA secp256k1 (k256/keccak) signatures.\n# It can be used standalone or in conjunction with other auth components like multisig.\n\nuse miden::protocol::active_account\nuse miden::protocol::native_account\n\ntype BeWord = struct @bigendian { a: felt, b: felt, c: felt, d: felt }\n\n# IMPORTANT SECURITY NOTES\n# --------------------------------------------------------------------------------\n# - The selector in `GUARDIAN_SELECTOR_SLOT` controls whether the extra GUARDIAN signature\n# is enforced:\n# * GUARDIAN_ON => exactly one valid GUARDIAN signature is required.\n# * GUARDIAN_OFF => GUARDIAN signature is skipped for that call.\n#\n# - `verify_guardian_signature` reads the selector from initial storage state.\n# This means changes made during the same transaction won't affect the check.\n#\n# - `enable_guardian` / `disable_guardian` procedures allow explicit control over GUARDIAN state.\n#\n# - `update_guardian_public_key`:\n# * Installs a new GUARDIAN public key in the map at `GUARDIAN_PUBLIC_KEY_MAP_SLOT`.\n# * Does not itself perform any signature checks.\n# * To update the key without requiring GUARDIAN signature, ensure selector is OFF.\n#\n# Storage Layout\n# --------------------------------------------------------------------------------\n#\n# +---------------------+---------------+\n# | DESCRIPTION | SLOT |\n# +---------------------+---------------+\n# | GUARDIAN SELECTOR (word) | 0 |\n# | GUARDIAN PUBLIC KEY MAP | 1 |\n# +---------------------+---------------+\n#\n# - GUARDIAN_SELECTOR_SLOT (0):\n# * Stores a word that is compared against [1, 0, 0, 0] (GUARDIAN_ON).\n# * Any value != GUARDIAN_ON is treated as GUARDIAN_OFF.\n#\n# - GUARDIAN_PUBLIC_KEY_MAP_SLOT (1):\n# * A map from a fixed key [0, 0, 0, 0] to the single GUARDIAN public key:\n# [0, 0, 0, 0] => GUARDIAN_PUBLIC_KEY\n# * GUARDIAN_PUBLIC_KEY is an ECDSA secp256k1 public key represented as a word.\n\n# CONSTANTS\n# =================================================================================================\n\n# Slot where the GUARDIAN selector flag is stored (using word() for named slot access):\n# - GUARDIAN_ON => GUARDIAN signature required\n# - GUARDIAN_OFF => GUARDIAN signature skipped\nconst GUARDIAN_SELECTOR_SLOT=word(\"openzeppelin::guardian::selector\")\n\n# Map slot for GUARDIAN public key\n# Uses exactly one GUARDIAN public key at index [0, 0, 0, 0]\n# [0, 0, 0, 0] => GUARDIAN_PUBLIC_KEY\nconst GUARDIAN_PUBLIC_KEY_MAP_SLOT=word(\"openzeppelin::guardian::public_key\")\n\n# Selector flag values\nconst GUARDIAN_ON=[1, 0, 0, 0]\nconst GUARDIAN_OFF=[0, 0, 0, 0]\n\n# The event emitted when a signature is not found for a required signer.\nconst AUTH_UNAUTHORIZED_EVENT=event(\"miden::auth::unauthorized\")\n\n# GUARDIAN PROCEDURES\n# =================================================================================================\n\n#! Enable GUARDIAN verification by setting the selector to ON.\n#!\n#! Operand stack inputs: []\n#! Outputs: []\n#!\n#! Notes:\n#! - Sets GUARDIAN_SELECTOR_SLOT to GUARDIAN_ON (1)\n#! - After this, transactions will require GUARDIAN signature verification\nproc enable_guardian\n push.GUARDIAN_ON\n # => [GUARDIAN_ON]\n\n push.GUARDIAN_SELECTOR_SLOT[0..2]\n # => [selector_slot_prefix, selector_slot_suffix, GUARDIAN_ON]\n\n exec.native_account::set_item\n # => [OLD_ROOT]\n\n dropw\n # => []\nend\n\n#! Disable GUARDIAN verification by setting the selector to OFF.\n#!\n#! Operand stack inputs: []\n#! Outputs: []\n#!\n#! Notes:\n#! - Sets GUARDIAN_SELECTOR_SLOT to GUARDIAN_OFF (0)\n#! - After this, transactions will NOT require GUARDIAN signature verification\nproc disable_guardian\n push.GUARDIAN_OFF\n # => [GUARDIAN_OFF]\n\n push.GUARDIAN_SELECTOR_SLOT[0..2]\n # => [selector_slot_prefix, selector_slot_suffix, GUARDIAN_OFF]\n\n exec.native_account::set_item\n # => [OLD_ROOT]\n\n dropw\n # => []\nend\n\n#! Update the GUARDIAN public key.\n#!\n#! Operand stack inputs: []\n#! Advice stack inputs: [PUB_KEY]\n#! - PUB_KEY is the new GUARDIAN ECDSA secp256k1 public key\n#!\n#! Notes:\n#! - Stores PUB_KEY into GUARDIAN_PUBLIC_KEY_MAP_SLOT:\n#! [0, 0, 0, 0] => GUARDIAN_PUBLIC_KEY\n#! - To update the key without requiring GUARDIAN signature, ensure\n#! GUARDIAN_SELECTOR_SLOT = 0 (OFF) before calling this.\npub proc update_guardian_public_key\n exec.disable_guardian\n # ------ Update the GUARDIAN public key ------\n adv_loadw\n # => [PUB_KEY]\n\n push.0.0.0.0\n # => [MAP_KEY, PUB_KEY]\n # Note that MAP_KEY is [0, 0, 0, 0] for a single GUARDIAN_KEY\n\n push.GUARDIAN_PUBLIC_KEY_MAP_SLOT[0..2]\n # => [pub_key_slot_prefix, pub_key_slot_suffix, MAP_KEY, PUB_KEY]\n\n exec.native_account::set_map_item\n # => [OLD_MAP_VALUE]\n\n dropw\n # => []\nend\n\n#! Conditionally verify a \"GUARDIAN\" signature against a stored public key hash.\n#! The condition is controlled by the selector at GUARDIAN_SELECTOR_SLOT.\n#!\n#! Inputs: [MSG]\n#! Outputs: [MSG]\n#!\n#! Panics if:\n#! - Selector is ON but the provided GUARDIAN signature is invalid or missing.\n#!\n#! Notes:\n#! - MSG is TX_SUMMARY_COMMITMENT provided by auth procedure\n#! - If selector is OFF (0), GUARDIAN verification is skipped\n#! - Selector value is read from initial storage state\npub proc verify_guardian_signature(msg: BeWord) -> BeWord\n push.GUARDIAN_SELECTOR_SLOT[0..2]\n exec.active_account::get_item\n drop drop drop\n # => [selector, MSG]\n\n push.1 eq\n if.true\n push.1\n push.GUARDIAN_PUBLIC_KEY_MAP_SLOT[0..2]\n exec.::miden::standards::auth::ecdsa_k256_keccak::verify_signatures\n push.1 neq\n if.true\n emit.AUTH_UNAUTHORIZED_EVENT\n push.0 assert.err=\"invalid GUARDIAN signature\"\n end\n end\n # => [MSG]\n exec.enable_guardian\nend\n";
1
+ export declare const MULTISIG_MASM = "# Multi-Signature RPO Falcon 512 Authentication Core Library\n#\n# This library provides the reusable multisig procedures used by account wrappers.\n\nuse miden::protocol::active_account\nuse miden::protocol::auth::AUTH_UNAUTHORIZED_EVENT\nuse miden::protocol::native_account\nuse miden::standards::auth\n\n# CONSTANTS\n# =================================================================================================\n\n# Auth Request Constants\n\n# Storage Layout Constants\n#\n# +-------------------------------+----------+------------+--------------+-------------------+\n# | THRESHOLD & APPROVERS CONFIG | PUB KEYS | SCHEME IDS | EXECUTED TXS | PROC THRESHOLDS |\n# | (slot) | (map) | (map) | (map) | (map) |\n# +-------------------------------+----------+------------+--------------+-------------------+\n# | 0 | 1 | 2 | 3 | 4 |\n# +-------------------------------+----------+------------+--------------+-------------------+\n\n# The slot in this component's storage layout where the default signature threshold and\n# number of approvers are stored as:\n# [default_threshold, num_approvers, 0, 0].\n# The threshold is guaranteed to be less than or equal to num_approvers.\nconst THRESHOLD_CONFIG_SLOT=word(\"openzeppelin::multisig::threshold_config\")\n\n# The slot in this component's storage layout where the public keys map is stored.\n# Map entries: [key_index, 0, 0, 0] => APPROVER_PUBLIC_KEY\nconst PUBLIC_KEYS_MAP_SLOT=word(\"openzeppelin::multisig::signer_public_keys\")\n\n# The slot in this component's storage layout where signer scheme IDs are stored.\n# Map entries: [key_index, 0, 0, 0] => [scheme_id, 0, 0, 0]\nconst APPROVER_SCHEME_ID_SLOT=word(\"openzeppelin::multisig::signer_scheme_ids\")\n\n# The slot in this component's storage layout where executed transactions are stored.\n# Map entries: transaction_message => [is_executed, 0, 0, 0]\nconst EXECUTED_TXS_SLOT=word(\"openzeppelin::multisig::executed_transactions\")\n\n# The slot in this component's storage layout where procedure thresholds are stored.\n# Map entries: PROC_ROOT => [proc_threshold, 0, 0, 0]\nconst PROC_THRESHOLD_ROOTS_SLOT=word(\"openzeppelin::multisig::procedure_thresholds\")\n\n# Executed Transaction Flag Constant\nconst IS_EXECUTED_FLAG=[1, 0, 0, 0]\nconst FALCON_512_POSEIDON2_SCHEME_WORD=[2, 0, 0, 0]\n\n# ERRORS\nconst ERR_TX_ALREADY_EXECUTED=\"failed to approve multisig transaction as it was already executed\"\n\nconst ERR_MALFORMED_MULTISIG_CONFIG=\"number of approvers must be equal to or greater than threshold\"\n\nconst ERR_ZERO_IN_MULTISIG_CONFIG=\"number of approvers or threshold must not be zero\"\n\nconst ERR_PROC_THRESHOLD_NOT_U32=\"procedure threshold must be a u32 value\"\n\nconst ERR_NUM_APPROVERS_OR_PROC_THRESHOLD_NOT_U32=\"number of approvers and procedure threshold must be u32\"\n\nconst ERR_PROC_THRESHOLD_EXCEEDS_NUM_APPROVERS=\"procedure threshold exceeds number of approvers\"\n\n# MULTISIG PROCEDURES\n# =================================================================================================\n\n#! Check if transaction has already been executed and add it to executed transactions for replay protection.\n#!\n#! Inputs: [MSG]\n#! Outputs: []\n#!\n#! Panics if:\n#! - the same transaction has already been executed\npub proc assert_new_tx(msg: word)\n push.IS_EXECUTED_FLAG\n # => [[0, 0, 0, is_executed], MSG]\n\n swapw\n # => [MSG, IS_EXECUTED_FLAG]\n\n push.EXECUTED_TXS_SLOT[0..2]\n # => [txs_slot_prefix, txs_slot_suffix, MSG, IS_EXECUTED_FLAG]\n\n # Set the key value pair in the map to mark transaction as executed\n exec.native_account::set_map_item\n # => [[0, 0, 0, is_executed]]\n\n drop drop drop\n # => [is_executed]\n\n assertz.err=ERR_TX_ALREADY_EXECUTED\n # => []\nend\n\n#! Remove old approver public keys from the approver public key mapping.\n#!\n#! This procedure cleans up the storage by removing public keys of approvers that are no longer\n#! part of the multisig configuration. This procedure assumes that init_num_of_approvers and\n#! new_num_of_approvers are u32 values.\n#!\n#! Inputs: [init_num_of_approvers, new_num_of_approvers]\n#! Outputs: []\n#!\n#! Where:\n#! - init_num_of_approvers is the original number of approvers before the update\n#! - new_num_of_approvers is the new number of approvers after the update\nproc cleanup_pubkey_mapping(init_num_of_approvers: u32, new_num_of_approvers: u32)\n dup.1 dup.1\n u32assert2 u32lt\n # => [should_loop, i = init_num_of_approvers, new_num_of_approvers]\n\n while.true\n # => [i, new_num_of_approvers]\n\n sub.1\n # => [i-1, new_num_of_approvers]\n\n dup exec.create_approver_map_key\n # => [APPROVER_MAP_KEY, i-1, new_num_of_approvers]\n\n padw swapw\n # => [APPROVER_MAP_KEY, EMPTY_WORD, i-1, new_num_of_approvers]\n\n push.PUBLIC_KEYS_MAP_SLOT[0..2]\n # => [pub_key_slot_prefix, pub_key_slot_suffix, APPROVER_MAP_KEY, EMPTY_WORD, i-1, new_num_of_approvers]\n\n exec.native_account::set_map_item\n # => [OLD_MAP_VALUE, i-1, new_num_of_approvers]\n\n dropw\n # => [i-1, new_num_of_approvers]\n\n dup exec.create_approver_map_key\n # => [APPROVER_MAP_KEY, i-1, new_num_of_approvers]\n\n padw swapw\n # => [APPROVER_MAP_KEY, EMPTY_WORD, i-1, new_num_of_approvers]\n\n push.APPROVER_SCHEME_ID_SLOT[0..2]\n # => [scheme_slot_prefix, scheme_slot_suffix, APPROVER_MAP_KEY, EMPTY_WORD, i-1, new_num_of_approvers]\n\n exec.native_account::set_map_item\n # => [OLD_MAP_VALUE, i-1, new_num_of_approvers]\n\n dropw\n # => [i-1, new_num_of_approvers]\n\n dup.1 dup.1\n u32lt\n # => [should_loop, i-1, new_num_of_approvers]\n end\n\n drop drop\n # => []\nend\n\nproc create_approver_map_key\n push.0.0.0 movup.3\n # => [APPROVER_MAP_KEY]\nend\n\nproc get_threshold_and_num_approvers\n push.THRESHOLD_CONFIG_SLOT[0..2]\n exec.active_account::get_initial_item\n # => [threshold, num_approvers]\n\n movup.2 drop movup.2 drop\n # => [threshold, num_approvers]\nend\n\nproc assert_proc_thresholds_lte_num_approvers(num_approvers: u32)\n exec.active_account::get_num_procedures\n # => [num_procedures, num_approvers]\n\n dup neq.0\n # => [should_continue, num_procedures, num_approvers]\n while.true\n sub.1 dup\n # => [proc_index, proc_index, num_approvers]\n\n exec.active_account::get_procedure_root\n # => [PROC_ROOT, proc_index, num_approvers]\n\n push.PROC_THRESHOLD_ROOTS_SLOT[0..2]\n # => [proc_roots_slot_prefix, proc_roots_slot_suffix, PROC_ROOT, proc_index, num_approvers]\n\n exec.active_account::get_map_item\n # => [[proc_threshold, 0, 0, 0], proc_index, num_approvers]\n\n movdn.3 drop drop drop\n # => [proc_threshold, proc_index, num_approvers]\n\n dup.2\n # => [num_approvers, proc_threshold, proc_index, num_approvers]\n\n u32assert2.err=ERR_PROC_THRESHOLD_NOT_U32\n u32gt assertz.err=ERR_PROC_THRESHOLD_EXCEEDS_NUM_APPROVERS\n # => [proc_index, num_approvers]\n\n dup neq.0\n # => [should_continue, proc_index, num_approvers]\n end\n\n drop drop\n # => []\nend\n\n# Internal storage helper used by the public `update_procedure_threshold`\n# entrypoint after it receives direct stack arguments.\nproc set_procedure_threshold(proc_threshold: u32, proc_root: word)\n exec.get_threshold_and_num_approvers\n # => [threshold, num_approvers, proc_threshold, PROC_ROOT]\n\n drop\n # => [num_approvers, proc_threshold, PROC_ROOT]\n\n dup.1 swap\n # => [num_approvers, proc_threshold, proc_threshold, PROC_ROOT]\n\n u32assert2.err=ERR_NUM_APPROVERS_OR_PROC_THRESHOLD_NOT_U32\n u32gt assertz.err=ERR_PROC_THRESHOLD_EXCEEDS_NUM_APPROVERS\n # => [proc_threshold, PROC_ROOT]\n\n push.0.0.0\n movup.3\n swapw\n # => [PROC_ROOT, PROC_THRESHOLD_WORD]\n\n push.PROC_THRESHOLD_ROOTS_SLOT[0..2]\n # => [proc_roots_slot_prefix, proc_roots_slot_suffix, PROC_ROOT, PROC_THRESHOLD_WORD]\n\n exec.native_account::set_map_item\n # => [OLD_VALUE]\n\n dropw\n # => []\nend\n\n#! Update threshold config and add / remove approvers\n#!\n#! Inputs:\n#! Operand stack: [MULTISIG_CONFIG_HASH, pad(12)]\n#! Advice map: {\n#! MULTISIG_CONFIG_HASH => [CONFIG, PUB_KEY_N, PUB_KEY_N-1, ..., PUB_KEY_0]\n#! }\n#! Outputs:\n#! Operand stack: [TX_SUMMARY_COMMITMENT]\n#!\n#! Where:\n#! - MULTISIG_CONFIG_HASH is the hash of the threshold and new public key vector\n#! - MULTISIG_CONFIG is [threshold, num_approvers, 0, 0]\n#! - PUB_KEY_i is the public key of the i-th signer\n#!\n#! Locals:\n#! 0: new_num_of_approvers\n#! 1: init_num_of_approvers\n@locals(2)\npub proc update_signers_and_threshold(multisig_config_hash: word)\n adv.push_mapval\n # => [MULTISIG_CONFIG_HASH, pad(12)]\n\n adv_loadw\n # => [MULTISIG_CONFIG, pad(12)]\n\n # store new_num_of_approvers for later\n dup.1 loc_store.0\n # => [MULTISIG_CONFIG, pad(12)]\n\n dup dup.2\n # => [num_approvers, threshold, MULTISIG_CONFIG, pad(12)]\n\n # make sure that the threshold is smaller than the number of approvers\n u32assert2.err=ERR_MALFORMED_MULTISIG_CONFIG\n u32gt assertz.err=ERR_MALFORMED_MULTISIG_CONFIG\n # => [MULTISIG_CONFIG, pad(12)]\n\n dup dup.2\n # => [num_approvers, threshold, MULTISIG_CONFIG, pad(12)]\n\n # make sure that threshold or num_approvers are not zero\n eq.0 assertz.err=ERR_ZERO_IN_MULTISIG_CONFIG\n eq.0 assertz.err=ERR_ZERO_IN_MULTISIG_CONFIG\n # => [MULTISIG_CONFIG, pad(12)]\n\n loc_load.0\n # => [num_approvers, MULTISIG_CONFIG, pad(12)]\n\n exec.assert_proc_thresholds_lte_num_approvers\n # => [MULTISIG_CONFIG, pad(12)]\n\n push.THRESHOLD_CONFIG_SLOT[0..2]\n # => [config_slot_prefix, config_slot_suffix, MULTISIG_CONFIG, pad(12)]\n\n exec.native_account::set_item\n # => [OLD_THRESHOLD_CONFIG, pad(12)]\n\n # store init_num_of_approvers for later\n drop loc_store.1 drop drop\n # => [pad(12)]\n\n loc_load.0\n # => [num_approvers]\n\n dup neq.0\n while.true\n sub.1\n # => [i-1, pad(12)]\n\n dup exec.create_approver_map_key\n # => [APPROVER_MAP_KEY, i-1, pad(12)]\n\n padw adv_loadw\n # => [PUB_KEY, APPROVER_MAP_KEY, i-1, pad(12)]\n\n swapw\n # => [APPROVER_MAP_KEY, PUB_KEY, i-1, pad(12)]\n\n push.PUBLIC_KEYS_MAP_SLOT[0..2]\n # => [pub_key_slot_prefix, pub_key_slot_suffix, APPROVER_MAP_KEY, PUB_KEY, i-1, pad(12)]\n\n exec.native_account::set_map_item\n # => [OLD_VALUE, i-1, pad(12)]\n\n dropw\n # => [i-1, pad(12)]\n\n dup exec.create_approver_map_key\n # => [APPROVER_MAP_KEY, i-1, pad(12)]\n\n push.FALCON_512_POSEIDON2_SCHEME_WORD\n # => [SCHEME_ID_WORD, APPROVER_MAP_KEY, i-1, pad(12)]\n\n swapw\n # => [APPROVER_MAP_KEY, [2, 0, 0, 0], i-1, pad(12)]\n\n push.APPROVER_SCHEME_ID_SLOT[0..2]\n # => [scheme_slot_prefix, scheme_slot_suffix, APPROVER_MAP_KEY, [2, 0, 0, 0], i-1, pad(12)]\n\n exec.native_account::set_map_item\n # => [OLD_VALUE, i-1, pad(12)]\n\n dropw\n # => [i-1, pad(12)]\n\n dup neq.0\n # => [is_non_zero, i-1, pad(12)]\n end\n # => [pad(13)]\n\n drop\n # => [pad(12)]\n\n # compare initial vs current multisig config\n\n # load init_num_of_approvers & new_num_of_approvers\n loc_load.0 loc_load.1\n # => [init_num_of_approvers, new_num_of_approvers, pad(12)]\n\n exec.cleanup_pubkey_mapping\n # => [pad(12)]\nend\n\n#! Update or clear the threshold override for a specific procedure.\n#!\n#! Inputs:\n#! Operand stack: [proc_threshold, PROC_ROOT]\n#! Outputs:\n#! Operand stack: []\n#! Invocation: call\npub proc update_procedure_threshold(proc_threshold: u32, proc_root: word)\n exec.set_procedure_threshold\nend\n\n# Computes the effective transaction threshold based on called procedures and per-procedure\n# overrides stored in PROC_THRESHOLD_ROOTS_SLOT. Falls back to default_threshold if no\n# overrides apply.\n#\n#! Inputs: [default_threshold]\n#! Outputs: [transaction_threshold]\n@locals(1)\nproc compute_transaction_threshold(default_threshold: u32) -> u32\n # 1. initialize transaction_threshold = 0\n # 2. iterate through all account procedures\n # a. check if the procedure was called during the transaction\n # b. if called, get the override threshold of that procedure from the config map\n # c. if proc_threshold > transaction_threshold, set transaction_threshold = proc_threshold\n # 3. if transaction_threshold == 0 at the end, revert to using default_threshold\n\n # store default_threshold for later\n loc_store.0\n # => []\n\n # 1. initialize transaction_threshold = 0\n push.0\n # => [transaction_threshold]\n\n # get the number of account procedures\n exec.active_account::get_num_procedures\n # => [num_procedures, transaction_threshold]\n\n # 2. iterate through all account procedures\n dup neq.0\n # => [should_continue, num_procedures, transaction_threshold]\n while.true\n sub.1 dup\n # => [num_procedures-1, num_procedures-1, transaction_threshold]\n\n # get procedure root of the procedure with index i\n exec.active_account::get_procedure_root dupw\n # => [PROC_ROOT, PROC_ROOT, num_procedures-1, transaction_threshold]\n\n # 2a. check if this procedure has been called in the transaction\n exec.native_account::was_procedure_called\n # => [was_called, PROC_ROOT, num_procedures-1, transaction_threshold]\n\n # if it has been called, get the override threshold of that procedure\n if.true\n # => [PROC_ROOT, num_procedures-1, transaction_threshold]\n\n push.PROC_THRESHOLD_ROOTS_SLOT[0..2]\n # => [PROC_THRESHOLD_ROOTS_SLOT_prefix, PROC_THRESHOLD_ROOTS_SLOT_suffix, PROC_ROOT, num_procedures-1, transaction_threshold]\n\n # 2b. get the override proc_threshold of that procedure\n # if the procedure has no override threshold, the returned map item will be [0, 0, 0, 0]\n exec.active_account::get_initial_map_item\n # => [[proc_threshold, 0, 0, 0], num_procedures-1, transaction_threshold]\n\n movdn.3 drop drop drop dup dup.3\n # => [transaction_threshold, proc_threshold, proc_threshold, num_procedures-1, transaction_threshold]\n\n u32assert2.err=\"transaction threshold or procedure threshold are not u32\"\n u32gt\n # => [is_gt, proc_threshold, num_procedures-1, transaction_threshold]\n # 2c. if proc_threshold > transaction_threshold, update transaction_threshold\n movup.2 movdn.3\n # => [is_gt, proc_threshold, transaction_threshold, num_procedures-1]\n cdrop\n # => [updated_transaction_threshold, num_procedures-1]\n swap\n # => [num_procedures-1, updated_transaction_threshold]\n # if it has not been called during this transaction, nothing to do, move to the next procedure\n else\n dropw\n # => [num_procedures-1, transaction_threshold]\n end\n\n dup neq.0\n # => [should_continue, num_procedures-1, transaction_threshold]\n end\n\n drop\n # => [transaction_threshold]\n\n loc_load.0\n # => [default_threshold, transaction_threshold]\n\n # 3. if transaction_threshold == 0 at the end, revert to using default_threshold\n dup.1 eq.0\n # => [is_zero, default_threshold, transaction_threshold]\n\n cdrop\n # => [effective_transaction_threshold]\nend\n\n#! Authenticate a transaction using the Falcon signature scheme with multi-signature support.\n#!\n#! This procedure implements multi-signature authentication by:\n#! 1. Computing the transaction summary message that needs to be signed\n#! 2. Verifying signatures from multiple required signers against their public keys\n#! 3. Ensuring the minimum threshold of valid signatures is met\n#! 4. Returning the transaction summary commitment for higher-level wrappers.\n#!\n#! Inputs:\n#! Operand stack: [SALT]\n#! Advice map: {\n#! h(SIG_0, MSG): SIG_0,\n#! h(SIG_1, MSG): SIG_1,\n#! h(SIG_n, MSG): SIG_n\n#! }\n#! Outputs:\n#! Operand stack: []\n#!\n#! Where:\n#! - SALT is a cryptographically random nonce that enables multiple concurrent\n#! multisig transactions while maintaining replay protection. Each transaction\n#! must use a unique SALT value to ensure transaction uniqueness.\n#! - SIG_i is the signature from the i-th signer.\n#! - MSG is the transaction message being signed.\n#! - h(SIG_i, MSG) is the hash of the signature and message used as the advice map key.\n#!\n#! Panics if:\n#! - insufficient number of valid signatures (below threshold).\n#! - insufficient number of valid signatures (below threshold).\n#!\n#! Invocation: exec\n@locals(1)\npub proc auth_tx(salt: word)\n exec.native_account::incr_nonce drop\n # => [SALT]\n\n # ------ Computing transaction summary ------\n\n exec.auth::create_tx_summary\n # => [ACCOUNT_DELTA_COMMITMENT, INPUT_NOTES_COMMITMENT, OUTPUT_NOTES_COMMITMENT, SALT]\n\n # to build a tx_summary in the host, we need these four words in the advice provider\n adv.insert_hqword\n # => [ACCOUNT_DELTA_COMMITMENT, INPUT_NOTES_COMMITMENT, OUTPUT_NOTES_COMMITMENT, SALT]\n\n # the commitment to the tx summary is the message that is signed\n exec.auth::hash_tx_summary\n # => [TX_SUMMARY_COMMITMENT]\n\n # ------ Verifying approver signatures ------\n\n exec.get_threshold_and_num_approvers\n # => [default_threshold, num_of_approvers, TX_SUMMARY_COMMITMENT]\n\n movdn.5\n # => [num_of_approvers, TX_SUMMARY_COMMITMENT, default_threshold]\n\n push.PUBLIC_KEYS_MAP_SLOT[0..2]\n # => [pub_key_slot_prefix, pub_key_slot_suffix, num_of_approvers, TX_SUMMARY_COMMITMENT, default_threshold]\n\n push.APPROVER_SCHEME_ID_SLOT[0..2]\n # => [scheme_id_slot_prefix, scheme_id_slot_suffix, pub_key_slot_prefix, pub_key_slot_suffix, num_of_approvers, TX_SUMMARY_COMMITMENT, default_threshold]\n\n exec.::miden::standards::auth::signature::verify_signatures\n # => [num_verified_signatures, TX_SUMMARY_COMMITMENT, default_threshold]\n\n # ------ Checking threshold is >= num_verified_signatures ------\n\n movup.5\n # => [default_threshold, num_verified_signatures, TX_SUMMARY_COMMITMENT]\n\n exec.compute_transaction_threshold\n # => [transaction_threshold, num_verified_signatures, TX_SUMMARY_COMMITMENT]\n\n u32assert2 u32lt\n # => [is_unauthorized, TX_SUMMARY_COMMITMENT]\n\n # If signatures are non-existent the tx will fail here.\n if.true\n emit.AUTH_UNAUTHORIZED_EVENT\n push.0 assert.err=\"insufficient number of signatures\"\n end\n\n # => [TX_SUMMARY_COMMITMENT]\nend\n";
2
+ export declare const MULTISIG_ECDSA_MASM = "# Multi-Signature ECDSA secp256k1 Authentication Core Library\n#\n# This library provides the reusable multisig procedures used by account wrappers.\n\nuse miden::protocol::active_account\nuse miden::protocol::auth::AUTH_UNAUTHORIZED_EVENT\nuse miden::protocol::native_account\nuse miden::standards::auth\n\n# CONSTANTS\n# =================================================================================================\n\n# Auth Request Constants\n\n# Storage Layout Constants\n#\n# +-------------------------------+----------+------------+--------------+-------------------+\n# | THRESHOLD & APPROVERS CONFIG | PUB KEYS | SCHEME IDS | EXECUTED TXS | PROC THRESHOLDS |\n# | (slot) | (map) | (map) | (map) | (map) |\n# +-------------------------------+----------+------------+--------------+-------------------+\n# | 0 | 1 | 2 | 3 | 4 |\n# +-------------------------------+----------+------------+--------------+-------------------+\n\n# The slot in this component's storage layout where the default signature threshold and\n# number of approvers are stored as:\n# [default_threshold, num_approvers, 0, 0].\n# The threshold is guaranteed to be less than or equal to num_approvers.\nconst THRESHOLD_CONFIG_SLOT=word(\"openzeppelin::multisig::threshold_config\")\n\n# The slot in this component's storage layout where the public keys map is stored.\n# Map entries: [key_index, 0, 0, 0] => APPROVER_PUBLIC_KEY\nconst PUBLIC_KEYS_MAP_SLOT=word(\"openzeppelin::multisig::signer_public_keys\")\n\n# The slot in this component's storage layout where signer scheme IDs are stored.\n# Map entries: [key_index, 0, 0, 0] => [scheme_id, 0, 0, 0]\nconst APPROVER_SCHEME_ID_SLOT=word(\"openzeppelin::multisig::signer_scheme_ids\")\n\n# The slot in this component's storage layout where executed transactions are stored.\n# Map entries: transaction_message => [is_executed, 0, 0, 0]\nconst EXECUTED_TXS_SLOT=word(\"openzeppelin::multisig::executed_transactions\")\n\n# The slot in this component's storage layout where procedure thresholds are stored.\n# Map entries: PROC_ROOT => [proc_threshold, 0, 0, 0]\nconst PROC_THRESHOLD_ROOTS_SLOT=word(\"openzeppelin::multisig::procedure_thresholds\")\n\n# Executed Transaction Flag Constant\nconst IS_EXECUTED_FLAG=[1, 0, 0, 0]\nconst ECDSA_K256_KECCAK_SCHEME_WORD=[1, 0, 0, 0]\n\n# ERRORS\nconst ERR_TX_ALREADY_EXECUTED=\"failed to approve multisig transaction as it was already executed\"\n\nconst ERR_MALFORMED_MULTISIG_CONFIG=\"number of approvers must be equal to or greater than threshold\"\n\nconst ERR_ZERO_IN_MULTISIG_CONFIG=\"number of approvers or threshold must not be zero\"\n\nconst ERR_PROC_THRESHOLD_NOT_U32=\"procedure threshold must be a u32 value\"\n\nconst ERR_NUM_APPROVERS_OR_PROC_THRESHOLD_NOT_U32=\"number of approvers and procedure threshold must be u32\"\n\nconst ERR_PROC_THRESHOLD_EXCEEDS_NUM_APPROVERS=\"procedure threshold exceeds number of approvers\"\n\n# MULTISIG PROCEDURES\n# =================================================================================================\n\n#! Check if transaction has already been executed and add it to executed transactions for replay protection.\n#!\n#! Inputs: [MSG]\n#! Outputs: []\n#!\n#! Panics if:\n#! - the same transaction has already been executed\npub proc assert_new_tx(msg: word)\n push.IS_EXECUTED_FLAG\n # => [[0, 0, 0, is_executed], MSG]\n\n swapw\n # => [MSG, IS_EXECUTED_FLAG]\n\n push.EXECUTED_TXS_SLOT[0..2]\n # => [txs_slot_prefix, txs_slot_suffix, MSG, IS_EXECUTED_FLAG]\n\n # Set the key value pair in the map to mark transaction as executed\n exec.native_account::set_map_item\n # => [[0, 0, 0, is_executed]]\n\n drop drop drop\n # => [is_executed]\n\n assertz.err=ERR_TX_ALREADY_EXECUTED\n # => []\nend\n\n#! Remove old approver public keys from the approver public key mapping.\n#!\n#! This procedure cleans up the storage by removing public keys of approvers that are no longer\n#! part of the multisig configuration. This procedure assumes that init_num_of_approvers and\n#! new_num_of_approvers are u32 values.\n#!\n#! Inputs: [init_num_of_approvers, new_num_of_approvers]\n#! Outputs: []\n#!\n#! Where:\n#! - init_num_of_approvers is the original number of approvers before the update\n#! - new_num_of_approvers is the new number of approvers after the update\nproc cleanup_pubkey_mapping(init_num_of_approvers: u32, new_num_of_approvers: u32)\n dup.1 dup.1\n u32assert2 u32lt\n # => [should_loop, i = init_num_of_approvers, new_num_of_approvers]\n\n while.true\n # => [i, new_num_of_approvers]\n\n sub.1\n # => [i-1, new_num_of_approvers]\n\n dup exec.create_approver_map_key\n # => [APPROVER_MAP_KEY, i-1, new_num_of_approvers]\n\n padw swapw\n # => [APPROVER_MAP_KEY, EMPTY_WORD, i-1, new_num_of_approvers]\n\n push.PUBLIC_KEYS_MAP_SLOT[0..2]\n # => [pub_key_slot_prefix, pub_key_slot_suffix, APPROVER_MAP_KEY, EMPTY_WORD, i-1, new_num_of_approvers]\n\n exec.native_account::set_map_item\n # => [OLD_MAP_VALUE, i-1, new_num_of_approvers]\n\n dropw\n # => [i-1, new_num_of_approvers]\n\n dup exec.create_approver_map_key\n # => [APPROVER_MAP_KEY, i-1, new_num_of_approvers]\n\n padw swapw\n # => [APPROVER_MAP_KEY, EMPTY_WORD, i-1, new_num_of_approvers]\n\n push.APPROVER_SCHEME_ID_SLOT[0..2]\n # => [scheme_slot_prefix, scheme_slot_suffix, APPROVER_MAP_KEY, EMPTY_WORD, i-1, new_num_of_approvers]\n\n exec.native_account::set_map_item\n # => [OLD_MAP_VALUE, i-1, new_num_of_approvers]\n\n dropw\n # => [i-1, new_num_of_approvers]\n\n dup.1 dup.1\n u32lt\n # => [should_loop, i-1, new_num_of_approvers]\n end\n\n drop drop\n # => []\nend\n\nproc create_approver_map_key\n push.0.0.0 movup.3\n # => [APPROVER_MAP_KEY]\nend\n\nproc get_threshold_and_num_approvers\n push.THRESHOLD_CONFIG_SLOT[0..2]\n exec.active_account::get_initial_item\n # => [threshold, num_approvers]\n\n movup.2 drop movup.2 drop\n # => [threshold, num_approvers]\nend\n\nproc assert_proc_thresholds_lte_num_approvers(num_approvers: u32)\n exec.active_account::get_num_procedures\n # => [num_procedures, num_approvers]\n\n dup neq.0\n # => [should_continue, num_procedures, num_approvers]\n while.true\n sub.1 dup\n # => [proc_index, proc_index, num_approvers]\n\n exec.active_account::get_procedure_root\n # => [PROC_ROOT, proc_index, num_approvers]\n\n push.PROC_THRESHOLD_ROOTS_SLOT[0..2]\n # => [proc_roots_slot_prefix, proc_roots_slot_suffix, PROC_ROOT, proc_index, num_approvers]\n\n exec.active_account::get_map_item\n # => [[proc_threshold, 0, 0, 0], proc_index, num_approvers]\n\n movdn.3 drop drop drop\n # => [proc_threshold, proc_index, num_approvers]\n\n dup.2\n # => [num_approvers, proc_threshold, proc_index, num_approvers]\n\n u32assert2.err=ERR_PROC_THRESHOLD_NOT_U32\n u32gt assertz.err=ERR_PROC_THRESHOLD_EXCEEDS_NUM_APPROVERS\n # => [proc_index, num_approvers]\n\n dup neq.0\n # => [should_continue, proc_index, num_approvers]\n end\n\n drop drop\n # => []\nend\n\n# Internal storage helper used by the public `update_procedure_threshold`\n# entrypoint after it receives direct stack arguments.\nproc set_procedure_threshold(proc_threshold: u32, proc_root: word)\n exec.get_threshold_and_num_approvers\n # => [threshold, num_approvers, proc_threshold, PROC_ROOT]\n\n drop\n # => [num_approvers, proc_threshold, PROC_ROOT]\n\n dup.1 swap\n # => [num_approvers, proc_threshold, proc_threshold, PROC_ROOT]\n\n u32assert2.err=ERR_NUM_APPROVERS_OR_PROC_THRESHOLD_NOT_U32\n u32gt assertz.err=ERR_PROC_THRESHOLD_EXCEEDS_NUM_APPROVERS\n # => [proc_threshold, PROC_ROOT]\n\n push.0.0.0\n movup.3\n swapw\n # => [PROC_ROOT, PROC_THRESHOLD_WORD]\n\n push.PROC_THRESHOLD_ROOTS_SLOT[0..2]\n # => [proc_roots_slot_prefix, proc_roots_slot_suffix, PROC_ROOT, PROC_THRESHOLD_WORD]\n\n exec.native_account::set_map_item\n # => [OLD_VALUE]\n\n dropw\n # => []\nend\n\n#! Update threshold config and add / remove approvers\n#!\n#! Inputs:\n#! Operand stack: [MULTISIG_CONFIG_HASH, pad(12)]\n#! Advice map: {\n#! MULTISIG_CONFIG_HASH => [CONFIG, PUB_KEY_N, PUB_KEY_N-1, ..., PUB_KEY_0]\n#! }\n#! Outputs:\n#! Operand stack: []\n#!\n#! Where:\n#! - MULTISIG_CONFIG_HASH is the hash of the threshold and new public key vector\n#! - MULTISIG_CONFIG is [threshold, num_approvers, 0, 0]\n#! - PUB_KEY_i is the public key of the i-th signer\n#!\n#! Locals:\n#! 0: new_num_of_approvers\n#! 1: init_num_of_approvers\n@locals(2)\npub proc update_signers_and_threshold(multisig_config_hash: word)\n adv.push_mapval\n # => [MULTISIG_CONFIG_HASH, pad(12)]\n\n adv_loadw\n # => [MULTISIG_CONFIG, pad(12)]\n\n # store new_num_of_approvers for later\n dup.1 loc_store.0\n # => [MULTISIG_CONFIG, pad(12)]\n\n dup dup.2\n # => [num_approvers, threshold, MULTISIG_CONFIG, pad(12)]\n\n # make sure that the threshold is smaller than the number of approvers\n u32assert2.err=ERR_MALFORMED_MULTISIG_CONFIG\n u32gt assertz.err=ERR_MALFORMED_MULTISIG_CONFIG\n # => [MULTISIG_CONFIG, pad(12)]\n\n dup dup.2\n # => [num_approvers, threshold, MULTISIG_CONFIG, pad(12)]\n\n # make sure that threshold or num_approvers are not zero\n eq.0 assertz.err=ERR_ZERO_IN_MULTISIG_CONFIG\n eq.0 assertz.err=ERR_ZERO_IN_MULTISIG_CONFIG\n # => [MULTISIG_CONFIG, pad(12)]\n\n loc_load.0\n # => [num_approvers, MULTISIG_CONFIG, pad(12)]\n\n exec.assert_proc_thresholds_lte_num_approvers\n # => [MULTISIG_CONFIG, pad(12)]\n\n push.THRESHOLD_CONFIG_SLOT[0..2]\n # => [config_slot_prefix, config_slot_suffix, MULTISIG_CONFIG, pad(12)]\n\n exec.native_account::set_item\n # => [OLD_THRESHOLD_CONFIG, pad(12)]\n\n # store init_num_of_approvers for later\n drop loc_store.1 drop drop\n # => [pad(12)]\n\n loc_load.0\n # => [num_approvers]\n\n dup neq.0\n while.true\n sub.1\n # => [i-1, pad(12)]\n\n dup exec.create_approver_map_key\n # => [APPROVER_MAP_KEY, i-1, pad(12)]\n\n padw adv_loadw\n # => [PUB_KEY, APPROVER_MAP_KEY, i-1, pad(12)]\n\n swapw\n # => [APPROVER_MAP_KEY, PUB_KEY, i-1, pad(12)]\n\n push.PUBLIC_KEYS_MAP_SLOT[0..2]\n # => [pub_key_slot_prefix, pub_key_slot_suffix, APPROVER_MAP_KEY, PUB_KEY, i-1, pad(12)]\n\n exec.native_account::set_map_item\n # => [OLD_VALUE, i-1, pad(12)]\n\n dropw\n # => [i-1, pad(12)]\n\n dup exec.create_approver_map_key\n # => [APPROVER_MAP_KEY, i-1, pad(12)]\n\n push.ECDSA_K256_KECCAK_SCHEME_WORD\n # => [SCHEME_ID_WORD, APPROVER_MAP_KEY, i-1, pad(12)]\n\n swapw\n # => [APPROVER_MAP_KEY, [1, 0, 0, 0], i-1, pad(12)]\n\n push.APPROVER_SCHEME_ID_SLOT[0..2]\n # => [scheme_slot_prefix, scheme_slot_suffix, APPROVER_MAP_KEY, [1, 0, 0, 0], i-1, pad(12)]\n\n exec.native_account::set_map_item\n # => [OLD_VALUE, i-1, pad(12)]\n\n dropw\n # => [i-1, pad(12)]\n\n dup neq.0\n # => [is_non_zero, i-1, pad(12)]\n end\n # => [pad(13)]\n\n drop\n # => [pad(12)]\n\n # compare initial vs current multisig config\n\n # load init_num_of_approvers & new_num_of_approvers\n loc_load.0 loc_load.1\n # => [init_num_of_approvers, new_num_of_approvers, pad(12)]\n\n exec.cleanup_pubkey_mapping\n # => [pad(12)]\nend\n\n#! Update or clear the threshold override for a specific procedure.\n#!\n#! Inputs:\n#! Operand stack: [proc_threshold, PROC_ROOT]\n#! Outputs:\n#! Operand stack: []\n#! Invocation: call\npub proc update_procedure_threshold(proc_threshold: u32, proc_root: word)\n exec.set_procedure_threshold\nend\n\n# Computes the effective transaction threshold based on called procedures and per-procedure\n# overrides stored in PROC_THRESHOLD_ROOTS_SLOT. Falls back to default_threshold if no\n# overrides apply.\n#\n#! Inputs: [default_threshold]\n#! Outputs: [transaction_threshold]\n@locals(1)\nproc compute_transaction_threshold(default_threshold: u32) -> u32\n # 1. initialize transaction_threshold = 0\n # 2. iterate through all account procedures\n # a. check if the procedure was called during the transaction\n # b. if called, get the override threshold of that procedure from the config map\n # c. if proc_threshold > transaction_threshold, set transaction_threshold = proc_threshold\n # 3. if transaction_threshold == 0 at the end, revert to using default_threshold\n\n # store default_threshold for later\n loc_store.0\n # => []\n\n # 1. initialize transaction_threshold = 0\n push.0\n # => [transaction_threshold]\n\n # get the number of account procedures\n exec.active_account::get_num_procedures\n # => [num_procedures, transaction_threshold]\n\n # 2. iterate through all account procedures\n dup neq.0\n # => [should_continue, num_procedures, transaction_threshold]\n while.true\n sub.1 dup\n # => [num_procedures-1, num_procedures-1, transaction_threshold]\n\n # get procedure root of the procedure with index i\n exec.active_account::get_procedure_root dupw\n # => [PROC_ROOT, PROC_ROOT, num_procedures-1, transaction_threshold]\n\n # 2a. check if this procedure has been called in the transaction\n exec.native_account::was_procedure_called\n # => [was_called, PROC_ROOT, num_procedures-1, transaction_threshold]\n\n # if it has been called, get the override threshold of that procedure\n if.true\n # => [PROC_ROOT, num_procedures-1, transaction_threshold]\n\n push.PROC_THRESHOLD_ROOTS_SLOT[0..2]\n # => [PROC_THRESHOLD_ROOTS_SLOT_prefix, PROC_THRESHOLD_ROOTS_SLOT_suffix, PROC_ROOT, num_procedures-1, transaction_threshold]\n\n # 2b. get the override proc_threshold of that procedure\n # if the procedure has no override threshold, the returned map item will be [0, 0, 0, 0]\n exec.active_account::get_initial_map_item\n # => [[proc_threshold, 0, 0, 0], num_procedures-1, transaction_threshold]\n\n movdn.3 drop drop drop dup dup.3\n # => [transaction_threshold, proc_threshold, proc_threshold, num_procedures-1, transaction_threshold]\n\n u32assert2.err=\"transaction threshold or procedure threshold are not u32\"\n u32gt\n # => [is_gt, proc_threshold, num_procedures-1, transaction_threshold]\n # 2c. if proc_threshold > transaction_threshold, update transaction_threshold\n movup.2 movdn.3\n # => [is_gt, proc_threshold, transaction_threshold, num_procedures-1]\n cdrop\n # => [updated_transaction_threshold, num_procedures-1]\n swap\n # => [num_procedures-1, updated_transaction_threshold]\n # if it has not been called during this transaction, nothing to do, move to the next procedure\n else\n dropw\n # => [num_procedures-1, transaction_threshold]\n end\n\n dup neq.0\n # => [should_continue, num_procedures-1, transaction_threshold]\n end\n\n drop\n # => [transaction_threshold]\n\n loc_load.0\n # => [default_threshold, transaction_threshold]\n\n # 3. if transaction_threshold == 0 at the end, revert to using default_threshold\n dup.1 eq.0\n # => [is_zero, default_threshold, transaction_threshold]\n\n cdrop\n # => [effective_transaction_threshold]\nend\n\n#! Authenticate a transaction using ECDSA secp256k1 with multi-signature support.\n#!\n#! This procedure implements multi-signature authentication by:\n#! 1. Computing the transaction summary message that needs to be signed\n#! 2. Verifying ECDSA signatures from multiple required signers against their public keys\n#! 3. Ensuring the minimum threshold of valid signatures is met\n#! 4. Returning the transaction summary commitment for higher-level wrappers.\n#!\n#! Inputs:\n#! Operand stack: [SALT]\n#! Advice map: {\n#! h(PUB_KEY_0, MSG): SIG_0,\n#! h(PUB_KEY_1, MSG): SIG_1,\n#! h(PUB_KEY_n, MSG): SIG_n\n#! }\n#! Outputs:\n#! Operand stack: [TX_SUMMARY_COMMITMENT]\n#!\n#! Where:\n#! - SALT is a cryptographically random nonce that enables multiple concurrent\n#! multisig transactions while maintaining replay protection. Each transaction\n#! must use a unique SALT value to ensure transaction uniqueness.\n#! - SIG_i is the ECDSA signature from the i-th signer.\n#! - MSG is the transaction message being signed.\n#! - h(PUB_KEY_i, MSG) is the hash of the public key and message used as the advice map key.\n#!\n#! Panics if:\n#! - insufficient number of valid signatures (below threshold).\n#! - insufficient number of valid signatures (below threshold).\n#!\n#! Invocation: exec\n@locals(1)\npub proc auth_tx(salt: word)\n exec.native_account::incr_nonce drop\n # => [SALT]\n\n # ------ Computing transaction summary ------\n\n exec.auth::create_tx_summary\n # => [ACCOUNT_DELTA_COMMITMENT, INPUT_NOTES_COMMITMENT, OUTPUT_NOTES_COMMITMENT, SALT]\n\n # to build a tx_summary in the host, we need these four words in the advice provider\n adv.insert_hqword\n # => [ACCOUNT_DELTA_COMMITMENT, INPUT_NOTES_COMMITMENT, OUTPUT_NOTES_COMMITMENT, SALT]\n\n # the commitment to the tx summary is the message that is signed\n exec.auth::hash_tx_summary\n # => [TX_SUMMARY_COMMITMENT]\n\n # ------ Verifying approver signatures ------\n\n exec.get_threshold_and_num_approvers\n # => [default_threshold, num_of_approvers, TX_SUMMARY_COMMITMENT]\n\n movdn.5\n # => [num_of_approvers, TX_SUMMARY_COMMITMENT, default_threshold]\n\n push.PUBLIC_KEYS_MAP_SLOT[0..2]\n # => [pub_key_slot_prefix, pub_key_slot_suffix, num_of_approvers, TX_SUMMARY_COMMITMENT, default_threshold]\n\n push.APPROVER_SCHEME_ID_SLOT[0..2]\n # => [scheme_id_slot_prefix, scheme_id_slot_suffix, pub_key_slot_prefix, pub_key_slot_suffix, num_of_approvers, TX_SUMMARY_COMMITMENT, default_threshold]\n\n exec.::miden::standards::auth::signature::verify_signatures\n # => [num_verified_signatures, TX_SUMMARY_COMMITMENT, default_threshold]\n\n # ------ Checking threshold is >= num_verified_signatures ------\n\n movup.5\n # => [default_threshold, num_verified_signatures, TX_SUMMARY_COMMITMENT]\n\n exec.compute_transaction_threshold\n # => [transaction_threshold, num_verified_signatures, TX_SUMMARY_COMMITMENT]\n\n u32assert2 u32lt\n # => [is_unauthorized, TX_SUMMARY_COMMITMENT]\n\n # If signatures are non-existent the tx will fail here.\n if.true\n emit.AUTH_UNAUTHORIZED_EVENT\n push.0 assert.err=\"insufficient number of signatures\"\n end\n\n # => [TX_SUMMARY_COMMITMENT]\nend\n";
3
+ export declare const GUARDIAN_MASM = "# Guardian Authentication Component\n#\n# This component provides GUARDIAN signature verification for accounts.\n# It can be used standalone or in conjunction with other auth components like multisig.\n\nuse miden::protocol::active_account\nuse miden::protocol::auth::AUTH_UNAUTHORIZED_EVENT\nuse miden::protocol::native_account\n\n# IMPORTANT SECURITY NOTES\n# --------------------------------------------------------------------------------\n# - The selector in `GUARDIAN_SELECTOR_SLOT` controls whether the extra GUARDIAN signature\n# is enforced:\n# * GUARDIAN_ON => exactly one valid GUARDIAN signature is required.\n# * GUARDIAN_OFF => GUARDIAN signature is skipped for that call.\n#\n# - `verify_guardian_signature` reads the selector from initial storage state.\n# This means changes made during the same transaction won't affect the check.\n#\n# - `enable_guardian` / `disable_guardian` procedures allow explicit control over GUARDIAN state.\n#\n# - `update_guardian_public_key`:\n# * Installs a new GUARDIAN public key in the map at `GUARDIAN_PUBLIC_KEY_MAP_SLOT`.\n# * Does not itself perform any signature checks.\n# * To update the key without requiring GUARDIAN signature, ensure selector is OFF.\n#\n# Storage Layout\n# --------------------------------------------------------------------------------\n#\n# +---------------------+---------------+\n# | DESCRIPTION | SLOT |\n# +---------------------+---------------+\n# | GUARDIAN SELECTOR (word) | 0 |\n# | GUARDIAN PUBLIC KEY MAP | 1 |\n# | GUARDIAN SCHEME ID MAP | 2 |\n# +---------------------+---------------+\n#\n# - GUARDIAN_SELECTOR_SLOT (0):\n# * Stores a word that is compared against [1, 0, 0, 0] (GUARDIAN_ON).\n# * Any value != GUARDIAN_ON is treated as GUARDIAN_OFF.\n#\n# - GUARDIAN_PUBLIC_KEY_MAP_SLOT (1):\n# * A map from a fixed key [0, 0, 0, 0] to the single GUARDIAN public key:\n# [0, 0, 0, 0] => GUARDIAN_PUBLIC_KEY\n# * GUARDIAN_PUBLIC_KEY is a Falcon Poseidon2 public key represented as a word.\n\n# CONSTANTS\n# =================================================================================================\n\n# Slot where the GUARDIAN selector flag is stored (using word() for named slot access):\n# - GUARDIAN_ON => GUARDIAN signature required\n# - GUARDIAN_OFF => GUARDIAN signature skipped\nconst GUARDIAN_SELECTOR_SLOT=word(\"openzeppelin::guardian::selector\")\n\n# Map slot for GUARDIAN public key\n# Uses exactly one GUARDIAN public key at index [0, 0, 0, 0]\n# [0, 0, 0, 0] => GUARDIAN_PUBLIC_KEY\nconst GUARDIAN_PUBLIC_KEY_MAP_SLOT=word(\"openzeppelin::guardian::public_key\")\n\n# Map slot for GUARDIAN signature scheme IDs\n# Uses exactly one scheme ID entry at index [0, 0, 0, 0]\n# [0, 0, 0, 0] => [scheme_id, 0, 0, 0]\nconst GUARDIAN_SCHEME_ID_MAP_SLOT=word(\"openzeppelin::guardian::scheme_id\")\n\n# Selector flag values\nconst GUARDIAN_ON=[1, 0, 0, 0]\nconst GUARDIAN_OFF=[0, 0, 0, 0]\nconst FALCON_512_POSEIDON2_SCHEME_WORD=[2, 0, 0, 0]\n\n# GUARDIAN PROCEDURES\n# =================================================================================================\n\n#! Enable GUARDIAN verification by setting the selector to ON.\n#!\n#! Operand stack inputs: []\n#! Outputs: []\n#!\n#! Notes:\n#! - Sets GUARDIAN_SELECTOR_SLOT to GUARDIAN_ON (1)\n#! - After this, transactions will require GUARDIAN signature verification\nproc enable_guardian\n push.GUARDIAN_ON\n # => [GUARDIAN_ON]\n\n push.GUARDIAN_SELECTOR_SLOT[0..2]\n # => [selector_slot_prefix, selector_slot_suffix, GUARDIAN_ON]\n\n exec.native_account::set_item\n # => [OLD_ROOT]\n\n dropw\n # => []\nend\n\n#! Disable GUARDIAN verification by setting the selector to OFF.\n#!\n#! Operand stack inputs: []\n#! Outputs: []\n#!\n#! Notes:\n#! - Sets GUARDIAN_SELECTOR_SLOT to GUARDIAN_OFF (0)\n#! - After this, transactions will NOT require GUARDIAN signature verification\nproc disable_guardian\n push.GUARDIAN_OFF\n # => [GUARDIAN_OFF]\n\n push.GUARDIAN_SELECTOR_SLOT[0..2]\n # => [selector_slot_prefix, selector_slot_suffix, GUARDIAN_OFF]\n\n exec.native_account::set_item\n # => [OLD_ROOT]\n\n dropw\n # => []\nend\n\n#! Update the GUARDIAN public key.\n#!\n#! Operand stack inputs: []\n#! Advice stack inputs: [PUB_KEY]\n#! - PUB_KEY is the new GUARDIAN RPO Falcon 512 public key\n#!\n#! Notes:\n#! - Stores PUB_KEY into GUARDIAN_PUBLIC_KEY_MAP_SLOT:\n#! [0, 0, 0, 0] => GUARDIAN_PUBLIC_KEY\n#! - To update the key without requiring GUARDIAN signature, ensure\n#! GUARDIAN_SELECTOR_SLOT = 0 (OFF) before calling this.\npub proc update_guardian_public_key\n exec.disable_guardian\n # ------ Update the GUARDIAN public key ------\n adv_loadw\n # => [PUB_KEY]\n\n push.0.0.0.0\n # => [MAP_KEY, PUB_KEY]\n # Note that MAP_KEY is [0, 0, 0, 0] for a single GUARDIAN_KEY\n\n push.GUARDIAN_PUBLIC_KEY_MAP_SLOT[0..2]\n # => [pub_key_slot_prefix, pub_key_slot_suffix, MAP_KEY, PUB_KEY]\n\n exec.native_account::set_map_item\n # => [OLD_MAP_VALUE]\n\n dropw\n # => []\n\n push.0.0.0.0\n # => [MAP_KEY]\n\n push.FALCON_512_POSEIDON2_SCHEME_WORD\n # => [SCHEME_ID_WORD, MAP_KEY]\n\n swapw\n # => [MAP_KEY, SCHEME_ID_WORD]\n\n push.GUARDIAN_SCHEME_ID_MAP_SLOT[0..2]\n # => [scheme_id_slot_prefix, scheme_id_slot_suffix, MAP_KEY, SCHEME_ID_WORD]\n\n exec.native_account::set_map_item\n # => [OLD_MAP_VALUE]\n\n dropw\n # => []\nend\n\n#! Conditionally verify a \"GUARDIAN\" signature against a stored public key hash.\n#! The condition is controlled by the selector at GUARDIAN_SELECTOR_SLOT.\n#!\n#! Inputs: [MSG]\n#! Outputs: [MSG]\n#!\n#! Panics if:\n#! - Selector is ON but the provided GUARDIAN signature is invalid or missing.\n#!\n#! Notes:\n#! - MSG is TX_SUMMARY_COMMITMENT provided by auth procedure\n#! - If selector is OFF (0), GUARDIAN verification is skipped\n#! - Selector value is read from initial storage state\npub proc verify_guardian_signature(msg: word)\n push.GUARDIAN_SELECTOR_SLOT[0..2]\n exec.active_account::get_item\n drop drop drop\n # => [selector, MSG]\n\n push.1 eq\n if.true\n push.1\n push.GUARDIAN_PUBLIC_KEY_MAP_SLOT[0..2]\n push.GUARDIAN_SCHEME_ID_MAP_SLOT[0..2]\n exec.::miden::standards::auth::signature::verify_signatures\n push.1 neq\n if.true\n emit.AUTH_UNAUTHORIZED_EVENT\n push.0 assert.err=\"invalid GUARDIAN signature\"\n end\n end\n # => [MSG]\n exec.enable_guardian\nend\n";
4
+ export declare const GUARDIAN_ECDSA_MASM = "# Guardian Authentication Component (ECDSA)\n#\n# This component provides GUARDIAN signature verification for accounts using\n# ECDSA secp256k1 (k256/keccak) signatures.\n# It can be used standalone or in conjunction with other auth components like multisig.\n\nuse miden::protocol::active_account\nuse miden::protocol::auth::AUTH_UNAUTHORIZED_EVENT\nuse miden::protocol::native_account\n\n# IMPORTANT SECURITY NOTES\n# --------------------------------------------------------------------------------\n# - The selector in `GUARDIAN_SELECTOR_SLOT` controls whether the extra GUARDIAN signature\n# is enforced:\n# * GUARDIAN_ON => exactly one valid GUARDIAN signature is required.\n# * GUARDIAN_OFF => GUARDIAN signature is skipped for that call.\n#\n# - `verify_guardian_signature` reads the selector from initial storage state.\n# This means changes made during the same transaction won't affect the check.\n#\n# - `enable_guardian` / `disable_guardian` procedures allow explicit control over GUARDIAN state.\n#\n# - `update_guardian_public_key`:\n# * Installs a new GUARDIAN public key in the map at `GUARDIAN_PUBLIC_KEY_MAP_SLOT`.\n# * Does not itself perform any signature checks.\n# * To update the key without requiring GUARDIAN signature, ensure selector is OFF.\n#\n# Storage Layout\n# --------------------------------------------------------------------------------\n#\n# +---------------------+---------------+\n# | DESCRIPTION | SLOT |\n# +---------------------+---------------+\n# | GUARDIAN SELECTOR (word) | 0 |\n# | GUARDIAN PUBLIC KEY MAP | 1 |\n# +---------------------+---------------+\n#\n# - GUARDIAN_SELECTOR_SLOT (0):\n# * Stores a word that is compared against [1, 0, 0, 0] (GUARDIAN_ON).\n# * Any value != GUARDIAN_ON is treated as GUARDIAN_OFF.\n#\n# - GUARDIAN_PUBLIC_KEY_MAP_SLOT (1):\n# * A map from a fixed key [0, 0, 0, 0] to the single GUARDIAN public key:\n# [0, 0, 0, 0] => GUARDIAN_PUBLIC_KEY\n# * GUARDIAN_PUBLIC_KEY is an ECDSA secp256k1 public key represented as a word.\n\n# CONSTANTS\n# =================================================================================================\n\n# Slot where the GUARDIAN selector flag is stored (using word() for named slot access):\n# - GUARDIAN_ON => GUARDIAN signature required\n# - GUARDIAN_OFF => GUARDIAN signature skipped\nconst GUARDIAN_SELECTOR_SLOT=word(\"openzeppelin::guardian::selector\")\n\n# Map slot for GUARDIAN public key\n# Uses exactly one GUARDIAN public key at index [0, 0, 0, 0]\n# [0, 0, 0, 0] => GUARDIAN_PUBLIC_KEY\nconst GUARDIAN_PUBLIC_KEY_MAP_SLOT=word(\"openzeppelin::guardian::public_key\")\nconst GUARDIAN_SCHEME_ID_MAP_SLOT=word(\"openzeppelin::guardian::scheme_id\")\n\n# Selector flag values\nconst GUARDIAN_ON=[1, 0, 0, 0]\nconst GUARDIAN_OFF=[0, 0, 0, 0]\nconst ECDSA_K256_KECCAK_SCHEME_WORD=[1, 0, 0, 0]\n\n# GUARDIAN PROCEDURES\n# =================================================================================================\n\n#! Enable GUARDIAN verification by setting the selector to ON.\n#!\n#! Operand stack inputs: []\n#! Outputs: []\n#!\n#! Notes:\n#! - Sets GUARDIAN_SELECTOR_SLOT to GUARDIAN_ON (1)\n#! - After this, transactions will require GUARDIAN signature verification\nproc enable_guardian\n push.GUARDIAN_ON\n # => [GUARDIAN_ON]\n\n push.GUARDIAN_SELECTOR_SLOT[0..2]\n # => [selector_slot_prefix, selector_slot_suffix, GUARDIAN_ON]\n\n exec.native_account::set_item\n # => [OLD_ROOT]\n\n dropw\n # => []\nend\n\n#! Disable GUARDIAN verification by setting the selector to OFF.\n#!\n#! Operand stack inputs: []\n#! Outputs: []\n#!\n#! Notes:\n#! - Sets GUARDIAN_SELECTOR_SLOT to GUARDIAN_OFF (0)\n#! - After this, transactions will NOT require GUARDIAN signature verification\nproc disable_guardian\n push.GUARDIAN_OFF\n # => [GUARDIAN_OFF]\n\n push.GUARDIAN_SELECTOR_SLOT[0..2]\n # => [selector_slot_prefix, selector_slot_suffix, GUARDIAN_OFF]\n\n exec.native_account::set_item\n # => [OLD_ROOT]\n\n dropw\n # => []\nend\n\n#! Update the GUARDIAN public key.\n#!\n#! Operand stack inputs: []\n#! Advice stack inputs: [PUB_KEY]\n#! - PUB_KEY is the new GUARDIAN ECDSA secp256k1 public key\n#!\n#! Notes:\n#! - Stores PUB_KEY into GUARDIAN_PUBLIC_KEY_MAP_SLOT:\n#! [0, 0, 0, 0] => GUARDIAN_PUBLIC_KEY\n#! - To update the key without requiring GUARDIAN signature, ensure\n#! GUARDIAN_SELECTOR_SLOT = 0 (OFF) before calling this.\npub proc update_guardian_public_key\n exec.disable_guardian\n # ------ Update the GUARDIAN public key ------\n adv_loadw\n # => [PUB_KEY]\n\n push.0.0.0.0\n # => [MAP_KEY, PUB_KEY]\n # Note that MAP_KEY is [0, 0, 0, 0] for a single GUARDIAN_KEY\n\n push.GUARDIAN_PUBLIC_KEY_MAP_SLOT[0..2]\n # => [pub_key_slot_prefix, pub_key_slot_suffix, MAP_KEY, PUB_KEY]\n\n exec.native_account::set_map_item\n # => [OLD_MAP_VALUE]\n\n dropw\n # => []\n\n push.0.0.0.0\n # => [MAP_KEY]\n\n push.ECDSA_K256_KECCAK_SCHEME_WORD\n # => [SCHEME_ID_WORD, MAP_KEY]\n\n swapw\n # => [MAP_KEY, SCHEME_ID_WORD]\n\n push.GUARDIAN_SCHEME_ID_MAP_SLOT[0..2]\n # => [scheme_id_slot_prefix, scheme_id_slot_suffix, MAP_KEY, SCHEME_ID_WORD]\n\n exec.native_account::set_map_item\n # => [OLD_MAP_VALUE]\n\n dropw\n # => []\nend\n\n#! Conditionally verify a \"GUARDIAN\" signature against a stored public key hash.\n#! The condition is controlled by the selector at GUARDIAN_SELECTOR_SLOT.\n#!\n#! Inputs: [MSG]\n#! Outputs: [MSG]\n#!\n#! Panics if:\n#! - Selector is ON but the provided GUARDIAN signature is invalid or missing.\n#!\n#! Notes:\n#! - MSG is TX_SUMMARY_COMMITMENT provided by auth procedure\n#! - If selector is OFF (0), GUARDIAN verification is skipped\n#! - Selector value is read from initial storage state\npub proc verify_guardian_signature(msg: word)\n push.GUARDIAN_SELECTOR_SLOT[0..2]\n exec.active_account::get_item\n drop drop drop\n # => [selector, MSG]\n\n push.1 eq\n if.true\n push.1\n push.GUARDIAN_PUBLIC_KEY_MAP_SLOT[0..2]\n push.GUARDIAN_SCHEME_ID_MAP_SLOT[0..2]\n exec.::miden::standards::auth::signature::verify_signatures\n push.1 neq\n if.true\n emit.AUTH_UNAUTHORIZED_EVENT\n push.0 assert.err=\"invalid GUARDIAN signature\"\n end\n end\n # => [MSG]\n exec.enable_guardian\nend\n";
5
5
  //# sourceMappingURL=auth.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../../src/account/masm/auth.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,aAAa,2hjBAqgBzB,CAAC;AAEF,eAAO,MAAM,mBAAmB,+ijBAogB/B,CAAC;AAEF,eAAO,MAAM,aAAa,q5LAiLzB,CAAC;AAEF,eAAO,MAAM,mBAAmB,s9LAkL/B,CAAC"}
1
+ {"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../../src/account/masm/auth.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,aAAa,6xlBAoiBzB,CAAC;AAEF,eAAO,MAAM,mBAAmB,yylBAoiB/B,CAAC;AAEF,eAAO,MAAM,aAAa,89MAuMzB,CAAC;AAEF,eAAO,MAAM,mBAAmB,i1MAmM/B,CAAC"}