Skip to content

Commit

Permalink
Add ecAddG2 precompile (#211)
Browse files Browse the repository at this point in the history
* add ecAddG2 precompile

* add fp2 arithmetics

* fix jacobian add

* update documentation

* add g2JacobianDouble

* add valid tests

* fix point double

* add case b = -a

* fix typo

* remove console_logs

* add tests for out of field order

* add ecAddG2 precompile

* add gas reports

* change to camel-case

* fmt

* fix variables names

* add sage file to generate valid points

* add ecadd2 report to build.rs
  • Loading branch information
ColoCarletti authored Feb 5, 2024
1 parent 9469bb6 commit 787f7fe
Show file tree
Hide file tree
Showing 7 changed files with 1,658 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .test-node-subtree/scripts/refresh_contracts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ for contract in "${contracts[@]}"; do
cp $SRC_DIR/$contract.sol/$contract.json $DST_DIR
done

precompiles=("EcAdd" "EcMul" "EcPairing" "Ecrecover" "Keccak256" "ModExp" "P256VERIFY" "SHA256" "secp256k1VERIFY" "EcMulG2")
precompiles=("EcAdd" "EcMul" "EcPairing" "Ecrecover" "Keccak256" "ModExp" "P256VERIFY" "SHA256" "secp256k1VERIFY" "EcAddG2" "EcMulG2")

for precompile in "${precompiles[@]}"; do
cp etc/system-contracts/contracts/precompiles/artifacts/$precompile.yul/$precompile.yul.zbin $DST_DIR
Expand Down
11 changes: 11 additions & 0 deletions .test-node-subtree/src/deps/system_contracts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ pub const ECADD_PRECOMPILE_ADDRESS: Address = H160([
0x00, 0x00, 0x00, 0x06,
]);

/// The `ecAddG2` system contract address.
pub const ECADD_G2_PRECOMPILE_ADDRESS: Address = H160([
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x0A,
]);

/// The `ecMul` system contract address.
pub const ECMUL_PRECOMPILE_ADDRESS: Address = H160([
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
Expand Down Expand Up @@ -156,6 +162,11 @@ pub static COMPILED_IN_SYSTEM_CONTRACTS: Lazy<Vec<DeployedContract>> = Lazy::new
ECADD_PRECOMPILE_ADDRESS,
include_bytes!("contracts/EcAdd.yul.zbin").to_vec(),
),
(
"ECADD_G2_PRECOMPILE_ADDRESS",
ECADD_G2_PRECOMPILE_ADDRESS,
include_bytes!("contracts/EcAddG2.yul.zbin").to_vec(),
),
(
"ECMUL_PRECOMPILE_ADDRESS",
ECMUL_PRECOMPILE_ADDRESS,
Expand Down
602 changes: 602 additions & 0 deletions precompiles/EcAddG2.yul

Large diffs are not rendered by default.

Loading

0 comments on commit 787f7fe

Please sign in to comment.