-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: jfldde <[email protected]> Co-authored-by: okkothejawa <[email protected]> Co-authored-by: eyusufatik <[email protected]> Co-authored-by: Roman Proskuryakoff <[email protected]>
- Loading branch information
1 parent
9cf26ad
commit 8c812ba
Showing
10 changed files
with
415 additions
and
13 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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 @@ | ||
[{"inputs":[{"internalType":"bytes","name":"input","type":"bytes"}],"name":"verifyPointEvaluation","outputs":[{"internalType":"bool","name":"success","type":"bool"}],"stateMutability":"nonpayable","type":"function"}] |
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 @@ | ||
6080604052348015600e575f5ffd5b506103208061001c5f395ff3fe608060405234801561000f575f5ffd5b5060043610610029575f3560e01c806325a05f401461002d575b5f5ffd5b610047600480360381019061004291906101a0565b61005d565b6040516100549190610205565b60405180910390f35b5f60c083839050146100a4576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161009b90610278565b60405180910390fd5b6060600a73ffffffffffffffffffffffffffffffffffffffff1684846040516100ce9291906102d2565b5f60405180830381855afa9150503d805f8114610106576040519150601f19603f3d011682016040523d82523d5f602084013e61010b565b606091505b5080925081935050505f815114610120575f5ffd5b60408101515f5581610130575f5ffd5b5092915050565b5f5ffd5b5f5ffd5b5f5ffd5b5f5ffd5b5f5ffd5b5f5f83601f8401126101605761015f61013f565b5b8235905067ffffffffffffffff81111561017d5761017c610143565b5b60208301915083600182028301111561019957610198610147565b5b9250929050565b5f5f602083850312156101b6576101b5610137565b5b5f83013567ffffffffffffffff8111156101d3576101d261013b565b5b6101df8582860161014b565b92509250509250929050565b5f8115159050919050565b6101ff816101eb565b82525050565b5f6020820190506102185f8301846101f6565b92915050565b5f82825260208201905092915050565b7f496e76616c696420696e7075742073697a6500000000000000000000000000005f82015250565b5f61026260128361021e565b915061026d8261022e565b602082019050919050565b5f6020820190508181035f83015261028f81610256565b9050919050565b5f81905092915050565b828183375f83830152505050565b5f6102b98385610296565b93506102c68385846102a0565b82840190509392505050565b5f6102de8284866102ae565b9150819050939250505056fea264697066735822122052f3d3eafaae24a10a4cb029d517a2fc7b949c9ee79750ca303d13aba9fb158264736f6c634300081b0033 |
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,21 @@ | ||
|
||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.26; | ||
|
||
contract KZGPointEvaluationCaller { | ||
/// @notice Calls the 0x0A precompile to perform point evaluation | ||
/// @param input A 192-byte input representing the polynomial versioned hash, commitment, point, and proof | ||
function verifyPointEvaluation( | ||
bytes calldata input // 192 bytes | ||
) external returns (bool success) { | ||
require(input.length == 192, "Invalid input size"); | ||
bytes memory out; | ||
(success, out) = address(10).staticcall(input); | ||
require(out.length == 0); | ||
// Write the 32 bytes of out to first storage slot | ||
assembly { | ||
sstore(0, mload(add(out, 64))) | ||
} | ||
require(success); | ||
} | ||
} |
49 changes: 49 additions & 0 deletions
49
crates/evm/src/smart_contracts/kzg_point_evaluation_caller.rs
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,49 @@ | ||
use alloy_primitives::Bytes; | ||
use alloy_sol_types::{sol, SolCall}; | ||
|
||
use super::TestContract; | ||
|
||
// KZGPointEvaluationCallerContract wrapper. | ||
sol! { | ||
#[sol(abi)] | ||
KZGPointEvaluationCaller, | ||
"./src/evm/test_data/KZGPointEvaluationCaller.abi" | ||
} | ||
|
||
/// KZGPointEvaluationContract wrapper. | ||
pub struct KZGPointEvaluationCallerContract { | ||
bytecode: Vec<u8>, | ||
} | ||
|
||
impl Default for KZGPointEvaluationCallerContract { | ||
fn default() -> Self { | ||
let bytecode = { | ||
let bytecode_hex = | ||
include_str!("../../../evm/src/evm/test_data/KZGPointEvaluationCaller.bin"); | ||
hex::decode(bytecode_hex).unwrap() | ||
}; | ||
|
||
Self { bytecode } | ||
} | ||
} | ||
|
||
impl TestContract for KZGPointEvaluationCallerContract { | ||
fn byte_code(&self) -> Vec<u8> { | ||
self.byte_code() | ||
} | ||
} | ||
|
||
impl KZGPointEvaluationCallerContract { | ||
/// KZGPointEvaluation bytecode. | ||
pub fn byte_code(&self) -> Vec<u8> { | ||
self.bytecode.clone() | ||
} | ||
|
||
/// Claims the gift. | ||
pub fn call_kzg_point_evaluation( | ||
&self, | ||
input: Bytes, // 192 bytes | ||
) -> Vec<u8> { | ||
KZGPointEvaluationCaller::verifyPointEvaluationCall { input }.abi_encode() | ||
} | ||
} |
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
Oops, something went wrong.