Guest User

Stealth Payment IDs 0.7.4

a guest
Jul 8th, 2015
34
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*Stealth Short Payment IDs - proposal(s) for shortening "user" payment IDs (to 48 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 copy, etc. Obviously the current space 2^256 is astronomically large and unnecessary, but whether that justifies changing, I'm not sure. While CN addresses are "long" in any case, I believe there's a cutoff point around 110-120 characters that results in line wrapping even on 1080p screens on many webpages. I feel it's warranted to try to keep it under that bound if there is little reason not to.
  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. We also don't want to remove by default the ability to specify your own payment ID (without having it auto hashed and encrypted for the receiver).
  9.  
  10. If shortening "user" payment IDs (whether as part of v2 integrated address or not) gets a general nack, 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. For reference to those unfamiliar with the integrated address in current head, it looks like:
  13. "netbyte (0x13)" + "32 byte public spend key" + "32 byte public view key" + "32 byte payment ID (6 byte proposed for v2)" + "4 byte checksum of all previous data"
  14. */
  15. //apologies for using javascript, it's the easiest way at present for me to express the implementation proposal
  16. //using cnUtil from mymonero.com
  17.  
  18. //---------------------------------------------------------
  19. //proposal 1.4.1 (older ideas discarded as subpar and/or unscalable)
  20. //here we hash the short paymentID to get a 32 byte version before encrypting
  21. var receiverKeys = create_address(rand_32()); //for testing only
  22. var payId = "0123456789ab"; /*48 bit, ~281 trillion transactions available per account (started with 32 bit, but trying not to fall into the "this ought to be enough for anybody" line of thinking; I would not be opposed to going up to 64 bit, but you gotta draw the line somewhere if proposing that shrinking is warranted). A new integrated address would be just 104 characters long vs 139 for present version.*/
  23. var payIdHash = cn_fast_hash(payId);
  24. var txkey = random_keypair();
  25. var der = generate_key_derivation(receiverKeys.view.pub, txkey.sec);
  26. var stealthKey = cn_fast_hash(der);
  27. var realPayId = hexXor(payIdKey, payIdHash); //JS can only xor numbers, made up function to xor hex strings
  28.  
  29. //receiver would:
  30. der = generate_key_derivation(txkey.pub, receiverKeys.view.sec); //txkey.pub from tx_extra
  31. stealthKey = cn_fast_hash(der);
  32. payIdHash = hexXor(payIdKey, realPayId); //realPayId from tx_extra
  33. //*compare payIdHash with known set*
  34. //---------------------------------------------------------
  35.  
  36.  
  37. //---------------------------------------------------------
  38. //proposal 1.4.2
  39. //instead of hashing, here we just pad the short version to 32 bytes before encrypting
  40. //this means the receiver doesn't need to store an extra hashed version to match, but loses uniformity in the plaintext ID
  41. var receiverKeys = create_address(rand_32()); //for testing only
  42. var payId = "0123456789ab";
  43. var paddedPayId = payId + "00000000000000000000000000000000000000000000000000"; //50 zeros
  44. var txkey = random_keypair();
  45. var der = generate_key_derivation(receiverKeys.view.pub, txkey.sec);
  46. var stealthKey = cn_fast_hash(der);
  47. var realPayId = hexXor(payIdKey, paddedPayId); //JS can only xor numbers, made up function to xor hex strings
  48.  
  49. //receiver would:
  50. der = generate_key_derivation(txkey.pub, receiverKeys.view.sec); //txkey.pub from tx_extra
  51. stealthKey = cn_fast_hash(der);
  52. paddedPayId = hexXor(payIdKey, realPayId); //realPayId from tx_extra
  53. //*compare paddedPayID.slice(0,12) with known set*
  54. //---------------------------------------------------------
  55.  
  56. //At present I support 1.4.2.
  57.  
  58. //I appreciate any and all feedback!
  59. //luigi1111
Advertisement
Add Comment
Please, Sign In to add comment