diff --git a/src/helpers/util.js b/src/helpers/util.js index 16460c6c52..b48107ebd8 100644 --- a/src/helpers/util.js +++ b/src/helpers/util.js @@ -125,7 +125,7 @@ module.exports = { * @param {String} value - value to sha3 * @return {Object} - return sha3ied value */ - sha3_32: function (value) { + sha3_256: function (value) { var ret = ethutil.bufferToHex(ethutil.setLengthLeft(value, 32)) ret = ethutil.sha3(ret) return ethutil.bufferToHex(ret) diff --git a/src/solidity/types/ArrayType.js b/src/solidity/types/ArrayType.js index 8f0f409678..f6ce23c0ac 100644 --- a/src/solidity/types/ArrayType.js +++ b/src/solidity/types/ArrayType.js @@ -43,7 +43,7 @@ class ArrayType extends RefType { } if (this.arraySize === 'dynamic') { size = util.toBN('0x' + slotValue) - currentLocation.slot = helper.sha3_32(location.slot) + currentLocation.slot = helper.sha3_256(location.slot) } else { size = new BN(this.arraySize) } diff --git a/src/solidity/types/DynamicByteArray.js b/src/solidity/types/DynamicByteArray.js index 2dd8edbe9e..f45fa8fa44 100644 --- a/src/solidity/types/DynamicByteArray.js +++ b/src/solidity/types/DynamicByteArray.js @@ -23,7 +23,7 @@ class DynamicByteArray extends RefType { var bn = new BN(value, 16) if (bn.testn(0)) { var length = bn.div(new BN(2)) - var dataPos = new BN(helper.sha3_32(location.slot).replace('0x', ''), 16) + var dataPos = new BN(helper.sha3_256(location.slot).replace('0x', ''), 16) var ret = '' var currentSlot = '0x' try { diff --git a/src/storage/storageViewer.js b/src/storage/storageViewer.js index 37b8463949..1252276d38 100644 --- a/src/storage/storageViewer.js +++ b/src/storage/storageViewer.js @@ -30,7 +30,7 @@ class StorageViewer { * @param {Function} - callback - {key, hashedKey, value} - */ storageSlot (slot, callback) { - var hashed = helper.sha3_32(slot) + var hashed = helper.sha3_256(slot) this.storageResolver.storageSlot(hashed, this.context.tx, this.context.stepIndex, this.storageChanges, this.context.address, (error, result) => { if (error) { callback(error) diff --git a/src/trace/traceCache.js b/src/trace/traceCache.js index 7a94109c7b..3d31012270 100644 --- a/src/trace/traceCache.js +++ b/src/trace/traceCache.js @@ -87,7 +87,7 @@ TraceCache.prototype.pushStoreChanges = function (index, address, key, value) { 'address': address, 'key': key, 'value': value, - 'hashedKey': helper.sha3_32(key) + 'hashedKey': helper.sha3_256(key) } this.storageChanges.push(index) } diff --git a/test/solidity/mockStorageResolver.js b/test/solidity/mockStorageResolver.js index 2f9f248f0d..bdf55ba575 100644 --- a/test/solidity/mockStorageResolver.js +++ b/test/solidity/mockStorageResolver.js @@ -5,7 +5,7 @@ class MockStorageResolver { constructor (_storage) { this.storage = {} for (var k in _storage) { - var hashed = util.sha3_32(k) + var hashed = util.sha3_256(k) this.storage[hashed] = { hashed: hashed, key: k, @@ -19,7 +19,7 @@ class MockStorageResolver { } storageSlot (slot, callback) { - var hashed = util.sha3_32(slot) + var hashed = util.sha3_256(slot) callback(null, this.storage[hashed]) }