From 180cdc3215c81d23dc06d295b8c1ae97c3cdd670 Mon Sep 17 00:00:00 2001 From: Ricardo Guilherme Schmidt <3esmit@gmail.com> Date: Mon, 27 Aug 2018 02:35:32 -0300 Subject: [PATCH] small typos --- contracts/common/MerkleProof.sol | 78 ++++++++------------- contracts/registry/ENSSubdomainRegistry.sol | 2 +- 2 files changed, 32 insertions(+), 48 deletions(-) diff --git a/contracts/common/MerkleProof.sol b/contracts/common/MerkleProof.sol index 4c30de0..9bb6ef4 100644 --- a/contracts/common/MerkleProof.sol +++ b/contracts/common/MerkleProof.sol @@ -1,59 +1,43 @@ pragma solidity ^0.4.24; -/* +/** * @title MerkleProof * @dev Merkle proof verification based on * https://github.com/ameensol/merkle-tree-solidity/blob/master/src/MerkleProof.sol */ library MerkleProof { - /* - * @dev Verifies a Merkle proof proving the existence of a leaf in a Merkle tree. Assumes that each pair of leaves - * and each pair of pre-images is sorted. - * @param _proof Merkle proof containing sibling hashes on the branch from the leaf to the root of the Merkle tree - * @param _root Merkle root - * @param _leaf Leaf of Merkle tree - */ - function verifyProof( - bytes32[] _proof, - bytes32 _root, - bytes32 _leaf - ) - internal - pure - returns (bool) - { - bytes32 computedHash = _leaf; + /** + * @dev Verifies a Merkle proof proving the existence of a leaf in a Merkle tree. Assumes that each pair of leaves + * and each pair of pre-images are sorted. + * @param _proof Merkle proof containing sibling hashes on the branch from the leaf to the root of the Merkle tree + * @param _root Merkle root + * @param _leaf Leaf of Merkle tree + */ + function verifyProof( + bytes32[] _proof, + bytes32 _root, + bytes32 _leaf + ) + internal + pure + returns (bool) + { + bytes32 computedHash = _leaf; - for (uint256 i = 0; i < _proof.length; i++) { - bytes32 proofElement = _proof[i]; + for (uint256 i = 0; i < _proof.length; i++) { + bytes32 proofElement = _proof[i]; - if (computedHash < proofElement) { - // Hash(current computed hash + current element of the proof) - computedHash = keccak256(abi.encodePacked(computedHash, proofElement)); - } else { - // Hash(current element of the proof + current computed hash) - computedHash = keccak256(abi.encodePacked(proofElement, computedHash)); - } + if (computedHash < proofElement) { + // Hash(current computed hash + current element of the proof) + computedHash = keccak256(abi.encodePacked(computedHash, proofElement)); + } else { + // Hash(current element of the proof + current computed hash) + computedHash = keccak256(abi.encodePacked(proofElement, computedHash)); + } + } + + // Check if the computed hash (root) is equal to the provided root + return computedHash == _root; } - - // Check if the computed hash (root) is equal to the provided root - return computedHash == _root; - } } - - © 2018 GitHub, Inc. - Terms - Privacy - Security - Status - Help - - Contact GitHub - API - Training - Shop - Blog - About - -Press h to open a hovercard with more details. diff --git a/contracts/registry/ENSSubdomainRegistry.sol b/contracts/registry/ENSSubdomainRegistry.sol index 3b5d35f..56dd1ee 100644 --- a/contracts/registry/ENSSubdomainRegistry.sol +++ b/contracts/registry/ENSSubdomainRegistry.sol @@ -202,7 +202,7 @@ contract ENSSubdomainRegistry is Controlled { MerkleProof.verifyProof( _proof, unallowedCharactersMerkleRoot, - keccak256(abi.encodePacked(rangeStart, rangeEnd)) + keccak256(abi.encodePacked(_rangeStart, _rangeEnd)) ), "Invalid Proof." );