mirror of
https://github.com/yzernik/squeaknode.git
synced 2026-08-15 12:50:47 +02:00
22 lines
384 B
Python
22 lines
384 B
Python
import os
|
|
|
|
DATA_KEY_LENGTH = 32
|
|
|
|
|
|
def get_hash(squeak):
|
|
return squeak.GetHash()[::-1]
|
|
|
|
|
|
def generate_offer_nonce():
|
|
return os.urandom(DATA_KEY_LENGTH)
|
|
|
|
|
|
def generate_offer_preimage():
|
|
return os.urandom(DATA_KEY_LENGTH)
|
|
|
|
|
|
def bxor(b1, b2): # use xor for bytes
|
|
result = bytearray()
|
|
for b1, b2 in zip(b1, b2):
|
|
result.append(b1 ^ b2)
|
|
return bytes(result)
|