(streamNumber=1, stealthLevel=0)
| 14 | # - level 2: a standard message, encrypted to a random pubkey |
| 15 | |
| 16 | def genAckPayload(streamNumber=1, stealthLevel=0): |
| 17 | if (stealthLevel==2): # Generate privacy-enhanced payload |
| 18 | # Generate a dummy privkey and derive the pubkey |
| 19 | dummyPubKeyHex = highlevelcrypto.privToPub(hexlify(helper_random.randomBytes(32))) |
| 20 | # Generate a dummy message of random length |
| 21 | # (the smallest possible standard-formatted message is 234 bytes) |
| 22 | dummyMessage = helper_random.randomBytes(random.randint(234, 800)) |
| 23 | # Encrypt the message using standard BM encryption (ECIES) |
| 24 | ackdata = highlevelcrypto.encrypt(dummyMessage, dummyPubKeyHex) |
| 25 | acktype = 2 # message |
| 26 | version = 1 |
| 27 | |
| 28 | elif (stealthLevel==1): # Basic privacy payload (random getpubkey) |
| 29 | ackdata = helper_random.randomBytes(32) |
| 30 | acktype = 0 # getpubkey |
| 31 | version = 4 |
| 32 | |
| 33 | else: # Minimum viable payload (non stealth) |
| 34 | ackdata = helper_random.randomBytes(32) |
| 35 | acktype = 2 # message |
| 36 | version = 1 |
| 37 | |
| 38 | ackobject = pack('>I', acktype) + encodeVarint(version) + encodeVarint(streamNumber) + ackdata |
| 39 | |
| 40 | return ackobject |
no test coverage detected