Returns the proof for a leaf at the given index as an array of merkle siblings in hex format
        :param index:
        :return:
420164
def get_proof(self, index):
        

        if not self.tree['is_ready']:
            return None
        current_row_index = len(self.tree['levels']) - 1
        if index < 0 or index > len(self.tree['levels'][current_row_index]) - 1:
            # the index it out of the bounds of the leaf array
            return None

        proof = []
        for current_level in range(current_row_index, 0, -1):
            current_level_node_count = len(self.tree['levels'][current_level])
            # skip if this is an odd end node
            if index == current_level_node_count - 1 and current_level_node_count % 2 == 1:
                index = int(math.floor(index / 2))
                continue

            # determine the sibling for the current index and get its value
            is_right_node = index % 2
            if is_right_node:
                sibling_index = index - 1
            else:
                sibling_index = index + 1
            sibling = {}

            if is_right_node:
                sibling_position = 'left'
            else:
                sibling_position = 'right'

            sibling_value = self.tree['levels'][current_level][sibling_index]
            sibling[sibling_position] = hexlify(sibling_value)

            proof.append(sibling)

            index = int(math.floor(index / 2))  # set index to the parent index

        return proof
876235
def flatten_tree_to_ident_hashes(item_or_tree,
                                 lucent_id=TRANSLUCENT_BINDER_ID):
    """"""
    if 'contents' in item_or_tree:
        tree = item_or_tree
        if tree['id'] != lucent_id:
            yield tree['id']
        for i in tree['contents']:
            # yield from flatten_tree_to_ident_hashs(i, lucent_id)
            for x in flatten_tree_to_ident_hashes(i, lucent_id):
                yield x
    else:
        item = item_or_tree
        yield item['id']
145987
def __Build(leaves):
        
        if len(leaves) < 1:
            raise Exception('Leaves must have length')
        if len(leaves) == 1:
            return leaves[0]

        num_parents = int((len(leaves) + 1) / 2)
        parents = [MerkleTreeNode() for i in range(0, num_parents)]

        for i in range(0, num_parents):
            node = parents[i]
            node.LeftChild = leaves[i * 2]
            leaves[i * 2].Parent = node
            if (i * 2 + 1 == len(leaves)):
                node.RightChild = node.LeftChild
            else:
                node.RightChild = leaves[i * 2 + 1]
                leaves[i * 2 + 1].Parent = node

            hasharray = bytearray(node.LeftChild.Hash.ToArray() + node.RightChild.Hash.ToArray())
            node.Hash = UInt256(data=Crypto.Hash256(hasharray))

        return MerkleTree.__Build(parents)
92869
def _indexed_leafs(parent):
    
    if not parent.get('children'):
        return {parent['nodeid']: parent}
    indexed = {}
    for child in parent['children']:
        child['parent'] = parent
        if 'leaf' in child:
            indexed[child['nodeid']] = child
        else:
            indexed.update(_indexed_leafs(child))
    parent['leaf'] = _parent_value(parent['children'])
    return indexed
58985
public List<Permutation> getLeftTransversal(int index) {
        List<Permutation> traversal = new ArrayList<Permutation>();
        for (int subIndex = 0; subIndex < size; subIndex++) {
            if (permutations[index][subIndex] != null) {
                traversal.add(permutations[index][subIndex]);
            }
        }
        return traversal;
    }
973729
def _assertIndex(self, index):
        
        if type(index) is not int:
            raise TypeError('list indices must be integers')
        if index < 0 or index >= self.nelems:
            raise IndexError('list index out of range')
195548
def pattern_of(index):
    ''''''
    return np.array([[index & 2**0,index & 2**1,index & 2**2],
                     [index & 2**3,index & 2**4,index & 2**5],
                     [index & 2**6,index & 2**7,index & 2**8]], bool)
739302
def get_common_session_key_proof(self, session_key, salt, server_public, client_public):
        
        h = self.hash
        prove = h(
            h(self._prime) ^ h(self._gen),
            h(self._user),
            salt,
            client_public,
            server_public,
            session_key,
            as_bytes=True
        )
        return prove
1309618
private static Node getNthSibling(Node first, int index) {
    Node sibling = first;
    while (index != 0 && sibling != null) {
      sibling = sibling.getNext();
      index--;
    }
    return sibling;
  }
1372154
def get_merkle_proof(self, tx_hash: str, is_full: bool = False) -> dict:
        
        payload = self.generate_json_rpc_payload(RpcMethod.GET_MERKLE_PROOF, [tx_hash, 1])
        response = self.__post(self.__url, payload)
        if is_full:
            return response
        return response['result']
1135702
public int getDepth(int index) {
    if (index == 0) {
      return 0;
    } else {
      int[] parts = findSubexpression(index);
      return 1 + subexpressions.get(parts[0]).getDepth(parts[1]);
    }
  }
214127
def compute_merkleproof_for(merkletree: 'MerkleTreeState', element: Keccak256) -> List[Keccak256]:
    
    idx = merkletree.layers[LEAVES].index(element)

    proof = []
    for layer in merkletree.layers:
        if idx % 2:
            pair = idx - 1
        else:
            pair = idx + 1

        # with an odd number of elements the rightmost one does not have a pair.
        if pair < len(layer):
            proof.append(layer[pair])

        # the tree is binary and balanced
        idx = idx // 2

    return proof
1057627
def get_chain(self, index):
        
        chain = []
        this = self.leaves[index]
        chain.append((this.val, 'SELF'))
        while this.p:
            chain.append((this.sib.val, this.sib.side))
            this = this.p
        chain.append((this.val, 'ROOT'))
        return chain
959179
def getblockhash(self, index: int) -> str:
        ''''''

        return cast(str, self.api_fetch('getblockhash?index=' + str(index)))
1105494
private int findLeftBrace(char chLeft, int fromIndex) {

        // 查找出现的左括号。
        for (int index = fromIndex; index < length; index++) {

            char ch = pattern.charAt(index);

            // 如果出现左括号，返回。
            if (ch == chLeft) {
                return index;
            }
            // 如果出现非空白字符，返回 - 1.
            else if (!Character.isWhitespace(ch)) {
                return -1;
            }
        }

        // 没有找到匹配的括号。
        return -1;
    }
632134
def __get_v_tree_consistent_leaf_based_hashable_multicolors(self):
        
        result = []
        nodes = deque([self.__root])
        while len(nodes) > 0:
            current_node = nodes.popleft()
            children = current_node.children
            nodes.extend(children)
            if not current_node.is_leaf():
                leaves = filter(lambda node: node.is_leaf(), current_node.get_descendants())
                result.append(Multicolor(*[self.__leaf_wrapper(leaf.name) for leaf in leaves]))
            else:
                result.append(Multicolor(self.__leaf_wrapper(current_node.name)))
        result.append(Multicolor())
        return result
755640
def index2qindexb(self, index):
        
        r = index // 0x10
        c = index % 0x10
        return self.index(r, c)