Ethereum  PoC-8
The C++ Implementation of Ethereum
SHA3.cpp
Go to the documentation of this file.
1 /*
2  This file is part of cpp-ethereum.
3 
4  cpp-ethereum is free software: you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation, either version 3 of the License, or
7  (at your option) any later version.
8 
9  cpp-ethereum is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with cpp-ethereum. If not, see <http://www.gnu.org/licenses/>.
16 */
17 
18 #include "SHA3.h"
19 #include "RLP.h"
20 
21 #include <ethash/keccak.hpp>
22 
23 namespace dev
24 {
27 
28 bool sha3(bytesConstRef _input, bytesRef o_output) noexcept
29 {
30  if (o_output.size() != 32)
31  return false;
32  ethash::hash256 h = ethash::keccak256(_input.data(), _input.size());
33  bytesConstRef{h.bytes, 32}.copyTo(o_output);
34  return true;
35 }
36 } // namespace dev
dev::vector_ref< byte const >
dev::sha3
bool sha3(bytesConstRef _input, bytesRef o_output) noexcept
Definition: SHA3.cpp:28
dev::vector_ref::copyTo
void copyTo(vector_ref< typename std::remove_const< _T >::type > _t) const
Copies the contents of this vector_ref to the contents of _t, up to the max size of _t.
Definition: vector_ref.h:67
dev::EmptySHA3
h256 const EmptySHA3
Definition: SHA3.cpp:25
dev::FixedHash< 32 >
dev::hash256
h256 hash256(BytesMap const &_s)
Definition: TrieHash.cpp:107
SHA3.h
dev::bytesConstRef
vector_ref< byte const > bytesConstRef
Definition: Common.h:74
dev
Definition: Address.cpp:21
dev::rlpList
bytes rlpList()
Export a list of items in RLP format, returning a byte array.
Definition: RLP.h:456
dev::EmptyListSHA3
h256 const EmptyListSHA3
Definition: SHA3.cpp:26
RLP.h