OpenCBDC Transaction Processor
Loading...
Searching...
No Matches
parsec/agent/runners/evm/hash.cpp
Go to the documentation of this file.
1// Copyright (c) 2021 MIT Digital Currency Initiative,
2// Federal Reserve Bank of Boston
3// Distributed under the MIT software license, see the accompanying
4// file COPYING or http://www.opensource.org/licenses/mit-license.php.
5
6#include "hash.hpp"
7
8#include <cstring>
9#include <ethash/keccak.hpp>
10#include <iomanip>
11#include <vector>
12
13namespace cbdc {
14 auto keccak_data(const void* data, size_t len) -> hash_t {
15 hash_t ret{};
16 auto data_vec = std::vector<unsigned char>(len);
17 std::memcpy(data_vec.data(), data, len);
18 auto resp = ethash::keccak256(data_vec.data(), data_vec.size());
19 std::memcpy(ret.data(), &resp, sizeof(resp));
20 return ret;
21 }
22}
std::array< unsigned char, cbdc::hash_size > hash_t
SHA256 hash container.
auto keccak_data(const void *data, size_t len) -> hash_t
Calculates the Keccak256 hash of the specified data.