Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix input/output size in staticcall for addition and scalar_mul #1368

Merged
merged 3 commits into from
Apr 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelogs/unreleased/1368-dark64
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix staticcall input/output size in `addition` & `scalar_mul`
4 changes: 2 additions & 2 deletions zokrates_proof_systems/src/solidity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,7 @@ library Pairing {
input[3] = p2.Y;
bool success;
assembly {
success := staticcall(sub(gas(), 2000), 6, input, 0xc0, r, 0x60)
success := staticcall(sub(gas(), 2000), 6, input, 0x80, r, 0x40)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://github.com/ethereum/go-ethereum/blob/master/core/vm/contracts.go#L446

Bn256Add takes 128 bytes (0x80) and outputs G1 which is 64 bytes (0x40)

// Use "invalid" to make gas estimation work
switch success case 0 { invalid() }
}
Expand All @@ -481,7 +481,7 @@ library Pairing {
input[2] = s;
bool success;
assembly {
success := staticcall(sub(gas(), 2000), 7, input, 0x80, r, 0x60)
success := staticcall(sub(gas(), 2000), 7, input, 0x60, r, 0x40)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://github.com/ethereum/go-ethereum/blob/master/core/vm/contracts.go#L488

Bn256ScalarMul takes 96 bytes (0x60) and outputs G1 which is 64 bytes (0x40)

// Use "invalid" to make gas estimation work
switch success case 0 { invalid() }
}
Expand Down
Loading