View difference between Paste ID: rdnSYwna and 7srK7TC3
SHOW: | | - or go back to the newest paste.
1
/*Stealth Short Payment IDs - proposals for shortening displayed payment IDs (to 32 bit), keeping full 32 byte "actual" payment IDs, AND incorporating a stealth feature to improve anonymity*/
2
3
//idea 1d
4
var rkeys = {};
5
rkeys = create_address(rand_32()); //for testing
6-
var payId = "0e0eedd4"; //32 bit
6+
var payId = "0123456789ab"; /*48 bit, ~281 trillion transactions available per account (started with 32 bit, but didn't want to fall into the "this ought to be enough for anybody" line of thinking). An new integrated address would be just 104 characters long vs 139 for present version.*/
7
var payIdHash = cn_fast_hash(payId);
8
var txkey = random_keypair(); //same keypair used for tx
9
var der = generate_key_derivation(rkeys.view.pub, txkey.sec);
10
var payIdOutput = derive_public_key(der, -1, rkeys.spend.pub);
11
var realPayId = hexXor(payIdOutput, payIdHash); //JS can only xor numbers, made up function to xor hex strings
12
13
//receiver would:
14
der = generate_key_derivation(txkey.pub, rkeys.view.sec); //txkey.pub from tx_extra
15
payIdOutput = derive_public_key(der, -1, rkeys.spend.pub);
16
payIdHash = hexXor(payIdOutput, realPayId); //realPayId from tx_extra
17
//compare payIdHash with known set
18
19
/*Note on output index in derive_public/secret_key operations: -1 actually works in JS, but it should of course be tested and reviewed before actual use. 1> last real output index could be used instead of -1.*/
20
21
//old ideas
22
//ordered by cost (highest first)
23
//idea 1a
24
var rkeys = {};
25
rkeys = create_address(rand_32()); //for testing obviously
26
var payId = {};
27
payId.id = "0e0eedd4"; //for example, 32 bit; an integrated address like this would be 101 base58 characters instead of 139 now
28
payId.sec = sc_reduce32(cn_fast_hash(payId.id)); //not used
29
payId.pub = sec_key_to_pub(payId.sec);
30
var txkey = random_keypair(); //same keypair used for tx
31
var der = generate_key_derivation(rkeys.view.pub, txkey.sec); //same derivation as the TX itself
32
var realPayId = derive_public_key(der, -1, payId.pub);
33
34
//idea 1b
35
var rkeys = {};
36
rkeys = create_address(rand_32()); //for testing obviously
37
var payId = {};
38
payId.id = "0e0eedd4";
39
payId.sec = sc_reduce32(cn_fast_hash(payId.id)); /*I do not know if sc_reduce32 needs to be used, as we don't need a "real"
40
scalar for our realPayId. It appears to work without after numerous tests (in JS at least), but then again sc_reduce32 costs 
41
very little.*/
42
var txkey = random_keypair(); //same keypair used for tx
43
var der = generate_key_derivation(rkeys.view.pub, txkey.sec);
44
var realPayId = derive_secret_key(der, -1, payId.sec);
45
46
//idea 1c
47
var rkeys = {};
48
rkeys = create_address(rand_32()); //for testing obviously
49
var shortPayId = "0e0eedd4";
50
var txkey = random_keypair(); //same keypair used for tx
51
var der = generate_key_derivation(rkeys.view.pub, txkey.sec);
52
var payIdOutput = derive_public_key(der, -1, rkeys.spend.pub);
53
var realPayId = cn_fast_hash(shortPayId + payIdOutput.slice(0,56)); //just to keep input length 32 bytes
54
55
//cost analysis
56
/*1a: expensive, requires sec_key_to_pub (can be one time) and derive_public_key operations for *every* (or 50% on average to find the match) payment ID (that a firm is tracking) for *every* transaction that has outputs belonging to the firm; for a large firm with potentially millions of payment IDs it just costs too much
57
1b: here we get rid of the sec_key_to_pub and derive_public_key operations in favor of a single derive_secret_key operation; it costs less, but not significantly so since sec_key_to_pub can be stored in 1a
58
1c: here we replace the "many" operation (derive_public_key or derive_secret_key) with a hash of the short ID plus a portion of an output public key; estimate 2 orders of magnitude or more reduction in cost, making 1c (or a variant) probably feasible
59
1d: here we use the output public key as an encryption key of sorts, removing the "many" operation entirely; cost becomes negligible, regardless of the size of known ID set, as it can just be decrypted and compared with known ID hashes*/