def derive(number)
      new_key = ExtPubkey.new
      new_key.depth = depth + 1
      new_key.number = number
      new_key.parent_fingerprint = fingerprint
      raise 'hardened key is not support' if number > (HARDENED_THRESHOLD - 1)
      data = pub.htb << [number].pack('N')
      l = Bitcoin.hmac_sha512(chain_code, data)
      left = l[0..31].bth.to_i(16)
      raise 'invalid key' if left >= CURVE_ORDER
      p1 = Bitcoin::Secp256k1::GROUP.generator.multiply_by_scalar(left)
      p2 = Bitcoin::Key.new(pubkey: pubkey, key_type: key_type).to_point
      new_key.pubkey = ECDSA::Format::PointOctetString.encode(p1 + p2, compression: true).bth
      new_key.chain_code = l[32..-1]
      new_key.ver = version
      new_key
    end
def derive(number)
      new_key = ExtPubkey.new
      new_key.depth = depth + 1
      new_key.number = number
      new_key.parent_fingerprint = fingerprint
      raise 'hardened key is not support' if number > (HARDENED_THRESHOLD - 1)
      data = pub.htb << [number].pack('N')
      l = Bitcoin.hmac_sha512(chain_code, data)
      left = l[0..31].bth.to_i(16)
      raise 'invalid key' if left >= CURVE_ORDER
      p1 = Bitcoin::Secp256k1::GROUP.generator.multiply_by_scalar(left)
      p2 = Bitcoin::Key.new(pubkey: pubkey, key_type: key_type).to_point
      new_key.pubkey = ECDSA::Format::PointOctetString.encode(p1 + p2, compression: true).bth
      new_key.chain_code = l[32..-1]
      new_key.ver = version
      new_key
    end
derive child key