From 78fcda7ce09a9075d148b7d2f5ada49cb68884e4 Mon Sep 17 00:00:00 2001 From: Ben Edgington Date: Thu, 10 Jan 2019 20:44:47 +0000 Subject: [PATCH] Use bitwise xor to simplify merkle branch getter --- specs/core/0_beacon-chain.md | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/specs/core/0_beacon-chain.md b/specs/core/0_beacon-chain.md index c86b4b6b5..e2ed64cf1 100644 --- a/specs/core/0_beacon-chain.md +++ b/specs/core/0_beacon-chain.md @@ -698,10 +698,7 @@ def get_merkle_branch(index: uint256) -> bytes32[32]: # size is DEPOSIT_CONTRACT idx: uint256 = index + TWO_TO_POWER_OF_TREE_DEPTH ret: bytes32[32] # size is DEPOSIT_CONTRACT_TREE_DEPTH for i in range(DEPOSIT_CONTRACT_TREE_DEPTH): - if idx % 2 == 1: - ret[i] = self.deposit_tree[idx - 1] - else: - ret[i] = self.deposit_tree[idx + 1] + ret[i] = self.deposit_tree[bitwise_xor(idx,1)] idx /= 2 return ret ```