Skip to content

Commit 889342b

Browse files
committed
DIP: aj-hd-mixing
1 parent 3563d0a commit 889342b

1 file changed

Lines changed: 152 additions & 0 deletions

File tree

dip-aj-hd-mixing.md

Lines changed: 152 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,152 @@
1+
<pre>
2+
DIP: aj-hd-mixing
3+
Title: Coin Mix Tracking in HD Wallets via HDPath
4+
Authors: coolaj86
5+
Special-Thanks: Rion Gull
6+
Comments-Summary: No comments yet.
7+
Status: Draft
8+
Type: Standard
9+
Created: 2023-06-28
10+
License: CC0-1.0
11+
</pre>
12+
13+
## Table of Contents
14+
15+
- [Table of Contents](#table-of-contents)
16+
- [Abstract](#abstract)
17+
- [Prior Art](#prior-art)
18+
- [Motivation](#motivation)
19+
- [Specification](#specification)
20+
- [Coin Mix Tracking via HDPath](#coin-mix-tracking-via-hdpath)
21+
- [Other Considerations](#other-considerations)
22+
- [Copyright](#copyright)
23+
24+
## Abstract
25+
26+
This DIP proposes to track "coin mixing" in HD Wallets using the HDPath.
27+
28+
keywords: CoinJoin PrivateSend mobile coin mixing mix hdpath mixpath
29+
30+
## Prior Art
31+
32+
- [Multi-Account Hierarchy for Deterministic Wallets](https://github.com/bitcoin/bips/blob/master/bip-0044.mediawiki)
33+
34+
## Motivation
35+
36+
Currently there's no strategy for tracking "coin mixing" on mobile devices, or
37+
sharing "coin mixing" enabled wallet accounts between devices - such as in the
38+
case where a second device should do the mixing because the mobile device cannot
39+
reasonably do so.
40+
41+
Preferably we want a strategy that doesn't require syncing indexes, especially
42+
not in one-off formats.
43+
44+
This solves all of those problems with minimal complexity.
45+
46+
This won't break any existing wallets - those that are unaware of mixing will
47+
still be aware - and will enable shared data via an offline indexing scheme
48+
protocol rather than requiring a new or custom format or online synced data.
49+
50+
## Specification
51+
52+
[lextx]: https://github.com/bitcoin/bips/blob/master/bip-0069.mediawiki
53+
54+
[Lexicographical Indexing of Transaction Inputs and Outputs][lextx] MUST be used
55+
for all mixing transactions.
56+
57+
The _Usage_ component (at index 4) of the HDPath is designated for tracking coin
58+
mixes for mixed accounts.
59+
60+
HDPaths are used in this format:
61+
62+
```text
63+
m/<bip44>'/<coin>'/<account>'/<mixcount>/<index>
64+
m/44'/5'/0'/0/0
65+
```
66+
67+
Accounts should be designated as either Mixed or Unmixed. However, if any path
68+
in the format of `m/44'/5'/<account>'/0/<index>` has only a single coin which is
69+
a recognizable denomination, it should be searched from
70+
`m/44'/5'/<account>'/1/<index>` up through `m/44'/5'/<account>'/<n>/<index>` to
71+
the first unused address to find unspent mixed, denominated coins.
72+
73+
### Coin Mix Tracking via HDPath
74+
75+
**Summary of BIP-44**
76+
77+
The index to a particular private key or address of an HDPath is defined in this
78+
format:
79+
80+
```text
81+
m/<bip44>'/<coin>'/<account>'/<usage>/<index>
82+
m/44'/5'/0'/0/0
83+
```
84+
85+
The _Usage_ path component is presently used to indicate either:
86+
87+
- `0` as _External_, for sending money
88+
- `1` as _Internal_ for receiving change
89+
90+
**Applied to Coin Mixing**
91+
92+
There are many factors that effect the viability of coin mixing, so for this
93+
specification and these examples we'll make 2 assumptions:
94+
95+
1. mixed coins are generally not used in a scenarios where change is returned
96+
2. any return change is denominated and its transaction adheres to
97+
[Lexicographical Indexing of TX Inputs & Outputs][lextx]
98+
99+
Given those assumptions either A) _Usage_ will _never_ represent return change
100+
or B) the return change will already have some measure of entropy added to it.
101+
102+
This means that the _Usage_ path can be used in for tracking the mix count with
103+
coming into conflict with unmixed coins.
104+
105+
```text
106+
m/<bip44>'/<coin>'/<account>'/<mixcount>/<index>
107+
m/44'/5'/0'/0/0 - newly denominated coin
108+
m/44'/5'/0'/1/0 - coin which has been mixed once
109+
m/44'/5'/0'/...
110+
m/44'/5'/0'/16/0 - a fully mixed coin
111+
m/44'/5'/0'/... - an overmixed coin
112+
```
113+
114+
## Other Considerations
115+
116+
1. Mixed accounts could be designated to start at 2147483648 and count _down_
117+
rather than starting at 0 and counting up.
118+
```text
119+
m/44'/5'/2147483648'/0/0 - newly denominated coin on first mixed account
120+
m/44'/5'/2147483647'/0/0 - newly denominated coin on second mixed account
121+
```
122+
Counterpoint: More complexity, no benefit. Software either will or won't be
123+
able to restore mixed accounts. This doesn't help.
124+
2. A new HDPath designation path could be introduced.
125+
```text
126+
m/dipXX'/5'/0'/0/0
127+
```
128+
Counterpoint: Software that follows the 44' spec can still follow this spec,
129+
so changing the identifier probably only makes it more difficult to adapt
130+
otherwise working software. DASH software will know to check for mixed
131+
funds.
132+
3. A new HDPath component could be introduced.
133+
```text
134+
m/<bip44>'/<coin>'/<account>'/<usage>/<index>/<mixcount>
135+
m/dipXX'/5'/0'/0/0
136+
```
137+
Counterpoint: Same as above, but more so.
138+
139+
## Copyright
140+
141+
Copyright 2023 AJ ONeal.
142+
143+
DIP to Secure Transactions - Patch Data Leak Vulnerability via Deterministic
144+
Index Ordering
145+
146+
Written in 2023 by AJ ONeal <coolaj86@proton.me> \
147+
To the extent possible under law, the author(s) have dedicated all copyright \
148+
and related and neighboring rights to this software to the public domain \
149+
worldwide. This software is distributed without any warranty. \
150+
151+
You should have received a copy of the CC0 Public Domain Dedication along with \
152+
this software. If not, see <https://creativecommons.org/publicdomain/zero/1.0/>.

0 commit comments

Comments
 (0)