diff options
-rw-r--r-- | libdevcore/ABI.h | 2 | ||||
-rw-r--r-- | libdevcore/SHA3.cpp | 28 | ||||
-rw-r--r-- | libdevcore/SHA3.h | 16 | ||||
-rw-r--r-- | libevmasm/Assembly.cpp | 2 | ||||
-rw-r--r-- | libevmasm/Assembly.h | 4 | ||||
-rw-r--r-- | libevmasm/KnownState.cpp | 2 | ||||
-rw-r--r-- | libsolidity/ast/AST.cpp | 2 | ||||
-rw-r--r-- | libsolidity/ast/Types.cpp | 2 | ||||
-rw-r--r-- | libsolidity/codegen/ExpressionCompiler.cpp | 2 | ||||
-rw-r--r-- | libsolidity/interface/CompilerStack.cpp | 2 | ||||
-rw-r--r-- | libsolidity/interface/GasEstimator.cpp | 2 | ||||
-rw-r--r-- | test/contracts/Wallet.cpp | 2 | ||||
-rw-r--r-- | test/libsolidity/GasMeter.cpp | 2 | ||||
-rw-r--r-- | test/libsolidity/SolidityEndToEndTest.cpp | 46 | ||||
-rw-r--r-- | test/libsolidity/SolidityExecutionFramework.h | 2 | ||||
-rw-r--r-- | test/libsolidity/SolidityNameAndTypeResolution.cpp | 2 | ||||
-rw-r--r-- | test/libsolidity/SolidityOptimizer.cpp | 4 |
17 files changed, 69 insertions, 53 deletions
diff --git a/libdevcore/ABI.h b/libdevcore/ABI.h index 5b7d160d..423cfda8 100644 --- a/libdevcore/ABI.h +++ b/libdevcore/ABI.h @@ -63,7 +63,7 @@ template <class T, class ... U> bytes abiInAux(T const& _t, U const& ... _u) template <class ... T> bytes abiIn(std::string _id, T const& ... _t) { - return sha3(_id).ref().cropped(0, 4).toBytes() + abiInAux(_t ...); + return keccak256(_id).ref().cropped(0, 4).toBytes() + abiInAux(_t ...); } template <class T> struct ABIDeserialiser {}; diff --git a/libdevcore/SHA3.cpp b/libdevcore/SHA3.cpp index 584ef07e..d4536a34 100644 --- a/libdevcore/SHA3.cpp +++ b/libdevcore/SHA3.cpp @@ -49,12 +49,19 @@ namespace keccak #define decsha3(bits) \ int sha3_##bits(uint8_t*, size_t, const uint8_t*, size_t); +#define deckeccak(bits) \ + int keccak##bits(uint8_t*, size_t, const uint8_t*, size_t); + decshake(128) decshake(256) decsha3(224) decsha3(256) decsha3(384) decsha3(512) +deckeccak(224) +deckeccak(256) +deckeccak(384) +deckeccak(512) /******** The Keccak-f[1600] permutation ********/ @@ -192,6 +199,14 @@ static inline int hash(uint8_t* out, size_t outlen, if (outlen > (bits/8)) { \ return -1; \ } \ + return hash(out, outlen, in, inlen, 200 - (bits / 4), 0x06); \ + } +#define defkeccak(bits) \ + int keccak##bits(uint8_t* out, size_t outlen, \ + const uint8_t* in, size_t inlen) { \ + if (outlen > (bits/8)) { \ + return -1; \ + } \ return hash(out, outlen, in, inlen, 200 - (bits / 4), 0x01); \ } @@ -205,17 +220,20 @@ defsha3(256) defsha3(384) defsha3(512) -} +/*** KECCAK FOFs ***/ +defkeccak(224) +defkeccak(256) +defkeccak(384) +defkeccak(512) -unsigned g_sha3Counter = 0; +} -bool sha3(bytesConstRef _input, bytesRef o_output) +bool keccak256(bytesConstRef _input, bytesRef o_output) { // FIXME: What with unaligned memory? if (o_output.size() != 32) return false; - ++g_sha3Counter; - keccak::sha3_256(o_output.data(), 32, _input.data(), _input.size()); + keccak::keccak256(o_output.data(), 32, _input.data(), _input.size()); // keccak::keccak(ret.data(), 32, (uint64_t const*)_input.data(), _input.size()); return true; } diff --git a/libdevcore/SHA3.h b/libdevcore/SHA3.h index 5393952f..eedcc420 100644 --- a/libdevcore/SHA3.h +++ b/libdevcore/SHA3.h @@ -34,26 +34,24 @@ namespace dev /// Calculate SHA3-256 hash of the given input and load it into the given output. /// @returns false if o_output.size() != 32. -bool sha3(bytesConstRef _input, bytesRef o_output); +bool keccak256(bytesConstRef _input, bytesRef o_output); /// Calculate SHA3-256 hash of the given input, returning as a 256-bit hash. -inline h256 sha3(bytesConstRef _input) { h256 ret; sha3(_input, ret.ref()); return ret; } +inline h256 keccak256(bytesConstRef _input) { h256 ret; keccak256(_input, ret.ref()); return ret; } /// Calculate SHA3-256 hash of the given input, returning as a 256-bit hash. -inline h256 sha3(bytes const& _input) { return sha3(bytesConstRef(&_input)); } +inline h256 keccak256(bytes const& _input) { return keccak256(bytesConstRef(&_input)); } /// Calculate SHA3-256 hash of the given input (presented as a binary-filled string), returning as a 256-bit hash. -inline h256 sha3(std::string const& _input) { return sha3(bytesConstRef(_input)); } +inline h256 keccak256(std::string const& _input) { return keccak256(bytesConstRef(_input)); } /// Calculate SHA3-256 hash of the given input (presented as a FixedHash), returns a 256-bit hash. -template<unsigned N> inline h256 sha3(FixedHash<N> const& _input) { return sha3(_input.ref()); } +template<unsigned N> inline h256 keccak256(FixedHash<N> const& _input) { return keccak256(_input.ref()); } /// Calculate SHA3-256 hash of the given input, possibly interpreting it as nibbles, and return the hash as a string filled with binary data. -inline std::string sha3(std::string const& _input, bool _isNibbles) { return asString((_isNibbles ? sha3(fromHex(_input)) : sha3(bytesConstRef(&_input))).asBytes()); } +inline std::string keccak256(std::string const& _input, bool _isNibbles) { return asString((_isNibbles ? keccak256(fromHex(_input)) : keccak256(bytesConstRef(&_input))).asBytes()); } /// Calculate SHA3-256 MAC -inline void sha3mac(bytesConstRef _secret, bytesConstRef _plain, bytesRef _output) { sha3(_secret.toBytes() + _plain.toBytes()).ref().populate(_output); } - -extern unsigned g_sha3Counter; +inline void keccak256mac(bytesConstRef _secret, bytesConstRef _plain, bytesRef _output) { keccak256(_secret.toBytes() + _plain.toBytes()).ref().populate(_output); } } diff --git a/libevmasm/Assembly.cpp b/libevmasm/Assembly.cpp index c7822819..450ee6ce 100644 --- a/libevmasm/Assembly.cpp +++ b/libevmasm/Assembly.cpp @@ -296,7 +296,7 @@ AssemblyItem const& Assembly::append(AssemblyItem const& _i) AssemblyItem Assembly::newPushLibraryAddress(string const& _identifier) { - h256 h(dev::sha3(_identifier)); + h256 h(dev::keccak256(_identifier)); m_libraries[h] = _identifier; return AssemblyItem(PushLibraryAddress, h); } diff --git a/libevmasm/Assembly.h b/libevmasm/Assembly.h index af28e220..dae1e1da 100644 --- a/libevmasm/Assembly.h +++ b/libevmasm/Assembly.h @@ -45,11 +45,11 @@ public: AssemblyItem newTag() { return AssemblyItem(Tag, m_usedTags++); } AssemblyItem newPushTag() { return AssemblyItem(PushTag, m_usedTags++); } - AssemblyItem newData(bytes const& _data) { h256 h(sha3(asString(_data))); m_data[h] = _data; return AssemblyItem(PushData, h); } + AssemblyItem newData(bytes const& _data) { h256 h(dev::keccak256(asString(_data))); m_data[h] = _data; return AssemblyItem(PushData, h); } AssemblyItem newSub(Assembly const& _sub) { m_subs.push_back(_sub); return AssemblyItem(PushSub, m_subs.size() - 1); } Assembly const& sub(size_t _sub) const { return m_subs.at(_sub); } Assembly& sub(size_t _sub) { return m_subs.at(_sub); } - AssemblyItem newPushString(std::string const& _data) { h256 h(sha3(_data)); m_strings[h] = _data; return AssemblyItem(PushString, h); } + AssemblyItem newPushString(std::string const& _data) { h256 h(dev::keccak256(_data)); m_strings[h] = _data; return AssemblyItem(PushString, h); } AssemblyItem newPushSubSize(u256 const& _subId) { return AssemblyItem(PushSubSize, _subId); } AssemblyItem newPushLibraryAddress(std::string const& _identifier); diff --git a/libevmasm/KnownState.cpp b/libevmasm/KnownState.cpp index dd269ff4..0b6e0ac5 100644 --- a/libevmasm/KnownState.cpp +++ b/libevmasm/KnownState.cpp @@ -378,7 +378,7 @@ KnownState::Id KnownState::applySha3( for (Id a: arguments) data += toBigEndian(*m_expressionClasses->knownConstant(a)); data.resize(size_t(*l)); - v = m_expressionClasses->find(AssemblyItem(u256(sha3(data)), _location)); + v = m_expressionClasses->find(AssemblyItem(u256(dev::keccak256(data)), _location)); } else v = m_expressionClasses->find(sha3Item, {_start, _length}, true, m_sequenceNumber); diff --git a/libsolidity/ast/AST.cpp b/libsolidity/ast/AST.cpp index 294daa13..cca19a4e 100644 --- a/libsolidity/ast/AST.cpp +++ b/libsolidity/ast/AST.cpp @@ -151,7 +151,7 @@ vector<pair<FixedHash<4>, FunctionTypePointer>> const& ContractDefinition::inter if (signaturesSeen.count(functionSignature) == 0) { signaturesSeen.insert(functionSignature); - FixedHash<4> hash(dev::sha3(functionSignature)); + FixedHash<4> hash(dev::keccak256(functionSignature)); m_interfaceFunctionList->push_back(make_pair(hash, fun)); } } diff --git a/libsolidity/ast/Types.cpp b/libsolidity/ast/Types.cpp index 4b5f12ce..6d1af534 100644 --- a/libsolidity/ast/Types.cpp +++ b/libsolidity/ast/Types.cpp @@ -2033,7 +2033,7 @@ string FunctionType::externalSignature() const u256 FunctionType::externalIdentifier() const { - return FixedHash<4>::Arith(FixedHash<4>(dev::sha3(externalSignature()))); + return FixedHash<4>::Arith(FixedHash<4>(dev::keccak256(externalSignature()))); } TypePointers FunctionType::parseElementaryTypeVector(strings const& _types) diff --git a/libsolidity/codegen/ExpressionCompiler.cpp b/libsolidity/codegen/ExpressionCompiler.cpp index 26acd8a4..3d05edd3 100644 --- a/libsolidity/codegen/ExpressionCompiler.cpp +++ b/libsolidity/codegen/ExpressionCompiler.cpp @@ -670,7 +670,7 @@ bool ExpressionCompiler::visit(FunctionCall const& _functionCall) } if (!event.isAnonymous()) { - m_context << u256(h256::Arith(dev::sha3(function.externalSignature()))); + m_context << u256(h256::Arith(dev::keccak256(function.externalSignature()))); ++numIndexed; } solAssert(numIndexed <= 4, "Too many indexed arguments."); diff --git a/libsolidity/interface/CompilerStack.cpp b/libsolidity/interface/CompilerStack.cpp index ec6b5d2e..476721db 100644 --- a/libsolidity/interface/CompilerStack.cpp +++ b/libsolidity/interface/CompilerStack.cpp @@ -302,7 +302,7 @@ dev::h256 CompilerStack::contractCodeHash(string const& _contractName) const if (obj.bytecode.empty() || !obj.linkReferences.empty()) return dev::h256(); else - return dev::sha3(obj.bytecode); + return dev::keccak256(obj.bytecode); } Json::Value CompilerStack::streamAssembly(ostream& _outStream, string const& _contractName, StringMap _sourceCodes, bool _inJsonFormat) const diff --git a/libsolidity/interface/GasEstimator.cpp b/libsolidity/interface/GasEstimator.cpp index 99ed75bc..1c804b78 100644 --- a/libsolidity/interface/GasEstimator.cpp +++ b/libsolidity/interface/GasEstimator.cpp @@ -136,7 +136,7 @@ GasEstimator::GasConsumption GasEstimator::functionalEstimation( ExpressionClasses& classes = state->expressionClasses(); using Id = ExpressionClasses::Id; using Ids = vector<Id>; - Id hashValue = classes.find(u256(FixedHash<4>::Arith(FixedHash<4>(dev::sha3(_signature))))); + Id hashValue = classes.find(u256(FixedHash<4>::Arith(FixedHash<4>(dev::keccak256(_signature))))); Id calldata = classes.find(Instruction::CALLDATALOAD, Ids{classes.find(u256(0))}); classes.forceEqual(hashValue, Instruction::DIV, Ids{ calldata, diff --git a/test/contracts/Wallet.cpp b/test/contracts/Wallet.cpp index cfc630d4..ec968058 100644 --- a/test/contracts/Wallet.cpp +++ b/test/contracts/Wallet.cpp @@ -588,7 +588,7 @@ BOOST_AUTO_TEST_CASE(revoke_addOwner) BOOST_REQUIRE(callContractFunction("changeRequirement(uint256)", u256(3)) == encodeArgs()); // add a new owner Address deployer = m_sender; - h256 opHash = sha3(FixedHash<4>(dev::sha3("addOwner(address)")).asBytes() + h256(0x33).asBytes()); + h256 opHash = dev::keccak256(FixedHash<4>(dev::keccak256("addOwner(address)")).asBytes() + h256(0x33).asBytes()); BOOST_REQUIRE(callContractFunction("addOwner(address)", h256(0x33)) == encodeArgs()); BOOST_REQUIRE(callContractFunction("isOwner(address)", h256(0x33)) == encodeArgs(false)); m_sender = account(0); diff --git a/test/libsolidity/GasMeter.cpp b/test/libsolidity/GasMeter.cpp index 1f216680..fc103393 100644 --- a/test/libsolidity/GasMeter.cpp +++ b/test/libsolidity/GasMeter.cpp @@ -82,7 +82,7 @@ public: { u256 gasUsed = 0; GasMeter::GasConsumption gas; - FixedHash<4> hash(dev::sha3(_sig)); + FixedHash<4> hash(dev::keccak256(_sig)); for (bytes const& arguments: _argumentVariants) { sendMessage(hash.asBytes() + arguments, false, 0); diff --git a/test/libsolidity/SolidityEndToEndTest.cpp b/test/libsolidity/SolidityEndToEndTest.cpp index 9485c5fa..7f9bac60 100644 --- a/test/libsolidity/SolidityEndToEndTest.cpp +++ b/test/libsolidity/SolidityEndToEndTest.cpp @@ -1260,7 +1260,7 @@ BOOST_AUTO_TEST_CASE(multiple_elementary_accessors) compileAndRun(sourceCode); BOOST_CHECK(callContractFunction("data()") == encodeArgs(8)); BOOST_CHECK(callContractFunction("name()") == encodeArgs("Celina")); - BOOST_CHECK(callContractFunction("a_hash()") == encodeArgs(dev::sha3(bytes(1, 0x7b)))); + BOOST_CHECK(callContractFunction("a_hash()") == encodeArgs(dev::keccak256(bytes(1, 0x7b)))); BOOST_CHECK(callContractFunction("an_address()") == encodeArgs(toBigEndian(u160(0x1337)))); BOOST_CHECK(callContractFunction("super_secret_data()") == bytes()); } @@ -1342,7 +1342,7 @@ BOOST_AUTO_TEST_CASE(msg_sig) } )"; compileAndRun(sourceCode); - BOOST_CHECK(callContractFunction("foo(uint256)") == encodeArgs(asString(FixedHash<4>(dev::sha3("foo(uint256)")).asBytes()))); + BOOST_CHECK(callContractFunction("foo(uint256)") == encodeArgs(asString(FixedHash<4>(dev::keccak256("foo(uint256)")).asBytes()))); } BOOST_AUTO_TEST_CASE(msg_sig_after_internal_call_is_same) @@ -1358,7 +1358,7 @@ BOOST_AUTO_TEST_CASE(msg_sig_after_internal_call_is_same) } )"; compileAndRun(sourceCode); - BOOST_CHECK(callContractFunction("foo(uint256)") == encodeArgs(asString(FixedHash<4>(dev::sha3("foo(uint256)")).asBytes()))); + BOOST_CHECK(callContractFunction("foo(uint256)") == encodeArgs(asString(FixedHash<4>(dev::keccak256("foo(uint256)")).asBytes()))); } BOOST_AUTO_TEST_CASE(now) @@ -1686,7 +1686,7 @@ BOOST_AUTO_TEST_CASE(sha3) compileAndRun(sourceCode); auto f = [&](u256 const& _x) -> u256 { - return dev::sha3(toBigEndian(_x)); + return dev::keccak256(toBigEndian(_x)); }; testSolidityAgainstCpp("a(bytes32)", f, u256(4)); testSolidityAgainstCpp("a(bytes32)", f, u256(5)); @@ -2582,7 +2582,7 @@ BOOST_AUTO_TEST_CASE(event) BOOST_CHECK_EQUAL(m_logs[0].address, m_contractAddress); BOOST_CHECK_EQUAL(h256(m_logs[0].data), h256(u256(value))); BOOST_REQUIRE_EQUAL(m_logs[0].topics.size(), 3); - BOOST_CHECK_EQUAL(m_logs[0].topics[0], dev::sha3(string("Deposit(address,bytes32,uint256)"))); + BOOST_CHECK_EQUAL(m_logs[0].topics[0], dev::keccak256(string("Deposit(address,bytes32,uint256)"))); BOOST_CHECK_EQUAL(m_logs[0].topics[1], h256(m_sender, h256::AlignRight)); BOOST_CHECK_EQUAL(m_logs[0].topics[2], h256(id)); } @@ -2604,7 +2604,7 @@ BOOST_AUTO_TEST_CASE(event_no_arguments) BOOST_CHECK_EQUAL(m_logs[0].address, m_contractAddress); BOOST_CHECK(m_logs[0].data.empty()); BOOST_REQUIRE_EQUAL(m_logs[0].topics.size(), 1); - BOOST_CHECK_EQUAL(m_logs[0].topics[0], dev::sha3(string("Deposit()"))); + BOOST_CHECK_EQUAL(m_logs[0].topics[0], dev::keccak256(string("Deposit()"))); } BOOST_AUTO_TEST_CASE(event_anonymous) @@ -2664,7 +2664,7 @@ BOOST_AUTO_TEST_CASE(event_lots_of_data) BOOST_CHECK_EQUAL(m_logs[0].address, m_contractAddress); BOOST_CHECK(m_logs[0].data == encodeArgs((u160)m_sender, id, value, true)); BOOST_REQUIRE_EQUAL(m_logs[0].topics.size(), 1); - BOOST_CHECK_EQUAL(m_logs[0].topics[0], dev::sha3(string("Deposit(address,bytes32,uint256,bool)"))); + BOOST_CHECK_EQUAL(m_logs[0].topics[0], dev::keccak256(string("Deposit(address,bytes32,uint256,bool)"))); } BOOST_AUTO_TEST_CASE(event_really_lots_of_data) @@ -2681,9 +2681,9 @@ BOOST_AUTO_TEST_CASE(event_really_lots_of_data) callContractFunction("deposit()"); BOOST_REQUIRE_EQUAL(m_logs.size(), 1); BOOST_CHECK_EQUAL(m_logs[0].address, m_contractAddress); - BOOST_CHECK(m_logs[0].data == encodeArgs(10, 0x60, 15, 4) + FixedHash<4>(dev::sha3("deposit()")).asBytes()); + BOOST_CHECK(m_logs[0].data == encodeArgs(10, 0x60, 15, 4) + FixedHash<4>(dev::keccak256("deposit()")).asBytes()); BOOST_REQUIRE_EQUAL(m_logs[0].topics.size(), 1); - BOOST_CHECK_EQUAL(m_logs[0].topics[0], dev::sha3(string("Deposit(uint256,bytes,uint256)"))); + BOOST_CHECK_EQUAL(m_logs[0].topics[0], dev::keccak256(string("Deposit(uint256,bytes,uint256)"))); } BOOST_AUTO_TEST_CASE(event_really_lots_of_data_from_storage) @@ -2707,7 +2707,7 @@ BOOST_AUTO_TEST_CASE(event_really_lots_of_data_from_storage) BOOST_CHECK_EQUAL(m_logs[0].address, m_contractAddress); BOOST_CHECK(m_logs[0].data == encodeArgs(10, 0x60, 15, 3, string("ABC"))); BOOST_REQUIRE_EQUAL(m_logs[0].topics.size(), 1); - BOOST_CHECK_EQUAL(m_logs[0].topics[0], dev::sha3(string("Deposit(uint256,bytes,uint256)"))); + BOOST_CHECK_EQUAL(m_logs[0].topics[0], dev::keccak256(string("Deposit(uint256,bytes,uint256)"))); } BOOST_AUTO_TEST_CASE(event_indexed_string) @@ -2738,11 +2738,11 @@ BOOST_AUTO_TEST_CASE(event_indexed_string) dynx[i] = i; BOOST_CHECK(m_logs[0].data == bytes()); BOOST_REQUIRE_EQUAL(m_logs[0].topics.size(), 3); - BOOST_CHECK_EQUAL(m_logs[0].topics[1], dev::sha3(dynx)); - BOOST_CHECK_EQUAL(m_logs[0].topics[2], dev::sha3( + BOOST_CHECK_EQUAL(m_logs[0].topics[1], dev::keccak256(dynx)); + BOOST_CHECK_EQUAL(m_logs[0].topics[2], dev::keccak256( encodeArgs(u256(4), u256(5), u256(6), u256(7)) )); - BOOST_CHECK_EQUAL(m_logs[0].topics[0], dev::sha3(string("E(string,uint256[4])"))); + BOOST_CHECK_EQUAL(m_logs[0].topics[0], dev::keccak256(string("E(string,uint256[4])"))); } BOOST_AUTO_TEST_CASE(empty_name_input_parameter_with_named_one) @@ -2784,7 +2784,7 @@ BOOST_AUTO_TEST_CASE(sha3_multiple_arguments) compileAndRun(sourceCode); BOOST_CHECK(callContractFunction("foo(uint256,uint256,uint256)", 10, 12, 13) == encodeArgs( - dev::sha3( + dev::keccak256( toBigEndian(u256(10)) + toBigEndian(u256(12)) + toBigEndian(u256(13))))); @@ -2802,7 +2802,7 @@ BOOST_AUTO_TEST_CASE(sha3_multiple_arguments_with_numeric_literals) compileAndRun(sourceCode); BOOST_CHECK(callContractFunction("foo(uint256,uint16)", 10, 12) == encodeArgs( - dev::sha3( + dev::keccak256( toBigEndian(u256(10)) + bytes{0x0, 0xc} + bytes(1, 0x91)))); @@ -2823,10 +2823,10 @@ BOOST_AUTO_TEST_CASE(sha3_multiple_arguments_with_string_literals) })"; compileAndRun(sourceCode); - BOOST_CHECK(callContractFunction("foo()") == encodeArgs(dev::sha3("foo"))); + BOOST_CHECK(callContractFunction("foo()") == encodeArgs(dev::keccak256("foo"))); BOOST_CHECK(callContractFunction("bar(uint256,uint16)", 10, 12) == encodeArgs( - dev::sha3( + dev::keccak256( toBigEndian(u256(10)) + bytes{0x0, 0xc} + bytes(1, 0x91) + @@ -2868,7 +2868,7 @@ BOOST_AUTO_TEST_CASE(iterated_sha3_with_bytes) )"; compileAndRun(sourceCode); BOOST_CHECK(callContractFunction("foo()") == encodeArgs( - u256(dev::sha3(bytes{'b'} + dev::sha3("xyz").asBytes() + bytes{'a'})) + u256(dev::keccak256(bytes{'b'} + dev::keccak256("xyz").asBytes() + bytes{'a'})) )); } @@ -3031,9 +3031,9 @@ BOOST_AUTO_TEST_CASE(bytes_from_calldata_to_memory) } )"; compileAndRun(sourceCode); - bytes calldata1 = FixedHash<4>(dev::sha3("f()")).asBytes() + bytes(61, 0x22) + bytes(12, 0x12); + bytes calldata1 = FixedHash<4>(dev::keccak256("f()")).asBytes() + bytes(61, 0x22) + bytes(12, 0x12); sendMessage(calldata1, false); - BOOST_CHECK(m_output == encodeArgs(dev::sha3(bytes{'a', 'b', 'c'} + calldata1))); + BOOST_CHECK(m_output == encodeArgs(dev::keccak256(bytes{'a', 'b', 'c'} + calldata1))); } BOOST_AUTO_TEST_CASE(call_forward_bytes) @@ -3407,8 +3407,8 @@ BOOST_AUTO_TEST_CASE(bytes_in_arguments) )"; compileAndRun(sourceCode); - string innercalldata1 = asString(FixedHash<4>(dev::sha3("f(uint256,uint256)")).asBytes() + encodeArgs(8, 9)); - string innercalldata2 = asString(FixedHash<4>(dev::sha3("g(uint256)")).asBytes() + encodeArgs(3)); + string innercalldata1 = asString(FixedHash<4>(dev::keccak256("f(uint256,uint256)")).asBytes() + encodeArgs(8, 9)); + string innercalldata2 = asString(FixedHash<4>(dev::keccak256("g(uint256)")).asBytes() + encodeArgs(3)); bytes calldata = encodeArgs( 12, 32 * 4, u256(32 * 4 + 32 + (innercalldata1.length() + 31) / 32 * 32), 13, u256(innercalldata1.length()), innercalldata1, @@ -4686,7 +4686,7 @@ BOOST_AUTO_TEST_CASE(reusing_memory) } )"; compileAndRun(sourceCode, 0, "Main"); - BOOST_REQUIRE(callContractFunction("f(uint256)", 0x34) == encodeArgs(dev::sha3(dev::toBigEndian(u256(0x34))))); + BOOST_REQUIRE(callContractFunction("f(uint256)", 0x34) == encodeArgs(dev::keccak256(dev::toBigEndian(u256(0x34))))); } BOOST_AUTO_TEST_CASE(return_string) diff --git a/test/libsolidity/SolidityExecutionFramework.h b/test/libsolidity/SolidityExecutionFramework.h index 6cf7e0ee..1cd45603 100644 --- a/test/libsolidity/SolidityExecutionFramework.h +++ b/test/libsolidity/SolidityExecutionFramework.h @@ -105,7 +105,7 @@ public: template <class... Args> bytes const& callContractFunctionWithValue(std::string _sig, u256 const& _value, Args const&... _arguments) { - FixedHash<4> hash(dev::sha3(_sig)); + FixedHash<4> hash(dev::keccak256(_sig)); sendMessage(hash.asBytes() + encodeArgs(_arguments...), false, _value); return m_output; } diff --git a/test/libsolidity/SolidityNameAndTypeResolution.cpp b/test/libsolidity/SolidityNameAndTypeResolution.cpp index b8c64336..76141f41 100644 --- a/test/libsolidity/SolidityNameAndTypeResolution.cpp +++ b/test/libsolidity/SolidityNameAndTypeResolution.cpp @@ -154,7 +154,7 @@ static FunctionTypePointer retrieveFunctionBySignature( std::string const& _signature ) { - FixedHash<4> hash(dev::sha3(_signature)); + FixedHash<4> hash(dev::keccak256(_signature)); return _contract->interfaceFunctions()[hash]; } diff --git a/test/libsolidity/SolidityOptimizer.cpp b/test/libsolidity/SolidityOptimizer.cpp index 206f23fb..562b7859 100644 --- a/test/libsolidity/SolidityOptimizer.cpp +++ b/test/libsolidity/SolidityOptimizer.cpp @@ -805,7 +805,7 @@ BOOST_AUTO_TEST_CASE(cse_empty_sha3) Instruction::SHA3 }; checkCSE(input, { - u256(sha3(bytesConstRef())) + u256(dev::keccak256(bytesConstRef())) }); } @@ -823,7 +823,7 @@ BOOST_AUTO_TEST_CASE(cse_partial_sha3) u256(0xabcd) << (256 - 16), u256(0), Instruction::MSTORE, - u256(sha3(bytes{0xab, 0xcd})) + u256(dev::keccak256(bytes{0xab, 0xcd})) }); } |