@openzeppelin/miden-multisig-client 0.13.0 → 0.13.2

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 (273) hide show
  1. package/README.md +98 -119
  2. package/dist/account/builder.d.ts +18 -0
  3. package/dist/account/builder.d.ts.map +1 -1
  4. package/dist/account/builder.js +59 -29
  5. package/dist/account/builder.js.map +1 -1
  6. package/dist/account/builder.test.d.ts +2 -0
  7. package/dist/account/builder.test.d.ts.map +1 -0
  8. package/dist/account/builder.test.js +115 -0
  9. package/dist/account/builder.test.js.map +1 -0
  10. package/dist/account/index.d.ts +1 -1
  11. package/dist/account/index.d.ts.map +1 -1
  12. package/dist/account/index.js +1 -1
  13. package/dist/account/index.js.map +1 -1
  14. package/dist/account/masm/account-components/auth.d.ts +5 -0
  15. package/dist/account/masm/account-components/auth.d.ts.map +1 -0
  16. package/dist/account/masm/account-components/auth.js +67 -0
  17. package/dist/account/masm/account-components/auth.js.map +1 -0
  18. package/dist/account/masm/auth.d.ts +5 -0
  19. package/dist/account/masm/auth.d.ts.map +1 -0
  20. package/dist/account/masm/auth.js +1395 -0
  21. package/dist/account/masm/auth.js.map +1 -0
  22. package/dist/account/masm/index.d.ts +3 -0
  23. package/dist/account/masm/index.d.ts.map +1 -0
  24. package/dist/account/masm/index.js +5 -0
  25. package/dist/account/masm/index.js.map +1 -0
  26. package/dist/account/masm.d.ts +1 -4
  27. package/dist/account/masm.d.ts.map +1 -1
  28. package/dist/account/masm.js +3 -1034
  29. package/dist/account/masm.js.map +1 -1
  30. package/dist/account/storage.d.ts +2 -2
  31. package/dist/account/storage.d.ts.map +1 -1
  32. package/dist/account/storage.js +18 -16
  33. package/dist/account/storage.js.map +1 -1
  34. package/dist/client.d.ts +67 -9
  35. package/dist/client.d.ts.map +1 -1
  36. package/dist/client.js +73 -22
  37. package/dist/client.js.map +1 -1
  38. package/dist/client.test.js +31 -32
  39. package/dist/client.test.js.map +1 -1
  40. package/dist/index.d.ts +54 -12
  41. package/dist/index.d.ts.map +1 -1
  42. package/dist/index.js +53 -9
  43. package/dist/index.js.map +1 -1
  44. package/dist/inspector.d.ts +32 -6
  45. package/dist/inspector.d.ts.map +1 -1
  46. package/dist/inspector.js +58 -23
  47. package/dist/inspector.js.map +1 -1
  48. package/dist/inspector.test.js +18 -18
  49. package/dist/inspector.test.js.map +1 -1
  50. package/dist/multisig/proposal/execution.d.ts +6 -5
  51. package/dist/multisig/proposal/execution.d.ts.map +1 -1
  52. package/dist/multisig/proposal/execution.js +49 -27
  53. package/dist/multisig/proposal/execution.js.map +1 -1
  54. package/dist/multisig/proposal/parser.d.ts +3 -3
  55. package/dist/multisig/proposal/parser.d.ts.map +1 -1
  56. package/dist/multisig/proposal/parser.js +23 -23
  57. package/dist/multisig/proposal/parser.js.map +1 -1
  58. package/dist/multisig/signing.d.ts +3 -3
  59. package/dist/multisig/signing.d.ts.map +1 -1
  60. package/dist/multisig/signing.js +3 -3
  61. package/dist/multisig/signing.js.map +1 -1
  62. package/dist/multisig.d.ts +187 -46
  63. package/dist/multisig.d.ts.map +1 -1
  64. package/dist/multisig.js +650 -289
  65. package/dist/multisig.js.map +1 -1
  66. package/dist/multisig.test.js +1680 -241
  67. package/dist/multisig.test.js.map +1 -1
  68. package/dist/procedures.d.ts +46 -24
  69. package/dist/procedures.d.ts.map +1 -1
  70. package/dist/procedures.js +46 -21
  71. package/dist/procedures.js.map +1 -1
  72. package/dist/proposal/factory.d.ts +18 -0
  73. package/dist/proposal/factory.d.ts.map +1 -0
  74. package/dist/proposal/factory.js +99 -0
  75. package/dist/proposal/factory.js.map +1 -0
  76. package/dist/proposal/metadata.d.ts +8 -0
  77. package/dist/proposal/metadata.d.ts.map +1 -0
  78. package/dist/proposal/metadata.js +156 -0
  79. package/dist/proposal/metadata.js.map +1 -0
  80. package/dist/proposal/signatures.d.ts +10 -0
  81. package/dist/proposal/signatures.d.ts.map +1 -0
  82. package/dist/proposal/signatures.js +54 -0
  83. package/dist/proposal/signatures.js.map +1 -0
  84. package/dist/signer.d.ts +2 -0
  85. package/dist/signer.d.ts.map +1 -1
  86. package/dist/signer.js +2 -0
  87. package/dist/signer.js.map +1 -1
  88. package/dist/signers/ecdsa.d.ts +3 -0
  89. package/dist/signers/ecdsa.d.ts.map +1 -1
  90. package/dist/signers/ecdsa.js +8 -4
  91. package/dist/signers/ecdsa.js.map +1 -1
  92. package/dist/signers/ecdsa.test.d.ts +2 -0
  93. package/dist/signers/ecdsa.test.d.ts.map +1 -0
  94. package/dist/signers/ecdsa.test.js +65 -0
  95. package/dist/signers/ecdsa.test.js.map +1 -0
  96. package/dist/signers/falcon.d.ts +3 -0
  97. package/dist/signers/falcon.d.ts.map +1 -1
  98. package/dist/signers/falcon.js +8 -4
  99. package/dist/signers/falcon.js.map +1 -1
  100. package/dist/signers/falcon.test.js +12 -0
  101. package/dist/signers/falcon.test.js.map +1 -1
  102. package/dist/signers/miden-wallet.d.ts +3 -1
  103. package/dist/signers/miden-wallet.d.ts.map +1 -1
  104. package/dist/signers/miden-wallet.js +11 -2
  105. package/dist/signers/miden-wallet.js.map +1 -1
  106. package/dist/signers/miden-wallet.test.js +26 -0
  107. package/dist/signers/miden-wallet.test.js.map +1 -1
  108. package/dist/signers/para.d.ts +3 -3
  109. package/dist/signers/para.d.ts.map +1 -1
  110. package/dist/signers/para.js +15 -6
  111. package/dist/signers/para.js.map +1 -1
  112. package/dist/signers/para.test.js +39 -0
  113. package/dist/signers/para.test.js.map +1 -1
  114. package/dist/transaction/consumeNotes.d.ts.map +1 -1
  115. package/dist/transaction/consumeNotes.js +1 -0
  116. package/dist/transaction/consumeNotes.js.map +1 -1
  117. package/dist/transaction/index.d.ts +2 -1
  118. package/dist/transaction/index.d.ts.map +1 -1
  119. package/dist/transaction/index.js +2 -1
  120. package/dist/transaction/index.js.map +1 -1
  121. package/dist/transaction/options.d.ts +1 -1
  122. package/dist/transaction/options.d.ts.map +1 -1
  123. package/dist/transaction/p2id.d.ts +1 -0
  124. package/dist/transaction/p2id.d.ts.map +1 -1
  125. package/dist/transaction/p2id.js +9 -3
  126. package/dist/transaction/p2id.js.map +1 -1
  127. package/dist/transaction/p2id.test.d.ts +2 -0
  128. package/dist/transaction/p2id.test.d.ts.map +1 -0
  129. package/dist/transaction/p2id.test.js +138 -0
  130. package/dist/transaction/p2id.test.js.map +1 -0
  131. package/dist/transaction/rpoRandomCoin.d.ts +7 -0
  132. package/dist/transaction/rpoRandomCoin.d.ts.map +1 -0
  133. package/dist/transaction/rpoRandomCoin.js +17 -0
  134. package/dist/transaction/rpoRandomCoin.js.map +1 -0
  135. package/dist/transaction/rpoRandomCoin.test.d.ts +2 -0
  136. package/dist/transaction/rpoRandomCoin.test.d.ts.map +1 -0
  137. package/dist/transaction/rpoRandomCoin.test.js +52 -0
  138. package/dist/transaction/rpoRandomCoin.test.js.map +1 -0
  139. package/dist/transaction/updateGuardian.d.ts +7 -0
  140. package/dist/transaction/updateGuardian.d.ts.map +1 -0
  141. package/dist/transaction/{updatePsm.js → updateGuardian.js} +15 -29
  142. package/dist/transaction/updateGuardian.js.map +1 -0
  143. package/dist/transaction/updateProcedureThreshold.d.ts +9 -0
  144. package/dist/transaction/updateProcedureThreshold.d.ts.map +1 -0
  145. package/dist/transaction/updateProcedureThreshold.js +55 -0
  146. package/dist/transaction/updateProcedureThreshold.js.map +1 -0
  147. package/dist/transaction/updateSigners.d.ts.map +1 -1
  148. package/dist/transaction/updateSigners.js +5 -23
  149. package/dist/transaction/updateSigners.js.map +1 -1
  150. package/dist/transaction.d.ts +2 -1
  151. package/dist/transaction.d.ts.map +1 -1
  152. package/dist/transaction.js +2 -1
  153. package/dist/transaction.js.map +1 -1
  154. package/dist/types/proposal.d.ts +32 -15
  155. package/dist/types/proposal.d.ts.map +1 -1
  156. package/dist/types.d.ts +24 -7
  157. package/dist/types.d.ts.map +1 -1
  158. package/dist/utils/digest.d.ts +5 -0
  159. package/dist/utils/digest.d.ts.map +1 -1
  160. package/dist/utils/digest.js +34 -1
  161. package/dist/utils/digest.js.map +1 -1
  162. package/dist/utils/digest.test.d.ts +2 -0
  163. package/dist/utils/digest.test.d.ts.map +1 -0
  164. package/dist/utils/digest.test.js +48 -0
  165. package/dist/utils/digest.test.js.map +1 -0
  166. package/dist/utils/signature.d.ts +3 -1
  167. package/dist/utils/signature.d.ts.map +1 -1
  168. package/dist/utils/signature.js +31 -6
  169. package/dist/utils/signature.js.map +1 -1
  170. package/dist/utils/word.test.js +1 -52
  171. package/dist/utils/word.test.js.map +1 -1
  172. package/masm/account_components/auth/multisig.masm +13 -0
  173. package/masm/account_components/auth/multisig_ecdsa.masm +13 -0
  174. package/masm/account_components/auth/multisig_guardian.masm +17 -0
  175. package/masm/account_components/auth/multisig_guardian_ecdsa.masm +17 -0
  176. package/masm/auth/guardian.masm +177 -0
  177. package/masm/auth/guardian_ecdsa.masm +178 -0
  178. package/masm/{multisig.masm → auth/multisig.masm} +149 -55
  179. package/masm/{multisig_ecdsa.masm → auth/multisig_ecdsa.masm} +148 -56
  180. package/package.json +11 -9
  181. package/src/account/builder.test.ts +165 -0
  182. package/src/account/builder.ts +71 -34
  183. package/src/account/index.ts +1 -1
  184. package/src/account/masm/account-components/auth.ts +70 -0
  185. package/src/account/masm/auth.ts +1398 -0
  186. package/src/account/masm/index.ts +5 -0
  187. package/src/account/masm.ts +3 -1040
  188. package/src/account/storage.ts +18 -16
  189. package/src/client.test.ts +31 -35
  190. package/src/client.ts +98 -26
  191. package/src/index.ts +84 -22
  192. package/src/inspector.test.ts +17 -17
  193. package/src/inspector.ts +63 -29
  194. package/src/multisig/proposal/execution.ts +102 -41
  195. package/src/multisig/proposal/parser.ts +26 -26
  196. package/src/multisig/signing.ts +4 -4
  197. package/src/multisig.test.ts +2097 -248
  198. package/src/multisig.ts +882 -365
  199. package/src/procedures.ts +50 -26
  200. package/src/proposal/factory.ts +171 -0
  201. package/src/proposal/metadata.ts +165 -0
  202. package/src/proposal/signatures.ts +68 -0
  203. package/src/signer.ts +2 -0
  204. package/src/signers/ecdsa.test.ts +80 -0
  205. package/src/signers/ecdsa.ts +15 -4
  206. package/src/signers/falcon.test.ts +19 -0
  207. package/src/signers/falcon.ts +16 -5
  208. package/src/signers/miden-wallet.test.ts +47 -0
  209. package/src/signers/miden-wallet.ts +18 -1
  210. package/src/signers/para.test.ts +57 -0
  211. package/src/signers/para.ts +26 -7
  212. package/src/transaction/consumeNotes.ts +1 -0
  213. package/src/transaction/index.ts +2 -2
  214. package/src/transaction/options.ts +1 -2
  215. package/src/transaction/p2id.test.ts +190 -0
  216. package/src/transaction/p2id.ts +11 -5
  217. package/src/transaction/rpoRandomCoin.test.ts +64 -0
  218. package/src/transaction/rpoRandomCoin.ts +24 -0
  219. package/src/transaction/{updatePsm.ts → updateGuardian.ts} +19 -32
  220. package/src/transaction/updateProcedureThreshold.ts +97 -0
  221. package/src/transaction/updateSigners.ts +12 -27
  222. package/src/transaction.ts +5 -3
  223. package/src/types/proposal.ts +43 -11
  224. package/src/types.ts +29 -11
  225. package/src/utils/digest.test.ts +55 -0
  226. package/src/utils/digest.ts +51 -1
  227. package/src/utils/signature.ts +47 -9
  228. package/src/utils/word.test.ts +1 -55
  229. package/dist/account.d.ts +0 -104
  230. package/dist/account.d.ts.map +0 -1
  231. package/dist/account.js +0 -136
  232. package/dist/account.js.map +0 -1
  233. package/dist/builder.d.ts +0 -54
  234. package/dist/builder.d.ts.map +0 -1
  235. package/dist/builder.js +0 -78
  236. package/dist/builder.js.map +0 -1
  237. package/dist/http.d.ts +0 -64
  238. package/dist/http.d.ts.map +0 -1
  239. package/dist/http.js +0 -162
  240. package/dist/http.js.map +0 -1
  241. package/dist/keystore.d.ts +0 -65
  242. package/dist/keystore.d.ts.map +0 -1
  243. package/dist/keystore.js +0 -121
  244. package/dist/keystore.js.map +0 -1
  245. package/dist/miden.d.ts +0 -9
  246. package/dist/miden.d.ts.map +0 -1
  247. package/dist/miden.js +0 -26
  248. package/dist/miden.js.map +0 -1
  249. package/dist/multisig/metadata.d.ts +0 -18
  250. package/dist/multisig/metadata.d.ts.map +0 -1
  251. package/dist/multisig/metadata.js +0 -100
  252. package/dist/multisig/metadata.js.map +0 -1
  253. package/dist/multisig/metadata.test.d.ts +0 -2
  254. package/dist/multisig/metadata.test.d.ts.map +0 -1
  255. package/dist/multisig/metadata.test.js +0 -323
  256. package/dist/multisig/metadata.test.js.map +0 -1
  257. package/dist/signer.test.d.ts +0 -2
  258. package/dist/signer.test.d.ts.map +0 -1
  259. package/dist/signer.test.js +0 -117
  260. package/dist/signer.test.js.map +0 -1
  261. package/dist/transaction/updatePsm.d.ts +0 -7
  262. package/dist/transaction/updatePsm.d.ts.map +0 -1
  263. package/dist/transaction/updatePsm.js.map +0 -1
  264. package/dist/transport/http.d.ts +0 -64
  265. package/dist/transport/http.d.ts.map +0 -1
  266. package/dist/transport/http.js +0 -162
  267. package/dist/transport/http.js.map +0 -1
  268. package/dist/transport/index.d.ts +0 -5
  269. package/dist/transport/index.d.ts.map +0 -1
  270. package/dist/transport/index.js +0 -5
  271. package/dist/transport/index.js.map +0 -1
  272. package/masm/psm.masm +0 -178
  273. package/masm/psm_ecdsa.masm +0 -179
@@ -1,14 +1,11 @@
1
- # Multi-Signature RPO Falcon 512 Authentication Component
1
+ # Multi-Signature RPO Falcon 512 Authentication Core Library
2
2
  #
3
- # This component provides multi-signature authentication for accounts.
4
- # It integrates with the PSM component for optional PSM signature verification.
3
+ # This library provides the reusable multisig procedures used by account wrappers.
5
4
 
6
- use miden::active_account
7
- use miden::native_account
8
- use miden::auth
9
- use openzeppelin::psm
5
+ use miden::protocol::active_account
6
+ use miden::protocol::native_account
7
+ use miden::standards::auth
10
8
 
11
- # Type definitions for v0.12 syntax
12
9
  type BeWord = struct @bigendian { a: felt, b: felt, c: felt, d: felt }
13
10
 
14
11
  # CONSTANTS
@@ -17,7 +14,7 @@ type BeWord = struct @bigendian { a: felt, b: felt, c: felt, d: felt }
17
14
  # Auth Request Constants
18
15
 
19
16
  # The event emitted when a signature is not found for a required signer.
20
- const AUTH_UNAUTHORIZED_EVENT = event("miden::auth::unauthorized")
17
+ const AUTH_UNAUTHORIZED_EVENT=event("miden::auth::unauthorized")
21
18
 
22
19
  # Storage Layout Constants
23
20
  #
@@ -32,29 +29,35 @@ const AUTH_UNAUTHORIZED_EVENT = event("miden::auth::unauthorized")
32
29
  # number of approvers are stored as:
33
30
  # [default_threshold, num_approvers, 0, 0].
34
31
  # The threshold is guaranteed to be less than or equal to num_approvers.
35
- const THRESHOLD_CONFIG_SLOT = 0
32
+ const THRESHOLD_CONFIG_SLOT=word("openzeppelin::multisig::threshold_config")
36
33
 
37
34
  # The slot in this component's storage layout where the public keys map is stored.
38
35
  # Map entries: [key_index, 0, 0, 0] => APPROVER_PUBLIC_KEY
39
- const PUBLIC_KEYS_MAP_SLOT = 1
36
+ const PUBLIC_KEYS_MAP_SLOT=word("openzeppelin::multisig::signer_public_keys")
40
37
 
41
38
  # The slot in this component's storage layout where executed transactions are stored.
42
39
  # Map entries: transaction_message => [is_executed, 0, 0, 0]
43
- const EXECUTED_TXS_SLOT = 2
40
+ const EXECUTED_TXS_SLOT=word("openzeppelin::multisig::executed_transactions")
44
41
 
45
42
  # The slot in this component's storage layout where procedure thresholds are stored.
46
43
  # Map entries: PROC_ROOT => [proc_threshold, 0, 0, 0]
47
- const PROC_THRESHOLD_ROOTS_SLOT = 3
44
+ const PROC_THRESHOLD_ROOTS_SLOT=word("openzeppelin::multisig::procedure_thresholds")
48
45
 
49
46
  # Executed Transaction Flag Constant
50
- const IS_EXECUTED_FLAG = [1, 0, 0, 0]
47
+ const IS_EXECUTED_FLAG=[1, 0, 0, 0]
51
48
 
52
49
  # ERRORS
53
- const ERR_TX_ALREADY_EXECUTED = "failed to approve multisig transaction as it was already executed"
50
+ const ERR_TX_ALREADY_EXECUTED="failed to approve multisig transaction as it was already executed"
54
51
 
55
- const ERR_MALFORMED_MULTISIG_CONFIG = "number of approvers must be equal to or greater than threshold"
52
+ const ERR_MALFORMED_MULTISIG_CONFIG="number of approvers must be equal to or greater than threshold"
56
53
 
57
- const ERR_ZERO_IN_MULTISIG_CONFIG = "number of approvers or threshold must not be zero"
54
+ const ERR_ZERO_IN_MULTISIG_CONFIG="number of approvers or threshold must not be zero"
55
+
56
+ const ERR_PROC_THRESHOLD_NOT_U32="procedure threshold must be a u32 value"
57
+
58
+ const ERR_NUM_APPROVERS_OR_PROC_THRESHOLD_NOT_U32="number of approvers and procedure threshold must be u32"
59
+
60
+ const ERR_PROC_THRESHOLD_EXCEEDS_NUM_APPROVERS="procedure threshold exceeds number of approvers"
58
61
 
59
62
  # MULTISIG PROCEDURES
60
63
  # =================================================================================================
@@ -66,21 +69,21 @@ const ERR_ZERO_IN_MULTISIG_CONFIG = "number of approvers or threshold must not b
66
69
  #!
67
70
  #! Panics if:
68
71
  #! - the same transaction has already been executed
69
- proc assert_new_tx(msg: BeWord)
72
+ pub proc assert_new_tx(msg: BeWord)
70
73
  push.IS_EXECUTED_FLAG
71
74
  # => [[0, 0, 0, is_executed], MSG]
72
75
 
73
76
  swapw
74
77
  # => [MSG, IS_EXECUTED_FLAG]
75
78
 
76
- push.EXECUTED_TXS_SLOT
77
- # => [index, MSG, IS_EXECUTED_FLAG]
79
+ push.EXECUTED_TXS_SLOT[0..2]
80
+ # => [txs_slot_prefix, txs_slot_suffix, MSG, IS_EXECUTED_FLAG]
78
81
 
79
82
  # Set the key value pair in the map to mark transaction as executed
80
83
  exec.native_account::set_map_item
81
- # => [OLD_MAP_ROOT, [0, 0, 0, is_executed]]
84
+ # => [[0, 0, 0, is_executed]]
82
85
 
83
- dropw drop drop drop
86
+ drop drop drop
84
87
  # => [is_executed]
85
88
 
86
89
  assertz.err=ERR_TX_ALREADY_EXECUTED
@@ -119,13 +122,13 @@ proc cleanup_pubkey_mapping(init_num_of_approvers: u32, new_num_of_approvers: u3
119
122
  padw swapw
120
123
  # => [[0, 0, 0, i-1], EMPTY_WORD, i-1, new_num_of_approvers]
121
124
 
122
- push.PUBLIC_KEYS_MAP_SLOT
123
- # => [pub_key_slot_idx, [0, 0, 0, i-1], EMPTY_WORD, i-1, new_num_of_approvers]
125
+ push.PUBLIC_KEYS_MAP_SLOT[0..2]
126
+ # => [pub_key_slot_prefix, pub_key_slot_suffix, [0, 0, 0, i-1], EMPTY_WORD, i-1, new_num_of_approvers]
124
127
 
125
128
  exec.native_account::set_map_item
126
- # => [OLD_MAP_ROOT, OLD_MAP_VALUE, i-1, new_num_of_approvers]
129
+ # => [OLD_MAP_VALUE, i-1, new_num_of_approvers]
127
130
 
128
- dropw dropw
131
+ dropw
129
132
  # => [i-1, new_num_of_approvers]
130
133
 
131
134
  dup.1 dup.1
@@ -137,6 +140,85 @@ proc cleanup_pubkey_mapping(init_num_of_approvers: u32, new_num_of_approvers: u3
137
140
  # => []
138
141
  end
139
142
 
143
+ proc get_threshold_and_num_approvers
144
+ push.THRESHOLD_CONFIG_SLOT[0..2]
145
+ exec.active_account::get_initial_item
146
+ # => [0, 0, num_approvers, threshold]
147
+
148
+ drop drop
149
+ # => [num_approvers, threshold]
150
+
151
+ swap
152
+ # => [threshold, num_approvers]
153
+ end
154
+
155
+ proc assert_proc_thresholds_lte_num_approvers(num_approvers: u32)
156
+ exec.active_account::get_num_procedures
157
+ # => [num_procedures, num_approvers]
158
+
159
+ dup neq.0
160
+ # => [should_continue, num_procedures, num_approvers]
161
+ while.true
162
+ sub.1 dup
163
+ # => [proc_index, proc_index, num_approvers]
164
+
165
+ exec.active_account::get_procedure_root
166
+ # => [PROC_ROOT, proc_index, num_approvers]
167
+
168
+ push.PROC_THRESHOLD_ROOTS_SLOT[0..2]
169
+ # => [proc_roots_slot_prefix, proc_roots_slot_suffix, PROC_ROOT, proc_index, num_approvers]
170
+
171
+ exec.active_account::get_initial_map_item
172
+ # => [[0, 0, 0, proc_threshold], proc_index, num_approvers]
173
+
174
+ drop drop drop
175
+ # => [proc_threshold, proc_index, num_approvers]
176
+
177
+ dup.2
178
+ # => [num_approvers, proc_threshold, proc_index, num_approvers]
179
+
180
+ u32assert2.err=ERR_PROC_THRESHOLD_NOT_U32
181
+ u32gt assertz.err=ERR_PROC_THRESHOLD_EXCEEDS_NUM_APPROVERS
182
+ # => [proc_index, num_approvers]
183
+
184
+ dup neq.0
185
+ # => [should_continue, proc_index, num_approvers]
186
+ end
187
+
188
+ drop drop
189
+ # => []
190
+ end
191
+
192
+ # Internal storage helper used by the public `update_procedure_threshold`
193
+ # entrypoint after it receives direct stack arguments.
194
+ proc set_procedure_threshold(proc_threshold: u32, proc_root: BeWord)
195
+ exec.get_threshold_and_num_approvers
196
+ # => [threshold, num_approvers, proc_threshold, PROC_ROOT]
197
+
198
+ drop
199
+ # => [num_approvers, proc_threshold, PROC_ROOT]
200
+
201
+ dup.1 swap
202
+ # => [num_approvers, proc_threshold, proc_threshold, PROC_ROOT]
203
+
204
+ u32assert2.err=ERR_NUM_APPROVERS_OR_PROC_THRESHOLD_NOT_U32
205
+ u32gt assertz.err=ERR_PROC_THRESHOLD_EXCEEDS_NUM_APPROVERS
206
+ # => [proc_threshold, PROC_ROOT]
207
+
208
+ push.0.0.0
209
+ swapw
210
+ # => [PROC_ROOT, PROC_THRESHOLD_WORD]
211
+
212
+ push.PROC_THRESHOLD_ROOTS_SLOT[0..2]
213
+ # => [proc_roots_slot_prefix, proc_roots_slot_suffix, PROC_ROOT, PROC_THRESHOLD_WORD]
214
+
215
+ exec.native_account::set_map_item
216
+ # => [OLD_VALUE]
217
+
218
+ dropw
219
+ # => []
220
+ end
221
+
140
222
  #! Update threshold config and add / remove approvers
141
223
  #!
142
224
  #! Inputs:
@@ -145,7 +227,7 @@ end
145
227
  #! MULTISIG_CONFIG_HASH => [CONFIG, PUB_KEY_N, PUB_KEY_N-1, ..., PUB_KEY_0]
146
228
  #! }
147
229
  #! Outputs:
148
- #! Operand stack: []
230
+ #! Operand stack: [TX_SUMMARY_COMMITMENT]
149
231
  #!
150
232
  #! Where:
151
233
  #! - MULTISIG_CONFIG_HASH is the hash of the threshold and new public key vector
@@ -155,7 +237,8 @@ end
155
237
  #! Locals:
156
238
  #! 0: new_num_of_approvers
157
239
  #! 1: init_num_of_approvers
158
- pub proc update_signers_and_threshold.2(multisig_config_hash: BeWord)
240
+ @locals(2)
241
+ pub proc update_signers_and_threshold(multisig_config_hash: BeWord)
159
242
  adv.push_mapval
160
243
  # => [MULTISIG_CONFIG_HASH, pad(12)]
161
244
 
@@ -182,8 +265,14 @@ pub proc update_signers_and_threshold.2(multisig_config_hash: BeWord)
182
265
  eq.0 assertz.err=ERR_ZERO_IN_MULTISIG_CONFIG
183
266
  # => [MULTISIG_CONFIG, pad(12)]
184
267
 
185
- push.THRESHOLD_CONFIG_SLOT
186
- # => [slot, MULTISIG_CONFIG, pad(12)]
268
+ loc_load.0
269
+ # => [num_approvers, MULTISIG_CONFIG, pad(12)]
270
+
271
+ exec.assert_proc_thresholds_lte_num_approvers
272
+ # => [MULTISIG_CONFIG, pad(12)]
273
+
274
+ push.THRESHOLD_CONFIG_SLOT[0..2]
275
+ # => [config_slot_prefix, config_slot_suffix, MULTISIG_CONFIG, pad(12)]
187
276
 
188
277
  exec.native_account::set_item
189
278
  # => [OLD_THRESHOLD_CONFIG, pad(12)]
@@ -209,13 +298,13 @@ pub proc update_signers_and_threshold.2(multisig_config_hash: BeWord)
209
298
  swapw
210
299
  # => [[0, 0, 0, i-1], PUB_KEY, i-1, pad(12)]
211
300
 
212
- push.PUBLIC_KEYS_MAP_SLOT
213
- # => [pub_key_slot_idx, [0, 0, 0, i-1], PUB_KEY, i-1, pad(12)]
301
+ push.PUBLIC_KEYS_MAP_SLOT[0..2]
302
+ # => [pub_key_slot_prefix, pub_key_slot_suffix, [0, 0, 0, i-1], PUB_KEY, i-1, pad(12)]
214
303
 
215
304
  exec.native_account::set_map_item
216
- # => [OLD_MAP_ROOT, OLD_MAP_VALUE, i-1, pad(12)]
305
+ # => [OLD_VALUE, i-1, pad(12)]
217
306
 
218
- dropw dropw
307
+ dropw
219
308
  # => [i-1, pad(12)]
220
309
 
221
310
  dup neq.0
@@ -236,13 +325,25 @@ pub proc update_signers_and_threshold.2(multisig_config_hash: BeWord)
236
325
  # => [pad(12)]
237
326
  end
238
327
 
328
+ #! Update or clear the threshold override for a specific procedure.
329
+ #!
330
+ #! Inputs:
331
+ #! Operand stack: [proc_threshold, PROC_ROOT]
332
+ #! Outputs:
333
+ #! Operand stack: []
334
+ #! Invocation: call
335
+ pub proc update_procedure_threshold(proc_threshold: u32, proc_root: BeWord)
336
+ exec.set_procedure_threshold
337
+ end
338
+
239
339
  # Computes the effective transaction threshold based on called procedures and per-procedure
240
340
  # overrides stored in PROC_THRESHOLD_ROOTS_SLOT. Falls back to default_threshold if no
241
341
  # overrides apply.
242
342
  #
243
343
  #! Inputs: [default_threshold]
244
344
  #! Outputs: [transaction_threshold]
245
- proc compute_transaction_threshold.1(default_threshold: u32) -> u32
345
+ @locals(1)
346
+ proc compute_transaction_threshold(default_threshold: u32) -> u32
246
347
  # 1. initialize transaction_threshold = 0
247
348
  # 2. iterate through all account procedures
248
349
  # a. check if the procedure was called during the transaction
@@ -281,8 +382,8 @@ proc compute_transaction_threshold.1(default_threshold: u32) -> u32
281
382
  if.true
282
383
  # => [PROC_ROOT, num_procedures-1, transaction_threshold]
283
384
 
284
- push.PROC_THRESHOLD_ROOTS_SLOT
285
- # => [PROC_THRESHOLD_ROOTS_SLOT, PROC_ROOT, num_procedures-1, transaction_threshold]
385
+ push.PROC_THRESHOLD_ROOTS_SLOT[0..2]
386
+ # => [PROC_THRESHOLD_ROOTS_SLOT_prefix, PROC_THRESHOLD_ROOTS_SLOT_suffix, PROC_ROOT, num_procedures-1, transaction_threshold]
286
387
 
287
388
  # 2b. get the override proc_threshold of that procedure
288
389
  # if the procedure has no override threshold, the returned map item will be [0, 0, 0, 0]
@@ -332,8 +433,7 @@ end
332
433
  #! 1. Computing the transaction summary message that needs to be signed
333
434
  #! 2. Verifying signatures from multiple required signers against their public keys
334
435
  #! 3. Ensuring the minimum threshold of valid signatures is met
335
- #! 4. Implementing replay protection by tracking executed transactions
336
- #! 5. Verifying PSM signature if PSM selector is enabled (via PSM component)
436
+ #! 4. Returning the transaction summary commitment for higher-level wrappers.
337
437
  #!
338
438
  #! Inputs:
339
439
  #! Operand stack: [SALT]
@@ -355,11 +455,11 @@ end
355
455
  #!
356
456
  #! Panics if:
357
457
  #! - insufficient number of valid signatures (below threshold).
358
- #! - the same transaction has already been executed (replay protection).
359
- #! - PSM signature verification fails (if PSM is enabled).
458
+ #! - insufficient number of valid signatures (below threshold).
360
459
  #!
361
- #! Invocation: call
362
- pub proc auth_tx_rpo_falcon512_multisig.1(salt: BeWord)
460
+ #! Invocation: exec
461
+ @locals(1)
462
+ pub proc auth_tx(salt: BeWord) -> BeWord
363
463
  exec.native_account::incr_nonce drop
364
464
  # => [SALT]
365
465
 
@@ -378,8 +478,8 @@ pub proc auth_tx_rpo_falcon512_multisig.1(salt: BeWord)
378
478
 
379
479
  # ------ Verifying approver signatures ------
380
480
 
381
- push.THRESHOLD_CONFIG_SLOT
382
- # => [index, TX_SUMMARY_COMMITMENT]
481
+ push.THRESHOLD_CONFIG_SLOT[0..2]
482
+ # => [config_slot_prefix, config_slot_suffix, TX_SUMMARY_COMMITMENT]
383
483
 
384
484
  exec.active_account::get_initial_item
385
485
  # => [0, 0, num_of_approvers, default_threshold, TX_SUMMARY_COMMITMENT]
@@ -390,10 +490,10 @@ pub proc auth_tx_rpo_falcon512_multisig.1(salt: BeWord)
390
490
  swap movdn.5
391
491
  # => [num_of_approvers, TX_SUMMARY_COMMITMENT, default_threshold]
392
492
 
393
- push.PUBLIC_KEYS_MAP_SLOT
394
- # => [pub_key_slot_idx, num_of_approvers, TX_SUMMARY_COMMITMENT, default_threshold]
493
+ push.PUBLIC_KEYS_MAP_SLOT[0..2]
494
+ # => [pub_key_slot_prefix, pub_key_slot_suffix, num_of_approvers, TX_SUMMARY_COMMITMENT, default_threshold]
395
495
 
396
- exec.::miden::auth::rpo_falcon512::verify_signatures
496
+ exec.::miden::standards::auth::falcon512_rpo::verify_signatures
397
497
  # => [num_verified_signatures, TX_SUMMARY_COMMITMENT, default_threshold]
398
498
 
399
499
  # ------ Checking threshold is >= num_verified_signatures ------
@@ -413,11 +513,5 @@ pub proc auth_tx_rpo_falcon512_multisig.1(salt: BeWord)
413
513
  push.0 assert.err="insufficient number of signatures"
414
514
  end
415
515
 
416
- # ------ Verifying PSM Signature ------
417
516
  # => [TX_SUMMARY_COMMITMENT]
418
- call.psm::verify_psm_signature
419
-
420
- # ------ Writing executed transaction MSG to map ------
421
- # => [TX_SUMMARY_COMMITMENT]
422
- exec.assert_new_tx
423
- end
517
+ end