View difference between Paste ID: wAb5eHPY and ed3E2rK4
SHOW: | | - or go back to the newest paste.
1
/*Stealth Short Payment IDs - proposal(s) for shortening "user" payment IDs (to 64 bit) while keeping full 32 byte "blockchain" payment IDs, incorporating a stealth feature to improve anonymity, and adding a new v2 integrated address
2
3
We are basically discussing three different aspects here, which aren't strictly related:
4
1. Stealth IDs, which change every TX, just like (or rather, similar to) addresses
5
2. Shortened IDs, less characters to display, copy, etc. The current space 2^256 is absurdly large and unnecessary, but whether that justifies changing (while the "network" version remains 256-bit), I'm not sure. CN addresses are "long" in any case, but I believe there's a cutoff point around 110-120 characters that results in line wrapping even on 1080p screens on many webpages. I think it's warranted to try to keep it under that bound if there is little reason not to. I guess it boils down to: is public address space precious even though it's already very long, or is "wasting" more characters not of any/much consequence?
6
3. New (v2) integrated addresses: not strictly necessary, unless implementing 2 as well.
7
8
Part of the idea is to not keep changing things all the time, so it seems reasonable to (at least try to) get it into a state where it can operate for years with no additional changes. #3 acts as a nice way to "tie it up with a bow", because shorter is better than longer (right?), and it creates an easy way to "enable" stealth IDs as the receivers take the time to implement them. If you just implement tx construction logic for stealth IDs, the existing payment ID implementation breaks (that seems bad). Thus if a receiver hands out v2 integrated addresses, they would be expected to support stealth IDs; if not, then use old method.
9
10
If shortening "user" payment IDs gets a general nack (there are some possibly valid considerations about out-of-band revealing of unwanted data by the ID generator/higher chance of "accidental" collision, etc, with a smaller set size), I would recommend the solution be to re-purpose the "existing" integrated address to use stealth logic (since no one has implemented it yet, it's not in a tagged release, etc) and continue to treat manual payment IDs the same as today (untouched). Even with consensus for shortening, I still feel it appropriate to "overwrite" v1 integrated addresses with the new short version; since no one supports them yet, we can avoid supporting them into perpetuity.
11
12
Chance of collision for randomly generating 1 million IDs: 1,000,000^2 / (2^64 * 2) = ~1/36,893,488
13
50% chance happens at 5.06 billion IDs generated.
14
If receivers are randomly generating IDs (and they should be, to avoid revealing data to their customers) with non-negligible chance of collision, obviously values need to be checked against existing.
15
16
1.4.2 without padding would be the proposal if short user payment IDs are nacked.
17
18
For reference to those unfamiliar with the integrated address in current head, it looks like:
19
"netbyte (0x13)" + "32 byte public spend key" + "32 byte public view key" + "32 byte payment ID (8 byte proposed for v2)" + "4 byte checksum of all previous data"
20
*/
21
//apologies for using javascript, it's the easiest way at present for me to express the implementation proposal
22
//using cnUtil.js from mymonero.com for functions
23
24
//---------------------------------------------------------
25
//proposal 1.4.1 (older ideas discarded as subpar and/or unscalable)
26
//we hash the short paymentID to get a 32 byte version before encrypting
27
var receiverKeys = create_address(rand_32()); //for example only
28
var payId = "0123456789abcdef"; /*64 bit, ~18.4 quintillion transactions/users available per account. A new integrated address would be just 106 characters long vs 139 for present version.*/
29
var payIdHash = cn_fast_hash(payId);
30
var txkey = random_keypair();
31
var der = generate_key_derivation(receiverKeys.view.pub, txkey.sec);
32
var stealthKey = cn_fast_hash(der);
33-
var realPayId = hexXor(payIdKey, payIdHash); //JS can only xor numbers, made up function to xor hex strings
33+
var realPayId = hexXor(stealthKey, payIdHash); //JS can only xor numbers, made up function to xor hex strings
34
35
//receiver would:
36-
der = generate_key_derivation(txkey.pub, receiverKeys.view.sec); //txkey.pub from tx_extra
36+
var der = generate_key_derivation(txkey.pub, receiverKeys.view.sec); //txkey.pub from tx_extra
37-
stealthKey = cn_fast_hash(der);
37+
38-
payIdHash = hexXor(payIdKey, realPayId); //realPayId from tx_extra
38+
var payIdHash = hexXor(stealthKey, realPayId); //realPayId from tx_extra
39
//*compare payIdHash with known set*
40
//---------------------------------------------------------
41
42
43
//---------------------------------------------------------
44
//proposal 1.4.2
45
//instead of hashing, we just pad the short version to 32 bytes before encrypting
46
//this means the receiver doesn't need to store an extra hashed version to match, but loses uniformity in the "paddedPayId"
47
//compared to the "payIdHash"
48
//I *believe* that, given the assumptions on secure hashing, the security difference between the two is negligible
49
var receiverKeys = create_address(rand_32()); //for example only
50
var payId = "0123456789abcdef";
51
var paddedPayId = payId + "000000000000000000000000000000000000000000000000"; //48 zeros 
52
var txkey = random_keypair();
53
var der = generate_key_derivation(receiverKeys.view.pub, txkey.sec);
54
var stealthKey = cn_fast_hash(der);
55-
var realPayId = hexXor(payIdKey, paddedPayId); //JS can only xor numbers, made up function to xor hex strings
55+
var realPayId = hexXor(stealthKey, paddedPayId); //JS can only xor numbers, made up function to xor hex strings
56
57
//receiver would:
58-
der = generate_key_derivation(txkey.pub, receiverKeys.view.sec); //txkey.pub from tx_extra
58+
var der = generate_key_derivation(txkey.pub, receiverKeys.view.sec); //txkey.pub from tx_extra
59-
stealthKey = cn_fast_hash(der);
59+
60-
paddedPayId = hexXor(payIdKey, realPayId); //realPayId from tx_extra
60+
var paddedPayId = hexXor(stealthKey, realPayId); //realPayId from tx_extra
61-
//*compare paddedPayID.slice(0,12) with known set*
61+
//*compare paddedPayID.slice(0,16) with known set*
62
//---------------------------------------------------------
63
64
//At present I support 1.4.2.
65
66
//I appreciate any and all feedback!
67
//luigi1111