Esempio n. 1
0
 def derive_child(self, i):
     high_bit = i & PUBLIC_DERIVATION_BIT
     if high_bit:
         I = hmac_sha512(self.chain_code, '\x00' + encode_bigint(self.key) + struct.pack('>L', i)).digest()
     else:
         I = hmac_sha512(self.chain_code, encode_pub_compressed(priv_to_pub(self.key)) + struct.pack('>L', i)).digest()
     IL = decode_bigint(I[:32])
     if IL >= secp256k1.order:
         raise Error('invalid key')
     IR = I[32:]
     ki = (IL + self.key) % secp256k1.order
     if ki == 0:
         raise Error('invalid key')
     ci = IR
     return HDPrivKey(ki, ci, self.depth + 1, i, self.fingerprint(), self.V_T[self.version])
Esempio n. 2
0
 def derive_child(self, i):
     high_bit = i & PUBLIC_DERIVATION_BIT
     if high_bit:
         I = hmac_sha512(
             self.chain_code, '\x00' + encode_bigint(self.key) +
             struct.pack('>L', i)).digest()
     else:
         I = hmac_sha512(
             self.chain_code,
             encode_pub_compressed(priv_to_pub(self.key)) +
             struct.pack('>L', i)).digest()
     IL = decode_bigint(I[:32])
     if IL >= secp256k1.order:
         raise Error('invalid key')
     IR = I[32:]
     ki = (IL + self.key) % secp256k1.order
     if ki == 0:
         raise Error('invalid key')
     ci = IR
     return HDPrivKey(ki, ci, self.depth + 1, i, self.fingerprint(),
                      self.V_T[self.version])
Esempio n. 3
0
 def serialized_key(self):
     return '\x00' + encode_bigint(self.key)
Esempio n. 4
0
 def serialized_key(self):
     return '\x00' + encode_bigint(self.key)