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 obviously | |
| 6 | - | var payId = "0e0eedd4"; |
| 6 | + | var payId = "0e0eedd4"; //32 bit |
| 7 | - | var payIdHash = cn_fast_hash(payID.ID); |
| 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 | - | /*Note on output index in derive_public/secret_key operations: -1 actually works in JS, but it should be tested and reviewed before actually using it. For ideas 1a and 1b, an index of 0 can safely be used because the pub/sec keys being used are not the same as the rest of the outputs in the TX. For 1c and 1d, 1> last real output index could be used instead of -1.*/ |
| 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 | ||
| 22 | //old ideas | |
| 23 | //ordered by cost (highest first) | |
| 24 | //idea 1a | |
| 25 | var rkeys = {};
| |
| 26 | rkeys = create_address(rand_32()); //for testing obviously | |
| 27 | var payId = {};
| |
| 28 | payId.id = "0e0eedd4"; //for example, 32 bit; an integrated address like this would be 101 base58 characters instead of 139 now | |
| 29 | payId.sec = sc_reduce32(cn_fast_hash(payId.id)); //not used | |
| 30 | payId.pub = sec_key_to_pub(payId.sec); | |
| 31 | var txkey = random_keypair(); //same keypair used for tx | |
| 32 | var der = generate_key_derivation(rkeys.view.pub, txkey.sec); //same derivation as the TX itself | |
| 33 | var realPayId = derive_public_key(der, -1, payId.pub); | |
| 34 | ||
| 35 | //idea 1b | |
| 36 | var rkeys = {};
| |
| 37 | rkeys = create_address(rand_32()); //for testing obviously | |
| 38 | var payId = {};
| |
| 39 | payId.id = "0e0eedd4"; | |
| 40 | 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" | |
| 41 | scalar for our realPayId. It appears to work without after numerous tests (in JS at least), but then again sc_reduce32 costs | |
| 42 | very little.*/ | |
| 43 | var txkey = random_keypair(); //same keypair used for tx | |
| 44 | var der = generate_key_derivation(rkeys.view.pub, txkey.sec); | |
| 45 | var realPayId = derive_secret_key(der, -1, payId.sec); | |
| 46 | ||
| 47 | //idea 1c | |
| 48 | var rkeys = {};
| |
| 49 | rkeys = create_address(rand_32()); //for testing obviously | |
| 50 | var shortPayId = "0e0eedd4"; | |
| 51 | var txkey = random_keypair(); //same keypair used for tx | |
| 52 | var der = generate_key_derivation(rkeys.view.pub, txkey.sec); | |
| 53 | var payIdOutput = derive_public_key(der, -1, rkeys.spend.pub); | |
| 54 | var realPayId = cn_fast_hash(shortPayId + payIdOutput.slice(0,56)); //just to keep input length 32 bytes | |
| 55 | ||
| 56 | //cost analysis | |
| 57 | /*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 | |
| 58 | 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 | |
| 59 | 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 | |
| 60 | 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*/ |