helper_ackPayload pylint fixes
This commit is contained in:
parent
e97d02ed78
commit
31e3d60fb0
|
@ -1,6 +1,7 @@
|
||||||
"""
|
"""
|
||||||
This module is for generating ack payload
|
This module is for generating ack payload
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from binascii import hexlify
|
from binascii import hexlify
|
||||||
from struct import pack
|
from struct import pack
|
||||||
|
|
||||||
|
@ -8,17 +9,20 @@ import highlevelcrypto
|
||||||
import helper_random
|
import helper_random
|
||||||
from addresses import encodeVarint
|
from addresses import encodeVarint
|
||||||
|
|
||||||
# This function generates payload objects for message acknowledgements
|
|
||||||
# Several stealth levels are available depending on the privacy needs;
|
|
||||||
# a higher level means better stealth, but also higher cost (size+POW)
|
|
||||||
# - level 0: a random 32-byte sequence with a message header appended
|
|
||||||
# - level 1: a getpubkey request for a (random) dummy key hash
|
|
||||||
# - level 2: a standard message, encrypted to a random pubkey
|
|
||||||
|
|
||||||
|
|
||||||
def genAckPayload(streamNumber=1, stealthLevel=0):
|
def genAckPayload(streamNumber=1, stealthLevel=0):
|
||||||
"""Generate and return payload obj."""
|
"""
|
||||||
if (stealthLevel == 2): # Generate privacy-enhanced payload
|
Generate and return payload obj.
|
||||||
|
|
||||||
|
This function generates payload objects for message acknowledgements
|
||||||
|
Several stealth levels are available depending on the privacy needs;
|
||||||
|
a higher level means better stealth, but also higher cost (size+POW)
|
||||||
|
|
||||||
|
- level 0: a random 32-byte sequence with a message header appended
|
||||||
|
- level 1: a getpubkey request for a (random) dummy key hash
|
||||||
|
- level 2: a standard message, encrypted to a random pubkey
|
||||||
|
"""
|
||||||
|
if stealthLevel == 2: # Generate privacy-enhanced payload
|
||||||
# Generate a dummy privkey and derive the pubkey
|
# Generate a dummy privkey and derive the pubkey
|
||||||
dummyPubKeyHex = highlevelcrypto.privToPub(
|
dummyPubKeyHex = highlevelcrypto.privToPub(
|
||||||
hexlify(helper_random.randomBytes(32)))
|
hexlify(helper_random.randomBytes(32)))
|
||||||
|
@ -31,7 +35,7 @@ def genAckPayload(streamNumber=1, stealthLevel=0):
|
||||||
acktype = 2 # message
|
acktype = 2 # message
|
||||||
version = 1
|
version = 1
|
||||||
|
|
||||||
elif (stealthLevel == 1): # Basic privacy payload (random getpubkey)
|
elif stealthLevel == 1: # Basic privacy payload (random getpubkey)
|
||||||
ackdata = helper_random.randomBytes(32)
|
ackdata = helper_random.randomBytes(32)
|
||||||
acktype = 0 # getpubkey
|
acktype = 0 # getpubkey
|
||||||
version = 4
|
version = 4
|
||||||
|
|
Loading…
Reference in New Issue
Block a user