MCPcopy Create free account
hub / github.com/QuipNetwork/cpp-sdk / keccak256

Function keccak256

src/cli.cpp:22–32  ·  view source on GitHub ↗

Keccak-256 hash function implementation for hashsigs-cpp

Source from the content-addressed store, hash-verified

20
21// Keccak-256 hash function implementation for hashsigs-cpp
22static std::array<uint8_t, 32> keccak256(const std::vector<uint8_t> &data) {
23 Keccak keccak(Keccak::Keccak256);
24 std::string hash = keccak(data.data(), data.size());
25
26 std::array<uint8_t, 32> result;
27 for (size_t i = 0; i < 32; ++i) {
28 std::string byte_str = hash.substr(i * 2, 2);
29 result[i] = static_cast<uint8_t>(std::stoi(byte_str, nullptr, 16));
30 }
31 return result;
32}
33
34// Helper: parse a hex string into a PublicKey (array<uint8_t, 32>)
35static PublicKey parsePublicKeyFromHex(const std::string &hex) {

Callers 4

recoverKeyPairMethod · 0.85
handleTransferMethod · 0.85
handleExecuteMethod · 0.85
handleChangePqOwnerMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected