@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.
- package/README.md +98 -119
- package/dist/account/builder.d.ts +18 -0
- package/dist/account/builder.d.ts.map +1 -1
- package/dist/account/builder.js +59 -29
- package/dist/account/builder.js.map +1 -1
- package/dist/account/builder.test.d.ts +2 -0
- package/dist/account/builder.test.d.ts.map +1 -0
- package/dist/account/builder.test.js +115 -0
- package/dist/account/builder.test.js.map +1 -0
- package/dist/account/index.d.ts +1 -1
- package/dist/account/index.d.ts.map +1 -1
- package/dist/account/index.js +1 -1
- package/dist/account/index.js.map +1 -1
- package/dist/account/masm/account-components/auth.d.ts +5 -0
- package/dist/account/masm/account-components/auth.d.ts.map +1 -0
- package/dist/account/masm/account-components/auth.js +67 -0
- package/dist/account/masm/account-components/auth.js.map +1 -0
- package/dist/account/masm/auth.d.ts +5 -0
- package/dist/account/masm/auth.d.ts.map +1 -0
- package/dist/account/masm/auth.js +1395 -0
- package/dist/account/masm/auth.js.map +1 -0
- package/dist/account/masm/index.d.ts +3 -0
- package/dist/account/masm/index.d.ts.map +1 -0
- package/dist/account/masm/index.js +5 -0
- package/dist/account/masm/index.js.map +1 -0
- package/dist/account/masm.d.ts +1 -4
- package/dist/account/masm.d.ts.map +1 -1
- package/dist/account/masm.js +3 -1034
- package/dist/account/masm.js.map +1 -1
- package/dist/account/storage.d.ts +2 -2
- package/dist/account/storage.d.ts.map +1 -1
- package/dist/account/storage.js +18 -16
- package/dist/account/storage.js.map +1 -1
- package/dist/client.d.ts +67 -9
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +73 -22
- package/dist/client.js.map +1 -1
- package/dist/client.test.js +31 -32
- package/dist/client.test.js.map +1 -1
- package/dist/index.d.ts +54 -12
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +53 -9
- package/dist/index.js.map +1 -1
- package/dist/inspector.d.ts +32 -6
- package/dist/inspector.d.ts.map +1 -1
- package/dist/inspector.js +58 -23
- package/dist/inspector.js.map +1 -1
- package/dist/inspector.test.js +18 -18
- package/dist/inspector.test.js.map +1 -1
- package/dist/multisig/proposal/execution.d.ts +6 -5
- package/dist/multisig/proposal/execution.d.ts.map +1 -1
- package/dist/multisig/proposal/execution.js +49 -27
- package/dist/multisig/proposal/execution.js.map +1 -1
- package/dist/multisig/proposal/parser.d.ts +3 -3
- package/dist/multisig/proposal/parser.d.ts.map +1 -1
- package/dist/multisig/proposal/parser.js +23 -23
- package/dist/multisig/proposal/parser.js.map +1 -1
- package/dist/multisig/signing.d.ts +3 -3
- package/dist/multisig/signing.d.ts.map +1 -1
- package/dist/multisig/signing.js +3 -3
- package/dist/multisig/signing.js.map +1 -1
- package/dist/multisig.d.ts +187 -46
- package/dist/multisig.d.ts.map +1 -1
- package/dist/multisig.js +650 -289
- package/dist/multisig.js.map +1 -1
- package/dist/multisig.test.js +1680 -241
- package/dist/multisig.test.js.map +1 -1
- package/dist/procedures.d.ts +46 -24
- package/dist/procedures.d.ts.map +1 -1
- package/dist/procedures.js +46 -21
- package/dist/procedures.js.map +1 -1
- package/dist/proposal/factory.d.ts +18 -0
- package/dist/proposal/factory.d.ts.map +1 -0
- package/dist/proposal/factory.js +99 -0
- package/dist/proposal/factory.js.map +1 -0
- package/dist/proposal/metadata.d.ts +8 -0
- package/dist/proposal/metadata.d.ts.map +1 -0
- package/dist/proposal/metadata.js +156 -0
- package/dist/proposal/metadata.js.map +1 -0
- package/dist/proposal/signatures.d.ts +10 -0
- package/dist/proposal/signatures.d.ts.map +1 -0
- package/dist/proposal/signatures.js +54 -0
- package/dist/proposal/signatures.js.map +1 -0
- package/dist/signer.d.ts +2 -0
- package/dist/signer.d.ts.map +1 -1
- package/dist/signer.js +2 -0
- package/dist/signer.js.map +1 -1
- package/dist/signers/ecdsa.d.ts +3 -0
- package/dist/signers/ecdsa.d.ts.map +1 -1
- package/dist/signers/ecdsa.js +8 -4
- package/dist/signers/ecdsa.js.map +1 -1
- package/dist/signers/ecdsa.test.d.ts +2 -0
- package/dist/signers/ecdsa.test.d.ts.map +1 -0
- package/dist/signers/ecdsa.test.js +65 -0
- package/dist/signers/ecdsa.test.js.map +1 -0
- package/dist/signers/falcon.d.ts +3 -0
- package/dist/signers/falcon.d.ts.map +1 -1
- package/dist/signers/falcon.js +8 -4
- package/dist/signers/falcon.js.map +1 -1
- package/dist/signers/falcon.test.js +12 -0
- package/dist/signers/falcon.test.js.map +1 -1
- package/dist/signers/miden-wallet.d.ts +3 -1
- package/dist/signers/miden-wallet.d.ts.map +1 -1
- package/dist/signers/miden-wallet.js +11 -2
- package/dist/signers/miden-wallet.js.map +1 -1
- package/dist/signers/miden-wallet.test.js +26 -0
- package/dist/signers/miden-wallet.test.js.map +1 -1
- package/dist/signers/para.d.ts +3 -3
- package/dist/signers/para.d.ts.map +1 -1
- package/dist/signers/para.js +15 -6
- package/dist/signers/para.js.map +1 -1
- package/dist/signers/para.test.js +39 -0
- package/dist/signers/para.test.js.map +1 -1
- package/dist/transaction/consumeNotes.d.ts.map +1 -1
- package/dist/transaction/consumeNotes.js +1 -0
- package/dist/transaction/consumeNotes.js.map +1 -1
- package/dist/transaction/index.d.ts +2 -1
- package/dist/transaction/index.d.ts.map +1 -1
- package/dist/transaction/index.js +2 -1
- package/dist/transaction/index.js.map +1 -1
- package/dist/transaction/options.d.ts +1 -1
- package/dist/transaction/options.d.ts.map +1 -1
- package/dist/transaction/p2id.d.ts +1 -0
- package/dist/transaction/p2id.d.ts.map +1 -1
- package/dist/transaction/p2id.js +9 -3
- package/dist/transaction/p2id.js.map +1 -1
- package/dist/transaction/p2id.test.d.ts +2 -0
- package/dist/transaction/p2id.test.d.ts.map +1 -0
- package/dist/transaction/p2id.test.js +138 -0
- package/dist/transaction/p2id.test.js.map +1 -0
- package/dist/transaction/rpoRandomCoin.d.ts +7 -0
- package/dist/transaction/rpoRandomCoin.d.ts.map +1 -0
- package/dist/transaction/rpoRandomCoin.js +17 -0
- package/dist/transaction/rpoRandomCoin.js.map +1 -0
- package/dist/transaction/rpoRandomCoin.test.d.ts +2 -0
- package/dist/transaction/rpoRandomCoin.test.d.ts.map +1 -0
- package/dist/transaction/rpoRandomCoin.test.js +52 -0
- package/dist/transaction/rpoRandomCoin.test.js.map +1 -0
- package/dist/transaction/updateGuardian.d.ts +7 -0
- package/dist/transaction/updateGuardian.d.ts.map +1 -0
- package/dist/transaction/{updatePsm.js → updateGuardian.js} +15 -29
- package/dist/transaction/updateGuardian.js.map +1 -0
- package/dist/transaction/updateProcedureThreshold.d.ts +9 -0
- package/dist/transaction/updateProcedureThreshold.d.ts.map +1 -0
- package/dist/transaction/updateProcedureThreshold.js +55 -0
- package/dist/transaction/updateProcedureThreshold.js.map +1 -0
- package/dist/transaction/updateSigners.d.ts.map +1 -1
- package/dist/transaction/updateSigners.js +5 -23
- package/dist/transaction/updateSigners.js.map +1 -1
- package/dist/transaction.d.ts +2 -1
- package/dist/transaction.d.ts.map +1 -1
- package/dist/transaction.js +2 -1
- package/dist/transaction.js.map +1 -1
- package/dist/types/proposal.d.ts +32 -15
- package/dist/types/proposal.d.ts.map +1 -1
- package/dist/types.d.ts +24 -7
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/digest.d.ts +5 -0
- package/dist/utils/digest.d.ts.map +1 -1
- package/dist/utils/digest.js +34 -1
- package/dist/utils/digest.js.map +1 -1
- package/dist/utils/digest.test.d.ts +2 -0
- package/dist/utils/digest.test.d.ts.map +1 -0
- package/dist/utils/digest.test.js +48 -0
- package/dist/utils/digest.test.js.map +1 -0
- package/dist/utils/signature.d.ts +3 -1
- package/dist/utils/signature.d.ts.map +1 -1
- package/dist/utils/signature.js +31 -6
- package/dist/utils/signature.js.map +1 -1
- package/dist/utils/word.test.js +1 -52
- package/dist/utils/word.test.js.map +1 -1
- package/masm/account_components/auth/multisig.masm +13 -0
- package/masm/account_components/auth/multisig_ecdsa.masm +13 -0
- package/masm/account_components/auth/multisig_guardian.masm +17 -0
- package/masm/account_components/auth/multisig_guardian_ecdsa.masm +17 -0
- package/masm/auth/guardian.masm +177 -0
- package/masm/auth/guardian_ecdsa.masm +178 -0
- package/masm/{multisig.masm → auth/multisig.masm} +149 -55
- package/masm/{multisig_ecdsa.masm → auth/multisig_ecdsa.masm} +148 -56
- package/package.json +11 -9
- package/src/account/builder.test.ts +165 -0
- package/src/account/builder.ts +71 -34
- package/src/account/index.ts +1 -1
- package/src/account/masm/account-components/auth.ts +70 -0
- package/src/account/masm/auth.ts +1398 -0
- package/src/account/masm/index.ts +5 -0
- package/src/account/masm.ts +3 -1040
- package/src/account/storage.ts +18 -16
- package/src/client.test.ts +31 -35
- package/src/client.ts +98 -26
- package/src/index.ts +84 -22
- package/src/inspector.test.ts +17 -17
- package/src/inspector.ts +63 -29
- package/src/multisig/proposal/execution.ts +102 -41
- package/src/multisig/proposal/parser.ts +26 -26
- package/src/multisig/signing.ts +4 -4
- package/src/multisig.test.ts +2097 -248
- package/src/multisig.ts +882 -365
- package/src/procedures.ts +50 -26
- package/src/proposal/factory.ts +171 -0
- package/src/proposal/metadata.ts +165 -0
- package/src/proposal/signatures.ts +68 -0
- package/src/signer.ts +2 -0
- package/src/signers/ecdsa.test.ts +80 -0
- package/src/signers/ecdsa.ts +15 -4
- package/src/signers/falcon.test.ts +19 -0
- package/src/signers/falcon.ts +16 -5
- package/src/signers/miden-wallet.test.ts +47 -0
- package/src/signers/miden-wallet.ts +18 -1
- package/src/signers/para.test.ts +57 -0
- package/src/signers/para.ts +26 -7
- package/src/transaction/consumeNotes.ts +1 -0
- package/src/transaction/index.ts +2 -2
- package/src/transaction/options.ts +1 -2
- package/src/transaction/p2id.test.ts +190 -0
- package/src/transaction/p2id.ts +11 -5
- package/src/transaction/rpoRandomCoin.test.ts +64 -0
- package/src/transaction/rpoRandomCoin.ts +24 -0
- package/src/transaction/{updatePsm.ts → updateGuardian.ts} +19 -32
- package/src/transaction/updateProcedureThreshold.ts +97 -0
- package/src/transaction/updateSigners.ts +12 -27
- package/src/transaction.ts +5 -3
- package/src/types/proposal.ts +43 -11
- package/src/types.ts +29 -11
- package/src/utils/digest.test.ts +55 -0
- package/src/utils/digest.ts +51 -1
- package/src/utils/signature.ts +47 -9
- package/src/utils/word.test.ts +1 -55
- package/dist/account.d.ts +0 -104
- package/dist/account.d.ts.map +0 -1
- package/dist/account.js +0 -136
- package/dist/account.js.map +0 -1
- package/dist/builder.d.ts +0 -54
- package/dist/builder.d.ts.map +0 -1
- package/dist/builder.js +0 -78
- package/dist/builder.js.map +0 -1
- package/dist/http.d.ts +0 -64
- package/dist/http.d.ts.map +0 -1
- package/dist/http.js +0 -162
- package/dist/http.js.map +0 -1
- package/dist/keystore.d.ts +0 -65
- package/dist/keystore.d.ts.map +0 -1
- package/dist/keystore.js +0 -121
- package/dist/keystore.js.map +0 -1
- package/dist/miden.d.ts +0 -9
- package/dist/miden.d.ts.map +0 -1
- package/dist/miden.js +0 -26
- package/dist/miden.js.map +0 -1
- package/dist/multisig/metadata.d.ts +0 -18
- package/dist/multisig/metadata.d.ts.map +0 -1
- package/dist/multisig/metadata.js +0 -100
- package/dist/multisig/metadata.js.map +0 -1
- package/dist/multisig/metadata.test.d.ts +0 -2
- package/dist/multisig/metadata.test.d.ts.map +0 -1
- package/dist/multisig/metadata.test.js +0 -323
- package/dist/multisig/metadata.test.js.map +0 -1
- package/dist/signer.test.d.ts +0 -2
- package/dist/signer.test.d.ts.map +0 -1
- package/dist/signer.test.js +0 -117
- package/dist/signer.test.js.map +0 -1
- package/dist/transaction/updatePsm.d.ts +0 -7
- package/dist/transaction/updatePsm.d.ts.map +0 -1
- package/dist/transaction/updatePsm.js.map +0 -1
- package/dist/transport/http.d.ts +0 -64
- package/dist/transport/http.d.ts.map +0 -1
- package/dist/transport/http.js +0 -162
- package/dist/transport/http.js.map +0 -1
- package/dist/transport/index.d.ts +0 -5
- package/dist/transport/index.d.ts.map +0 -1
- package/dist/transport/index.js +0 -5
- package/dist/transport/index.js.map +0 -1
- package/masm/psm.masm +0 -178
- package/masm/psm_ecdsa.masm +0 -179
|
@@ -1,14 +1,11 @@
|
|
|
1
|
-
# Multi-Signature RPO Falcon 512 Authentication
|
|
1
|
+
# Multi-Signature RPO Falcon 512 Authentication Core Library
|
|
2
2
|
#
|
|
3
|
-
# This
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
44
|
+
const PROC_THRESHOLD_ROOTS_SLOT=word("openzeppelin::multisig::procedure_thresholds")
|
|
48
45
|
|
|
49
46
|
# Executed Transaction Flag Constant
|
|
50
|
-
const IS_EXECUTED_FLAG
|
|
47
|
+
const IS_EXECUTED_FLAG=[1, 0, 0, 0]
|
|
51
48
|
|
|
52
49
|
# ERRORS
|
|
53
|
-
const ERR_TX_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
|
|
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
|
|
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
|
-
# => [
|
|
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
|
-
# => [
|
|
84
|
+
# => [[0, 0, 0, is_executed]]
|
|
82
85
|
|
|
83
|
-
|
|
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
|
-
# => [
|
|
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
|
-
# => [
|
|
129
|
+
# => [OLD_MAP_VALUE, i-1, new_num_of_approvers]
|
|
127
130
|
|
|
128
|
-
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
|
-
|
|
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
|
-
|
|
186
|
-
# => [
|
|
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
|
-
# => [
|
|
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
|
-
# => [
|
|
305
|
+
# => [OLD_VALUE, i-1, pad(12)]
|
|
217
306
|
|
|
218
|
-
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
|
-
|
|
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
|
-
# => [
|
|
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.
|
|
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
|
-
#! -
|
|
359
|
-
#! - PSM signature verification fails (if PSM is enabled).
|
|
458
|
+
#! - insufficient number of valid signatures (below threshold).
|
|
360
459
|
#!
|
|
361
|
-
#! Invocation:
|
|
362
|
-
|
|
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
|
-
# => [
|
|
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
|
-
# => [
|
|
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::
|
|
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
|
-
|
|
419
|
-
|
|
420
|
-
# ------ Writing executed transaction MSG to map ------
|
|
421
|
-
# => [TX_SUMMARY_COMMITMENT]
|
|
422
|
-
exec.assert_new_tx
|
|
423
|
-
end
|
|
517
|
+
end
|