multisig 0.1.2__tar.gz → 0.1.3__tar.gz
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.
- {multisig-0.1.2 → multisig-0.1.3}/LICENSE +1 -1
- {multisig-0.1.2 → multisig-0.1.3}/PKG-INFO +28 -15
- {multisig-0.1.2 → multisig-0.1.3}/README.md +20 -12
- {multisig-0.1.2 → multisig-0.1.3}/SECURITY.md +23 -17
- {multisig-0.1.2 → multisig-0.1.3}/pyproject.toml +10 -9
- {multisig-0.1.2 → multisig-0.1.3}/src/multisig_escrow/__init__.py +1 -1
- {multisig-0.1.2 → multisig-0.1.3}/src/multisig_escrow/bitcoin/__init__.py +2 -1
- {multisig-0.1.2 → multisig-0.1.3}/src/multisig_escrow/bitcoin/keys.py +17 -1
- {multisig-0.1.2 → multisig-0.1.3}/src/multisig_escrow/bitcoin/psbt.py +19 -5
- {multisig-0.1.2 → multisig-0.1.3}/src/multisig_escrow/bitcoin/verify.py +8 -3
- {multisig-0.1.2 → multisig-0.1.3}/src/multisig_escrow/core/codec.py +1 -1
- {multisig-0.1.2 → multisig-0.1.3}/src/multisig_escrow/evm/safe.py +17 -0
- {multisig-0.1.2 → multisig-0.1.3}/src/multisig_escrow/evm/verify.py +6 -3
- {multisig-0.1.2 → multisig-0.1.3}/src/multisig_escrow/facade.py +110 -12
- {multisig-0.1.2 → multisig-0.1.3}/src/multisig_escrow/fsm/__init__.py +2 -0
- {multisig-0.1.2 → multisig-0.1.3}/src/multisig_escrow/fsm/events.py +8 -0
- {multisig-0.1.2 → multisig-0.1.3}/src/multisig_escrow/fsm/invariants.py +6 -1
- {multisig-0.1.2 → multisig-0.1.3}/src/multisig_escrow/fsm/machine.py +59 -6
- {multisig-0.1.2 → multisig-0.1.3}/src/multisig_escrow/monero/crypto.py +36 -4
- {multisig-0.1.2 → multisig-0.1.3}/src/multisig_escrow/monero/facade.py +3 -0
- {multisig-0.1.2 → multisig-0.1.3}/src/multisig_escrow/store.py +9 -0
- multisig-0.1.3/tools/monero_oxide_verify/Cargo.lock +590 -0
- multisig-0.1.3/tools/monero_oxide_verify/Cargo.toml +12 -0
- multisig-0.1.3/tools/monero_oxide_verify/README.md +69 -0
- multisig-0.1.3/tools/monero_oxide_verify/src/main.rs +159 -0
- {multisig-0.1.2 → multisig-0.1.3}/.gitignore +0 -0
- {multisig-0.1.2 → multisig-0.1.3}/src/multisig_escrow/authenticity.py +0 -0
- {multisig-0.1.2 → multisig-0.1.3}/src/multisig_escrow/bitcoin/addresses.py +0 -0
- {multisig-0.1.2 → multisig-0.1.3}/src/multisig_escrow/bitcoin/assets.py +0 -0
- {multisig-0.1.2 → multisig-0.1.3}/src/multisig_escrow/bitcoin/descriptor.py +0 -0
- {multisig-0.1.2 → multisig-0.1.3}/src/multisig_escrow/bitcoin/fees.py +0 -0
- {multisig-0.1.2 → multisig-0.1.3}/src/multisig_escrow/bitcoin/finalize.py +0 -0
- {multisig-0.1.2 → multisig-0.1.3}/src/multisig_escrow/bitcoin/funding.py +0 -0
- {multisig-0.1.2 → multisig-0.1.3}/src/multisig_escrow/bitcoin/params.py +0 -0
- {multisig-0.1.2 → multisig-0.1.3}/src/multisig_escrow/bitcoin/policy.py +0 -0
- {multisig-0.1.2 → multisig-0.1.3}/src/multisig_escrow/bitcoin/timelock.py +0 -0
- {multisig-0.1.2 → multisig-0.1.3}/src/multisig_escrow/core/__init__.py +0 -0
- {multisig-0.1.2 → multisig-0.1.3}/src/multisig_escrow/core/amounts.py +0 -0
- {multisig-0.1.2 → multisig-0.1.3}/src/multisig_escrow/core/capabilities.py +0 -0
- {multisig-0.1.2 → multisig-0.1.3}/src/multisig_escrow/core/errors.py +0 -0
- {multisig-0.1.2 → multisig-0.1.3}/src/multisig_escrow/core/ids.py +0 -0
- {multisig-0.1.2 → multisig-0.1.3}/src/multisig_escrow/core/protocol.py +0 -0
- {multisig-0.1.2 → multisig-0.1.3}/src/multisig_escrow/core/roles.py +0 -0
- {multisig-0.1.2 → multisig-0.1.3}/src/multisig_escrow/core/terms.py +0 -0
- {multisig-0.1.2 → multisig-0.1.3}/src/multisig_escrow/core/time.py +0 -0
- {multisig-0.1.2 → multisig-0.1.3}/src/multisig_escrow/core/validation.py +0 -0
- {multisig-0.1.2 → multisig-0.1.3}/src/multisig_escrow/evm/__init__.py +0 -0
- {multisig-0.1.2 → multisig-0.1.3}/src/multisig_escrow/evm/addresses.py +0 -0
- {multisig-0.1.2 → multisig-0.1.3}/src/multisig_escrow/evm/assets.py +0 -0
- {multisig-0.1.2 → multisig-0.1.3}/src/multisig_escrow/evm/calldata.py +0 -0
- {multisig-0.1.2 → multisig-0.1.3}/src/multisig_escrow/evm/deployment.py +0 -0
- {multisig-0.1.2 → multisig-0.1.3}/src/multisig_escrow/evm/eip712.py +0 -0
- {multisig-0.1.2 → multisig-0.1.3}/src/multisig_escrow/evm/funding.py +0 -0
- {multisig-0.1.2 → multisig-0.1.3}/src/multisig_escrow/evm/params.py +0 -0
- {multisig-0.1.2 → multisig-0.1.3}/src/multisig_escrow/evm/payouts.py +0 -0
- {multisig-0.1.2 → multisig-0.1.3}/src/multisig_escrow/evm/plan.py +0 -0
- {multisig-0.1.2 → multisig-0.1.3}/src/multisig_escrow/evm/signatures.py +0 -0
- {multisig-0.1.2 → multisig-0.1.3}/src/multisig_escrow/fsm/plan.py +0 -0
- {multisig-0.1.2 → multisig-0.1.3}/src/multisig_escrow/fsm/record.py +0 -0
- {multisig-0.1.2 → multisig-0.1.3}/src/multisig_escrow/fsm/serialize.py +0 -0
- {multisig-0.1.2 → multisig-0.1.3}/src/multisig_escrow/fsm/states.py +0 -0
- {multisig-0.1.2 → multisig-0.1.3}/src/multisig_escrow/fsm/tokens.py +0 -0
- {multisig-0.1.2 → multisig-0.1.3}/src/multisig_escrow/monero/__init__.py +0 -0
- {multisig-0.1.2 → multisig-0.1.3}/src/multisig_escrow/monero/adapter.py +0 -0
- {multisig-0.1.2 → multisig-0.1.3}/src/multisig_escrow/monero/addresses.py +0 -0
- {multisig-0.1.2 → multisig-0.1.3}/src/multisig_escrow/monero/approval.py +0 -0
- {multisig-0.1.2 → multisig-0.1.3}/src/multisig_escrow/monero/funding.py +0 -0
- {multisig-0.1.2 → multisig-0.1.3}/src/multisig_escrow/monero/key_images.py +0 -0
- {multisig-0.1.2 → multisig-0.1.3}/src/multisig_escrow/monero/keys.py +0 -0
- {multisig-0.1.2 → multisig-0.1.3}/src/multisig_escrow/monero/manifest.py +0 -0
- {multisig-0.1.2 → multisig-0.1.3}/src/multisig_escrow/monero/multisig.py +0 -0
- {multisig-0.1.2 → multisig-0.1.3}/src/multisig_escrow/monero/params.py +0 -0
- {multisig-0.1.2 → multisig-0.1.3}/src/multisig_escrow/monero/refund.py +0 -0
- {multisig-0.1.2 → multisig-0.1.3}/src/multisig_escrow/monero/settlement.py +0 -0
- {multisig-0.1.2 → multisig-0.1.3}/src/multisig_escrow/monero/terms.py +0 -0
- {multisig-0.1.2 → multisig-0.1.3}/src/multisig_escrow/py.typed +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
MIT License
|
|
2
2
|
|
|
3
|
-
Copyright (c) 2026
|
|
3
|
+
Copyright (c) 2026 Ivan Klydz and multisig contributors
|
|
4
4
|
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
6
|
of this software and associated documentation files (the "Software"), to deal
|
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: multisig
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.3
|
|
4
4
|
Summary: Offline multisig escrow for Bitcoin, EVM, and Monero
|
|
5
|
-
|
|
5
|
+
Project-URL: Homepage, https://multisig.zip/
|
|
6
|
+
Project-URL: Documentation, https://multisig.zip/
|
|
7
|
+
Project-URL: Repository, https://github.com/klydz/multisig
|
|
8
|
+
Project-URL: Issues, https://github.com/klydz/multisig/issues
|
|
9
|
+
Project-URL: Changelog, https://github.com/klydz/multisig/releases
|
|
10
|
+
Author: Ivan Klydz
|
|
6
11
|
License: MIT License
|
|
7
12
|
|
|
8
|
-
Copyright (c) 2026
|
|
13
|
+
Copyright (c) 2026 Ivan Klydz and multisig contributors
|
|
9
14
|
|
|
10
15
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
11
16
|
of this software and associated documentation files (the "Software"), to deal
|
|
@@ -79,14 +84,14 @@ Description-Content-Type: text/markdown
|
|
|
79
84
|
Offline multisig escrow for Bitcoin, EVM Safe accounts, and Monero.
|
|
80
85
|
|
|
81
86
|
`multisig` builds and verifies funding targets, settlement plans, PSBTs, Safe
|
|
82
|
-
calldata, Monero settlement plans, and
|
|
83
|
-
|
|
84
|
-
|
|
87
|
+
calldata, Monero settlement plans, and approval tokens without connecting to a
|
|
88
|
+
node, RPC endpoint, or wallet. It never accepts private keys, private view keys,
|
|
89
|
+
wallet files, seed phrases, or multisig secret shares.
|
|
85
90
|
|
|
86
91
|
**Distribution:** `multisig`
|
|
87
92
|
**Python import:** `multisig_escrow`
|
|
88
93
|
**Documentation:** https://multisig.zip/
|
|
89
|
-
**Version:** 0.1.
|
|
94
|
+
**Version:** 0.1.3
|
|
90
95
|
|
|
91
96
|
## Install
|
|
92
97
|
|
|
@@ -104,16 +109,23 @@ support is optional and imported lazily.
|
|
|
104
109
|
|
|
105
110
|
Only these coins and chains are supported for now.
|
|
106
111
|
|
|
107
|
-
**Bitcoin:** BTC on P2WSH sortedmulti
|
|
112
|
+
**Bitcoin:** BTC on P2WSH sortedmulti with an optional CSV refund. The descriptor helpers also support P2SH P2WSH for lower level integrations.
|
|
108
113
|
|
|
109
|
-
**EVM:** ETH and
|
|
114
|
+
**EVM:** ETH and application selected ERC20 on supported EVM chains with Safe v1.3.0 or v1.4.1.
|
|
110
115
|
|
|
111
116
|
**Monero:** XMR with experimental CLSAG 2 of 3 and optional pre signed `unlock_time` refund.
|
|
112
117
|
|
|
113
118
|
Additional coins and chains will be added in future releases.
|
|
114
119
|
|
|
120
|
+
## Role policy
|
|
121
|
+
|
|
122
|
+
Normal release and refund proposals require the configured quorum. An arbiter approval is accepted only after a dispute is opened.
|
|
123
|
+
|
|
115
124
|
## Quick start
|
|
116
125
|
|
|
126
|
+
The example assumes your application has already built `terms`, funding
|
|
127
|
+
evidence, and settlement parameters.
|
|
128
|
+
|
|
117
129
|
```python
|
|
118
130
|
from multisig_escrow import BitcoinEscrow, MemoryStore
|
|
119
131
|
|
|
@@ -127,10 +139,10 @@ settlement = escrow.finalize()
|
|
|
127
139
|
```
|
|
128
140
|
|
|
129
141
|
EVM flows use `EvmEscrow` with `SafeFundingEvidence`, `EvmReleaseParams`, or
|
|
130
|
-
`EvmRefundParams`. Monero flows use `MoneroEscrow`
|
|
131
|
-
`MoneroFundingEvidence`, `MoneroReleaseParams`, or
|
|
132
|
-
three facades share the same FSM, optimistic store
|
|
133
|
-
rules, and broadcast and confirmation checks.
|
|
142
|
+
`EvmRefundParams`. Monero flows use `MoneroEscrow` from
|
|
143
|
+
`multisig_escrow.monero` with `MoneroFundingEvidence`, `MoneroReleaseParams`, or
|
|
144
|
+
`MoneroRefundParams`. All three facades share the same FSM, optimistic store
|
|
145
|
+
contract, approval token rules, and broadcast and confirmation checks.
|
|
134
146
|
|
|
135
147
|
For Monero, funding requires a `MoneroFundingVerifier`, finalization requires a
|
|
136
148
|
`MoneroSettlementVerifier`, and CLSAG verification uses a pinned external
|
|
@@ -188,8 +200,9 @@ For security reports, read [SECURITY.md](SECURITY.md) before opening a public is
|
|
|
188
200
|
|
|
189
201
|
**R24 remains Critical.** Monero CLSAG, RingCT, multisig, parser behavior,
|
|
190
202
|
wallet interoperability, and the native verifier boundary remain high risk.
|
|
191
|
-
Monero is experimental and must remain testnet and value capped. Use
|
|
192
|
-
funds only after completing the operator checklist and explicitly
|
|
203
|
+
Monero is experimental and must remain testnet and value capped. Use Monero
|
|
204
|
+
with real funds only after completing the operator checklist and explicitly
|
|
205
|
+
accepting R24.
|
|
193
206
|
|
|
194
207
|
Read [SECURITY.md](SECURITY.md) before deploying.
|
|
195
208
|
|
|
@@ -12,14 +12,14 @@
|
|
|
12
12
|
Offline multisig escrow for Bitcoin, EVM Safe accounts, and Monero.
|
|
13
13
|
|
|
14
14
|
`multisig` builds and verifies funding targets, settlement plans, PSBTs, Safe
|
|
15
|
-
calldata, Monero settlement plans, and
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
calldata, Monero settlement plans, and approval tokens without connecting to a
|
|
16
|
+
node, RPC endpoint, or wallet. It never accepts private keys, private view keys,
|
|
17
|
+
wallet files, seed phrases, or multisig secret shares.
|
|
18
18
|
|
|
19
19
|
**Distribution:** `multisig`
|
|
20
20
|
**Python import:** `multisig_escrow`
|
|
21
21
|
**Documentation:** https://multisig.zip/
|
|
22
|
-
**Version:** 0.1.
|
|
22
|
+
**Version:** 0.1.3
|
|
23
23
|
|
|
24
24
|
## Install
|
|
25
25
|
|
|
@@ -37,16 +37,23 @@ support is optional and imported lazily.
|
|
|
37
37
|
|
|
38
38
|
Only these coins and chains are supported for now.
|
|
39
39
|
|
|
40
|
-
**Bitcoin:** BTC on P2WSH sortedmulti
|
|
40
|
+
**Bitcoin:** BTC on P2WSH sortedmulti with an optional CSV refund. The descriptor helpers also support P2SH P2WSH for lower level integrations.
|
|
41
41
|
|
|
42
|
-
**EVM:** ETH and
|
|
42
|
+
**EVM:** ETH and application selected ERC20 on supported EVM chains with Safe v1.3.0 or v1.4.1.
|
|
43
43
|
|
|
44
44
|
**Monero:** XMR with experimental CLSAG 2 of 3 and optional pre signed `unlock_time` refund.
|
|
45
45
|
|
|
46
46
|
Additional coins and chains will be added in future releases.
|
|
47
47
|
|
|
48
|
+
## Role policy
|
|
49
|
+
|
|
50
|
+
Normal release and refund proposals require the configured quorum. An arbiter approval is accepted only after a dispute is opened.
|
|
51
|
+
|
|
48
52
|
## Quick start
|
|
49
53
|
|
|
54
|
+
The example assumes your application has already built `terms`, funding
|
|
55
|
+
evidence, and settlement parameters.
|
|
56
|
+
|
|
50
57
|
```python
|
|
51
58
|
from multisig_escrow import BitcoinEscrow, MemoryStore
|
|
52
59
|
|
|
@@ -60,10 +67,10 @@ settlement = escrow.finalize()
|
|
|
60
67
|
```
|
|
61
68
|
|
|
62
69
|
EVM flows use `EvmEscrow` with `SafeFundingEvidence`, `EvmReleaseParams`, or
|
|
63
|
-
`EvmRefundParams`. Monero flows use `MoneroEscrow`
|
|
64
|
-
`MoneroFundingEvidence`, `MoneroReleaseParams`, or
|
|
65
|
-
three facades share the same FSM, optimistic store
|
|
66
|
-
rules, and broadcast and confirmation checks.
|
|
70
|
+
`EvmRefundParams`. Monero flows use `MoneroEscrow` from
|
|
71
|
+
`multisig_escrow.monero` with `MoneroFundingEvidence`, `MoneroReleaseParams`, or
|
|
72
|
+
`MoneroRefundParams`. All three facades share the same FSM, optimistic store
|
|
73
|
+
contract, approval token rules, and broadcast and confirmation checks.
|
|
67
74
|
|
|
68
75
|
For Monero, funding requires a `MoneroFundingVerifier`, finalization requires a
|
|
69
76
|
`MoneroSettlementVerifier`, and CLSAG verification uses a pinned external
|
|
@@ -121,8 +128,9 @@ For security reports, read [SECURITY.md](SECURITY.md) before opening a public is
|
|
|
121
128
|
|
|
122
129
|
**R24 remains Critical.** Monero CLSAG, RingCT, multisig, parser behavior,
|
|
123
130
|
wallet interoperability, and the native verifier boundary remain high risk.
|
|
124
|
-
Monero is experimental and must remain testnet and value capped. Use
|
|
125
|
-
funds only after completing the operator checklist and explicitly
|
|
131
|
+
Monero is experimental and must remain testnet and value capped. Use Monero
|
|
132
|
+
with real funds only after completing the operator checklist and explicitly
|
|
133
|
+
accepting R24.
|
|
126
134
|
|
|
127
135
|
Read [SECURITY.md](SECURITY.md) before deploying.
|
|
128
136
|
|
|
@@ -2,14 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
## Status
|
|
4
4
|
|
|
5
|
-
**Version:** 0.1.
|
|
6
|
-
**R24:** Critical
|
|
5
|
+
**Version:** 0.1.3
|
|
6
|
+
**R24:** Critical
|
|
7
7
|
|
|
8
8
|
**R24 remains Critical.** Monero CLSAG, RingCT, multisig, parser behavior,
|
|
9
9
|
wallet interoperability, and the native verifier boundary remain high risk.
|
|
10
|
-
Monero is experimental and must remain testnet and value capped.
|
|
11
|
-
library with real funds only after completing the operator checklist and
|
|
12
|
-
explicitly accepting R24.
|
|
10
|
+
Monero is experimental and must remain testnet and value capped.
|
|
13
11
|
|
|
14
12
|
## Scope
|
|
15
13
|
|
|
@@ -23,6 +21,8 @@ Only these coins and chains are supported for now.
|
|
|
23
21
|
|
|
24
22
|
Additional coins and chains will be added in future releases. Other chains are out of scope.
|
|
25
23
|
|
|
24
|
+
An arbiter approval is accepted only after a dispute is opened. ERC20 assets must be present in the chain token allowlist.
|
|
25
|
+
|
|
26
26
|
## Operator checklist
|
|
27
27
|
|
|
28
28
|
Every item is mandatory. If any item cannot be checked and recorded, do not
|
|
@@ -85,20 +85,19 @@ Monero requires trusted external components.
|
|
|
85
85
|
**Native verifier:** The Monero Oxide 0.1.0 verifier is external and is not bundled in the wheel.
|
|
86
86
|
|
|
87
87
|
Build the native verifier from pinned source, verify its hash, ship it through
|
|
88
|
-
a signed release channel, and select it with `MONERO_OXIDE_VERIFY_BIN
|
|
89
|
-
`
|
|
90
|
-
closed.
|
|
88
|
+
a signed release channel, and select it with `MONERO_OXIDE_VERIFY_BIN`,
|
|
89
|
+
`MONERO_OXIDE_VERIFY_SHA256`, or `MoneroOxideVerifier(path, expected_sha256)`.
|
|
90
|
+
Missing, failing, or malformed verifier output fails closed.
|
|
91
91
|
|
|
92
|
-
The
|
|
93
|
-
|
|
94
|
-
`MoneroSettlementVerifier`. No private view key is accepted by the library.
|
|
92
|
+
The settlement verifier must attest the payout address and amount because
|
|
93
|
+
RingCT hides them. No private view key is accepted by the library.
|
|
95
94
|
|
|
96
95
|
## Evidence
|
|
97
96
|
|
|
98
|
-
All chain evidence is
|
|
99
|
-
signatures, payload binding, and declared freshness
|
|
100
|
-
|
|
101
|
-
|
|
97
|
+
All chain evidence is supplied by the application. The library verifies
|
|
98
|
+
structure, signatures, payload binding, and declared freshness. Use a trusted
|
|
99
|
+
node, independent verifier, or chain proof for funding, maturity, broadcast, and
|
|
100
|
+
confirmation evidence.
|
|
102
101
|
|
|
103
102
|
## Contributions
|
|
104
103
|
|
|
@@ -107,5 +106,12 @@ Contributions are very much appreciated. If you find an issue, a vulnerability,
|
|
|
107
106
|
## Reporting
|
|
108
107
|
|
|
109
108
|
Report suspected vulnerabilities privately to the maintainers. Do not open a
|
|
110
|
-
public issue for a report that may affect funds.
|
|
111
|
-
|
|
109
|
+
public issue for a report that may affect funds.
|
|
110
|
+
|
|
111
|
+
Use GitHub private vulnerability reporting:
|
|
112
|
+
|
|
113
|
+
https://github.com/klydz/multisig/security/advisories/new
|
|
114
|
+
|
|
115
|
+
Include the affected version, chain, reproduction steps or vector, impact, and
|
|
116
|
+
any proposed mitigation. This project is maintained by one developer. Reports
|
|
117
|
+
are handled on a best effort basis, typically within 7 days.
|
|
@@ -4,12 +4,12 @@ build-backend = "hatchling.build"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "multisig"
|
|
7
|
-
version = "0.1.
|
|
7
|
+
version = "0.1.3"
|
|
8
8
|
description = "Offline multisig escrow for Bitcoin, EVM, and Monero"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
requires-python = ">=3.11"
|
|
11
11
|
license = { file = "LICENSE" }
|
|
12
|
-
authors = [{ name = "
|
|
12
|
+
authors = [{ name = "Ivan Klydz" }]
|
|
13
13
|
keywords = ["escrow", "multisig", "bitcoin", "ethereum", "monero"]
|
|
14
14
|
classifiers = [
|
|
15
15
|
"Development Status :: 3 - Alpha",
|
|
@@ -23,6 +23,13 @@ classifiers = [
|
|
|
23
23
|
]
|
|
24
24
|
dependencies = []
|
|
25
25
|
|
|
26
|
+
[project.urls]
|
|
27
|
+
Homepage = "https://multisig.zip/"
|
|
28
|
+
Documentation = "https://multisig.zip/"
|
|
29
|
+
Repository = "https://github.com/klydz/multisig"
|
|
30
|
+
Issues = "https://github.com/klydz/multisig/issues"
|
|
31
|
+
Changelog = "https://github.com/klydz/multisig/releases"
|
|
32
|
+
|
|
26
33
|
[project.optional-dependencies]
|
|
27
34
|
bitcoin = [
|
|
28
35
|
"embit>=0.8,<0.9",
|
|
@@ -65,9 +72,6 @@ exclude = [
|
|
|
65
72
|
"tools",
|
|
66
73
|
"examples",
|
|
67
74
|
"docs*.md",
|
|
68
|
-
"AUDIT*.md",
|
|
69
|
-
"EXTERNAL_AUDIT_BRIEF.md",
|
|
70
|
-
"STRESS_TEST_REPORT.md",
|
|
71
75
|
"**/target",
|
|
72
76
|
"**/__pycache__",
|
|
73
77
|
"**/*.pyc",
|
|
@@ -87,6 +91,7 @@ include = [
|
|
|
87
91
|
"SECURITY.md",
|
|
88
92
|
"LICENSE",
|
|
89
93
|
"pyproject.toml",
|
|
94
|
+
"tools/monero_oxide_verify",
|
|
90
95
|
]
|
|
91
96
|
exclude = [
|
|
92
97
|
".venv",
|
|
@@ -95,12 +100,8 @@ exclude = [
|
|
|
95
100
|
"**/.gitignore",
|
|
96
101
|
"dist",
|
|
97
102
|
"tests",
|
|
98
|
-
"tools",
|
|
99
103
|
"examples",
|
|
100
104
|
"docs*.md",
|
|
101
|
-
"AUDIT*.md",
|
|
102
|
-
"EXTERNAL_AUDIT_BRIEF.md",
|
|
103
|
-
"STRESS_TEST_REPORT.md",
|
|
104
105
|
"**/__pycache__",
|
|
105
106
|
"**/*.pyc",
|
|
106
107
|
"**/target",
|
|
@@ -42,7 +42,7 @@ from .funding import (
|
|
|
42
42
|
BtcUtxo,
|
|
43
43
|
validate_funding,
|
|
44
44
|
)
|
|
45
|
-
from .keys import BitcoinChain, BitcoinNetwork, BtcSigner, network_data
|
|
45
|
+
from .keys import BitcoinChain, BitcoinNetwork, BtcSigner, escrow_derivation_index, network_data
|
|
46
46
|
from .params import BtcRefundParams, BtcReleaseParams, PsbtApproval, PsbtSigner
|
|
47
47
|
from .policy import BitcoinPolicy
|
|
48
48
|
from .psbt import BitcoinSettlementPlan, build_settlement_psbt
|
|
@@ -76,6 +76,7 @@ __all__ = [
|
|
|
76
76
|
"BtcRefundParams",
|
|
77
77
|
"BtcReleaseParams",
|
|
78
78
|
"BtcSigner",
|
|
79
|
+
"escrow_derivation_index",
|
|
79
80
|
"BtcUtxo",
|
|
80
81
|
"CsvDelay",
|
|
81
82
|
"CsvUnit",
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
|
|
3
|
+
import hashlib
|
|
3
4
|
from dataclasses import dataclass
|
|
4
5
|
from enum import StrEnum
|
|
5
6
|
from typing import Any, cast
|
|
6
7
|
|
|
7
8
|
from ..core.capabilities import ChainFamily
|
|
8
9
|
from ..core.errors import DependencyError, NetworkMismatchError, ValidationError
|
|
9
|
-
from ..core.ids import SignerId
|
|
10
|
+
from ..core.ids import EscrowId, SignerId
|
|
10
11
|
from ..core.validation import require_bytes, require_str
|
|
11
12
|
|
|
12
13
|
try:
|
|
@@ -17,6 +18,20 @@ except ImportError as exc:
|
|
|
17
18
|
|
|
18
19
|
_HARDENED = 1 << 31
|
|
19
20
|
_MAX_DEPTH = 255
|
|
21
|
+
_ESCROW_INDEX_DOMAIN = b"multisig.bitcoin.escrow-index.v1"
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
def escrow_derivation_index(escrow_id: EscrowId) -> int:
|
|
25
|
+
"""Return the deterministic non-hardened child index for an escrow.
|
|
26
|
+
|
|
27
|
+
The index is mixed into every signer derivation path so that two escrows
|
|
28
|
+
with identical signer keys do not share a funding address.
|
|
29
|
+
"""
|
|
30
|
+
|
|
31
|
+
if not isinstance(escrow_id, EscrowId):
|
|
32
|
+
raise ValidationError("escrow id")
|
|
33
|
+
digest = hashlib.sha256(_ESCROW_INDEX_DOMAIN + escrow_id.value).digest()
|
|
34
|
+
return int.from_bytes(digest[:4], "big") & 0x7FFFFFFF
|
|
20
35
|
|
|
21
36
|
|
|
22
37
|
class BitcoinNetwork(StrEnum):
|
|
@@ -205,5 +220,6 @@ __all__ = [
|
|
|
205
220
|
"BitcoinChain",
|
|
206
221
|
"BitcoinNetwork",
|
|
207
222
|
"BtcSigner",
|
|
223
|
+
"escrow_derivation_index",
|
|
208
224
|
"network_data",
|
|
209
225
|
]
|
|
@@ -34,7 +34,7 @@ try:
|
|
|
34
34
|
except ImportError as exc:
|
|
35
35
|
raise DependencyError("embit") from exc
|
|
36
36
|
|
|
37
|
-
|
|
37
|
+
_RBF = 0xFFFFFFFD
|
|
38
38
|
_MAX_INPUTS = 100
|
|
39
39
|
|
|
40
40
|
|
|
@@ -54,6 +54,7 @@ class BitcoinSettlementPlan:
|
|
|
54
54
|
fee_policy: FeePolicy | None = None
|
|
55
55
|
required_approvers: frozenset[SignerId] | None = None
|
|
56
56
|
approver_threshold: int | None = None
|
|
57
|
+
change_payout: BtcPayout | None = None
|
|
57
58
|
|
|
58
59
|
@property
|
|
59
60
|
def psbt_base64(self) -> str:
|
|
@@ -97,6 +98,9 @@ class BitcoinSettlementPlan:
|
|
|
97
98
|
"amount": self.amount,
|
|
98
99
|
"fee": self.fee,
|
|
99
100
|
"change": self.change,
|
|
101
|
+
"change_payout": (
|
|
102
|
+
None if self.change_payout is None else self.change_payout.to_canonical()
|
|
103
|
+
),
|
|
100
104
|
"utxos": [utxo.to_canonical() for utxo in self.utxos],
|
|
101
105
|
"tx": cast(bytes, self.tx.serialize()).hex(),
|
|
102
106
|
"psbt": self.psbt_base64,
|
|
@@ -131,6 +135,7 @@ def build_settlement_psbt(
|
|
|
131
135
|
path: SettlementPath = SettlementPath.PRIMARY,
|
|
132
136
|
maturity: TimelockMaturity | None = None,
|
|
133
137
|
fee_policy: FeePolicy | None = None,
|
|
138
|
+
change_payout: BtcPayout | None = None,
|
|
134
139
|
) -> BitcoinSettlementPlan:
|
|
135
140
|
if not isinstance(policy, BitcoinPolicy):
|
|
136
141
|
raise ValidationError("policy")
|
|
@@ -144,6 +149,11 @@ def build_settlement_psbt(
|
|
|
144
149
|
raise NetworkMismatchError("payout network")
|
|
145
150
|
if fee_policy is not None and not isinstance(fee_policy, FeePolicy):
|
|
146
151
|
raise ValidationError("fee policy")
|
|
152
|
+
if change_payout is not None:
|
|
153
|
+
if not isinstance(change_payout, BtcPayout):
|
|
154
|
+
raise ValidationError("change payout")
|
|
155
|
+
if change_payout.network != policy.network:
|
|
156
|
+
raise NetworkMismatchError("change payout network")
|
|
147
157
|
active_fee_policy = fee_policy if fee_policy is not None else policy.fee_policy
|
|
148
158
|
value = require_int(amount, "amount", 1, (1 << 64) - 1)
|
|
149
159
|
fee_sats = require_int(fee, "fee", 0, (1 << 64) - 1)
|
|
@@ -167,7 +177,7 @@ def build_settlement_psbt(
|
|
|
167
177
|
raise SettlementError("dust output")
|
|
168
178
|
if total < value + fee_sats:
|
|
169
179
|
raise SettlementError("insufficient funds")
|
|
170
|
-
sequence =
|
|
180
|
+
sequence = _RBF
|
|
171
181
|
if path is SettlementPath.TIMELOCK:
|
|
172
182
|
timelock = policy.timelock
|
|
173
183
|
if timelock is None:
|
|
@@ -185,9 +195,12 @@ def build_settlement_psbt(
|
|
|
185
195
|
elif maturity is not None:
|
|
186
196
|
raise TimelockError("maturity path")
|
|
187
197
|
rate = dust_rate(active_fee_policy)
|
|
198
|
+
change_script = (
|
|
199
|
+
escrow_script if change_payout is None else change_payout.script_pubkey
|
|
200
|
+
)
|
|
188
201
|
raw_change = total - value - fee_sats
|
|
189
202
|
output_scripts: tuple[bytes, ...]
|
|
190
|
-
if 0 < raw_change < dust_threshold(
|
|
203
|
+
if 0 < raw_change < dust_threshold(change_script, rate):
|
|
191
204
|
effective_fee = fee_sats + raw_change
|
|
192
205
|
change = 0
|
|
193
206
|
output_scripts = (payout.script_pubkey,)
|
|
@@ -195,14 +208,14 @@ def build_settlement_psbt(
|
|
|
195
208
|
effective_fee = fee_sats
|
|
196
209
|
change = raw_change
|
|
197
210
|
output_scripts = (
|
|
198
|
-
(payout.script_pubkey,
|
|
211
|
+
(payout.script_pubkey, change_script) if change else (payout.script_pubkey,)
|
|
199
212
|
)
|
|
200
213
|
if active_fee_policy is not None:
|
|
201
214
|
bounds = vsize_bounds(policy, len(items), output_scripts, path)
|
|
202
215
|
validate_fee(active_fee_policy, effective_fee, bounds)
|
|
203
216
|
vout = [TransactionOutput(value, Script(payout.script_pubkey))]
|
|
204
217
|
if change:
|
|
205
|
-
vout.append(TransactionOutput(change, Script(
|
|
218
|
+
vout.append(TransactionOutput(change, Script(change_script)))
|
|
206
219
|
vin = [
|
|
207
220
|
TransactionInput(utxo.txid[::-1], utxo.output_index, sequence=sequence) for utxo in items
|
|
208
221
|
]
|
|
@@ -235,6 +248,7 @@ def build_settlement_psbt(
|
|
|
235
248
|
path=path,
|
|
236
249
|
maturity=maturity,
|
|
237
250
|
fee_policy=active_fee_policy,
|
|
251
|
+
change_payout=change_payout,
|
|
238
252
|
)
|
|
239
253
|
|
|
240
254
|
|
|
@@ -25,7 +25,7 @@ except ImportError as exc:
|
|
|
25
25
|
_CURVE_N = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141
|
|
26
26
|
_HALF_N = _CURVE_N // 2
|
|
27
27
|
_SIGHASH_ALL = 1
|
|
28
|
-
|
|
28
|
+
_RBF = 0xFFFFFFFD
|
|
29
29
|
_MAX_SIG = 72
|
|
30
30
|
_DUST_RELAY_RATE = 3
|
|
31
31
|
_WITNESS_SPEND_SIZE = 67
|
|
@@ -239,7 +239,12 @@ def expected_outputs(plan: BitcoinSettlementPlan) -> tuple[tuple[int, bytes, str
|
|
|
239
239
|
raise VerificationError("change")
|
|
240
240
|
outputs: list[tuple[int, bytes, str]] = [(plan.amount, plan.payout.script_pubkey, "payout")]
|
|
241
241
|
if change:
|
|
242
|
-
|
|
242
|
+
change_script = (
|
|
243
|
+
reconstruct_script_pubkey(plan.policy)
|
|
244
|
+
if plan.change_payout is None
|
|
245
|
+
else plan.change_payout.script_pubkey
|
|
246
|
+
)
|
|
247
|
+
outputs.append((change, change_script, "change"))
|
|
243
248
|
return tuple(outputs)
|
|
244
249
|
|
|
245
250
|
|
|
@@ -405,7 +410,7 @@ def _check_timelock_maturity(plan: BitcoinSettlementPlan) -> None:
|
|
|
405
410
|
def _expected_sequence(plan: BitcoinSettlementPlan) -> int:
|
|
406
411
|
if plan.path is SettlementPath.TIMELOCK:
|
|
407
412
|
return _timelock_sequence(plan.policy)
|
|
408
|
-
return
|
|
413
|
+
return _RBF
|
|
409
414
|
|
|
410
415
|
|
|
411
416
|
def _signature_requirements(plan: BitcoinSettlementPlan) -> tuple[set[bytes], int]:
|
|
@@ -107,7 +107,7 @@ def strict_loads(value: str | bytes) -> object:
|
|
|
107
107
|
)
|
|
108
108
|
except CodecError:
|
|
109
109
|
raise
|
|
110
|
-
except
|
|
110
|
+
except (ValueError, RecursionError) as exc:
|
|
111
111
|
raise CodecError("json parse") from exc
|
|
112
112
|
require_json_depth(parsed)
|
|
113
113
|
return parsed
|
|
@@ -204,6 +204,7 @@ class EvmChain:
|
|
|
204
204
|
chain_id: int
|
|
205
205
|
name: str
|
|
206
206
|
safe: SafeAccount
|
|
207
|
+
token_allowlist: frozenset[EvmAddress] | None = None
|
|
207
208
|
|
|
208
209
|
def __post_init__(self) -> None:
|
|
209
210
|
chain_id = require_int(self.chain_id, "chain id", 1, MAX_UINT256)
|
|
@@ -213,6 +214,17 @@ class EvmChain:
|
|
|
213
214
|
self.safe.validate()
|
|
214
215
|
if chain_id != self.safe.chain_id:
|
|
215
216
|
raise ValidationError("chain safe")
|
|
217
|
+
allowlist = self.token_allowlist
|
|
218
|
+
if allowlist is not None:
|
|
219
|
+
if not isinstance(allowlist, frozenset):
|
|
220
|
+
try:
|
|
221
|
+
allowlist = frozenset(allowlist)
|
|
222
|
+
except TypeError as exc:
|
|
223
|
+
raise ValidationError("token allowlist") from exc
|
|
224
|
+
for token in allowlist:
|
|
225
|
+
if not isinstance(token, EvmAddress) or token.is_zero():
|
|
226
|
+
raise ValidationError("token allowlist")
|
|
227
|
+
object.__setattr__(self, "token_allowlist", allowlist)
|
|
216
228
|
object.__setattr__(self, "chain_id", chain_id)
|
|
217
229
|
object.__setattr__(self, "name", name)
|
|
218
230
|
|
|
@@ -230,6 +242,11 @@ class EvmChain:
|
|
|
230
242
|
"chain_id": self.chain_id,
|
|
231
243
|
"name": self.name,
|
|
232
244
|
"safe": self.safe.to_canonical(),
|
|
245
|
+
"token_allowlist": (
|
|
246
|
+
None
|
|
247
|
+
if self.token_allowlist is None
|
|
248
|
+
else sorted(token.value for token in self.token_allowlist)
|
|
249
|
+
),
|
|
233
250
|
}
|
|
234
251
|
|
|
235
252
|
|
|
@@ -73,6 +73,7 @@ _TRANSFER_TYPES = ("address", "uint256")
|
|
|
73
73
|
_SECP256K1_N = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141
|
|
74
74
|
_SECP256K1_HALF_N = _SECP256K1_N // 2
|
|
75
75
|
_SIGNATURE_LENGTH = 65
|
|
76
|
+
_MAX_RLP_DEPTH = 64
|
|
76
77
|
_DATA_MAX = 64 * 1024
|
|
77
78
|
_SIGNATURES_MAX = _SIGNATURE_LENGTH * 1000
|
|
78
79
|
_CALLDATA_MAX = _DATA_MAX + _SIGNATURES_MAX + 4096
|
|
@@ -568,7 +569,9 @@ def verify_safe_digest(plan: SafeTransferPlan, digest: bytes) -> None:
|
|
|
568
569
|
_compare_digest(_expected_digest(expected), value)
|
|
569
570
|
|
|
570
571
|
|
|
571
|
-
def _rlp_item(raw: bytes, offset: int) -> tuple[object, int]:
|
|
572
|
+
def _rlp_item(raw: bytes, offset: int, depth: int = 0) -> tuple[object, int]:
|
|
573
|
+
if depth > _MAX_RLP_DEPTH:
|
|
574
|
+
raise VerificationError("rlp depth")
|
|
572
575
|
if offset >= len(raw):
|
|
573
576
|
raise VerificationError("rlp input")
|
|
574
577
|
prefix = raw[offset]
|
|
@@ -604,7 +607,7 @@ def _rlp_item(raw: bytes, offset: int) -> tuple[object, int]:
|
|
|
604
607
|
items = []
|
|
605
608
|
cursor = start
|
|
606
609
|
while cursor < end:
|
|
607
|
-
item, cursor = _rlp_item(raw, cursor)
|
|
610
|
+
item, cursor = _rlp_item(raw, cursor, depth + 1)
|
|
608
611
|
items.append(item)
|
|
609
612
|
if cursor != end:
|
|
610
613
|
raise VerificationError("rlp list")
|
|
@@ -624,7 +627,7 @@ def _rlp_item(raw: bytes, offset: int) -> tuple[object, int]:
|
|
|
624
627
|
items = []
|
|
625
628
|
cursor = start
|
|
626
629
|
while cursor < end:
|
|
627
|
-
item, cursor = _rlp_item(raw, cursor)
|
|
630
|
+
item, cursor = _rlp_item(raw, cursor, depth + 1)
|
|
628
631
|
items.append(item)
|
|
629
632
|
if cursor != end:
|
|
630
633
|
raise VerificationError("rlp list")
|