Example #1
0
 def _make_node_path(self, xpub, address_n):
     pubkey = bip32_key_from_string(xpub)
     derivation = pubkey.derivation()
     node = HDNodeType(
         depth=derivation.depth,
         fingerprint=be_bytes_to_int(pubkey.fingerprint()),
         child_num=derivation.n,
         chain_code=derivation.chain_code,
         public_key=pubkey.to_bytes(),
     )
     return HDNodePathType(node=node, address_n=address_n)
Example #2
0
def random_integer(nbits):
    nbytes = (nbits + 7) // 8
    return be_bytes_to_int(os.urandom(nbytes)) % (1 << nbits)
Example #3
0
 def get_sequence(cls, mpk: str, derivation_path: Sequence[int]) -> int:
     old_sequence = derivation_path[1], derivation_path[0]
     return be_bytes_to_int(
         sha256d(("%d:%d:" % old_sequence).encode('ascii') +
                 bytes.fromhex(mpk)))
Example #4
0
 def stretch_key(self, seed):
     x = seed
     for i in range(100000):
         x = hashlib.sha256(x + seed).digest()
     return be_bytes_to_int(x)
Example #5
0
 def get_sequence(cls, mpk, for_change, n):
     return be_bytes_to_int(sha256d(("%d:%d:"%(n, for_change)).encode('ascii') + bfh(mpk)))
Example #6
0
 def test_s_value(self, der_sig, compact_sig):
     s = Signature(der_sig + pack_byte(SigHash.ALL))
     assert s.s_value() == be_bytes_to_int(compact_sig[32:])