-
Notifications
You must be signed in to change notification settings - Fork 294
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
92 additions
and
376 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// evmone: Fast Ethereum Virtual Machine implementation | ||
// Copyright 2022 The evmone Authors. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
#pragma once | ||
|
||
#include <ethash/keccak.hpp> | ||
#include <evmc/evmc.hpp> | ||
#include <evmc/hex.hpp> | ||
#include <cstring> | ||
|
||
namespace evmone | ||
{ | ||
using evmc::bytes; | ||
using evmc::bytes_view; | ||
|
||
/// Better than ethash::hash256 because has some additional handy constructors. | ||
using hash256 = evmc::bytes32; | ||
|
||
inline hash256 keccak256(bytes_view data) noexcept | ||
{ | ||
const auto eh = ethash::keccak256(data.data(), data.size()); | ||
hash256 h; | ||
std::memcpy(h.bytes, eh.bytes, sizeof(h)); // TODO: Use std::bit_cast. | ||
return h; | ||
} | ||
} // namespace evmone |
Oops, something went wrong.