MCPcopy Index your code
hub / github.com/Bitmessage/PyBitmessage / genAckPayload

Function genAckPayload

src/helper_ackPayload.py:16–40  ·  view source on GitHub ↗
(streamNumber=1, stealthLevel=0)

Source from the content-addressed store, hash-verified

14# - level 2: a standard message, encrypted to a random pubkey
15
16def 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

Callers 7

processmsgMethod · 0.90
HandleSendMessageMethod · 0.90
HandleSendBroadcastMethod · 0.90
sendMethod · 0.90
sendMethod · 0.90
click_pushButtonSendMethod · 0.90
sendMessageFunction · 0.90

Calls 2

encodeVarintFunction · 0.90
encryptMethod · 0.80

Tested by

no test coverage detected