-
Notifications
You must be signed in to change notification settings - Fork 401
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
timemarkovqtum
committed
Sep 26, 2024
1 parent
e40bd1a
commit 20eb80c
Showing
5 changed files
with
60 additions
and
0 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,31 @@ | ||
#include <libdevcrypto/LibKzg.h> | ||
#include <evmone_precompiles/kzg.hpp> | ||
|
||
using namespace std; | ||
using namespace dev; | ||
using namespace dev::crypto; | ||
|
||
pair<bool, bytes> dev::crypto::point_evaluation_execute(dev::bytesConstRef input) | ||
{ | ||
bytes output(64, 0); | ||
size_t output_size = output.size(); | ||
size_t input_size = input.size(); | ||
assert(output_size >= 64); | ||
if (input_size != 192) | ||
return {false, bytes{}}; | ||
|
||
const auto r = evmone::crypto::kzg_verify_proof(reinterpret_cast<const std::byte*>(&input[0]), | ||
reinterpret_cast<const std::byte*>(&input[32]), | ||
reinterpret_cast<const std::byte*>(&input[64]), | ||
reinterpret_cast<const std::byte*>(&input[96]), | ||
reinterpret_cast<const std::byte*>(&input[96 + 48])); | ||
|
||
if (!r) | ||
return {false, bytes{}}; | ||
|
||
// Return FIELD_ELEMENTS_PER_BLOB and BLS_MODULUS as padded 32 byte big endian values | ||
// as required by the EIP-4844. | ||
intx::be::unsafe::store(output.data(), evmone::crypto::FIELD_ELEMENTS_PER_BLOB); | ||
intx::be::unsafe::store(output.data() + 32, evmone::crypto::BLS_MODULUS); | ||
return {true, output}; | ||
} |
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,13 @@ | ||
#pragma once | ||
|
||
#include <libdevcore/Common.h> | ||
|
||
namespace dev | ||
{ | ||
namespace crypto | ||
{ | ||
|
||
std::pair<bool, bytes> point_evaluation_execute(bytesConstRef _in); | ||
|
||
} | ||
} |
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