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

perf: use abi.encodePacked() #11

Open
wants to merge 2 commits into
base: v2
Choose a base branch
from
Open
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
27 changes: 27 additions & 0 deletions contracts/.gas-snapshot
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
·------------------------------------------------------|---------------------------|-------------|-----------------------------·
| Solc version: 0.8.18 · Optimizer enabled: true · Runs: 200 · Block limit: 30000000 gas │
·······················································|···························|·············|······························
| Methods │
·····················|·································|·············|·············|·············|···············|··············
| Contract · Method · Min · Max · Avg · # calls · usd (avg) │
·····················|·································|·············|·············|·············|···············|··············
| GrandSumVerifier · verifyProof · - · - · 271155 · 2 · - │
·····················|·································|·············|·············|·············|···············|··············
| Summa · submitCommitment · - · - · 1068958 · 5 · - │
·····················|·································|·············|·············|·············|···············|··············
| Summa · submitProofOfAddressOwnership · - · - · 700479 · 3 · - │
·····················|·································|·············|·············|·············|···············|··············
| Deployments · · % of limit · │
·······················································|·············|·············|·············|···············|··············
| GrandSumVerifier · - · - · 277127 · 0.9 % · - │
·······················································|·············|·············|·············|···············|··············
| InclusionVerifier · - · - · 284887 · 0.9 % · - │
·······················································|·············|·············|·············|···············|··············
| src/DummyVerifyingKey.sol:Halo2VerifyingKey · - · - · 266321 · 0.9 % · - │
·······················································|·············|·············|·············|···············|··············
| src/VerifyingKey.sol:Halo2VerifyingKey · - · - · 350335 · 1.2 % · - │
·······················································|·············|·············|·············|···············|··············
| Summa · - · - · 1915414 · 6.4 % · - │
·······················································|·············|·············|·············|···············|··············
| Verifier · - · - · 1907494 · 6.4 % · - │
·------------------------------------------------------|-------------|-------------|-------------|---------------|-------------·
3 changes: 3 additions & 0 deletions contracts/hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ module.exports = {
gasReporter: {
currency: "USD",
gasPrice: 30,
enabled: process.env.REPORT_GAS ? true : false,
outputFile: ".gas-snapshot",
noColors: true
},
solidity: {
compilers: [
Expand Down
8 changes: 1 addition & 7 deletions contracts/src/Summa.sol
Original file line number Diff line number Diff line change
Expand Up @@ -272,13 +272,7 @@ contract Summa is Ownable {

bytes memory snarkProof = commitments[timestamp];

bytes memory combinedProofs = new bytes(snarkProof.length + inclusionProof.length);
for (uint256 i = 0; i < inclusionProof.length; i++) {
combinedProofs[i] = inclusionProof[i];
}
for (uint256 i = 0; i < snarkProof.length; i++) {
combinedProofs[i + inclusionProof.length] = snarkProof[i];
}
bytes memory combinedProofs = abi.encodePacked(inclusionProof, snarkProof);

return inclusionVerifier.verifyProof(verifyingKey, combinedProofs, challenges, values);
}
Expand Down