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

add hash blobData type 3 #347

Draft
wants to merge 1 commit into
base: develop-feijoa
Choose a base branch
from
Draft
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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@
"license": "UNLICENSED",
"dependencies": {
"@0xpolygonhermez/zkasmcom": "github:0xPolygonHermez/zkasmcom#develop-feijoa",
"@0xpolygonhermez/zkevm-commonjs": "github:0xpolygonhermez/zkevm-commonjs#feature/fix-computez",
"@0xpolygonhermez/zkevm-commonjs": "github:0xpolygonhermez/zkevm-commonjs#feature/add-blob-type-3",
"@grpc/grpc-js": "^1.8.14",
"chalk": "^3.0.0",
"circomlib": "^2.0.3",
Expand Down
13 changes: 12 additions & 1 deletion src/sm/sm_main/sm_main_exec.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ const Prints = require("./debug/prints");
const StatsTracer = require("./debug/stats-tracer");
const Constants = require('./const-sm-main-exec');
const Helpers = require("../../helpers.js");
const { computeBlobL2HashKData, computeBlobL2HashPData } = require("@0xpolygonhermez/zkevm-commonjs/src/blob-inner/blob-utils.js");

const twoTo255 = Scalar.shl(Scalar.one, 255);
const twoTo256 = Scalar.shl(Scalar.one, 256);
Expand Down Expand Up @@ -158,13 +159,23 @@ module.exports = async function execute(pols, input, rom, config = {}, metadata

} else if (blob && (input.blobType === ConstantsBlob.BLOB_TYPE.CALLDATA || input.blobType === ConstantsBlob.BLOB_TYPE.FORCED)) {
// Load keccak256BlobData into DB
const blobL2HashData = await ethers.utils.keccak256(input.blobData);
const blobL2HashData = await computeBlobL2HashKData(input.blobData);
if (typeof input.blobL2HashData === 'undefined') {
input.blobL2HashData = blobL2HashData;
} else if (input.blobL2HashData !== blobL2HashData) {
throw new Error('input.blobL2HashData != keccak(input.blobData)');
}
await db.setProgram(stringToH4(blobL2HashData), hexString2byteArray(input.blobData));

} else if (blob && input.blobType === ConstantsBlob.BLOB_TYPE.VALIDIUM) {
// Load poseidonBlobData into DB
const blobL2HashData = await computeBlobL2HashPData(input.blobData);
if (typeof input.blobL2HashData === 'undefined') {
input.blobL2HashData = blobL2HashData;
} else if (input.blobL2HashData !== blobL2HashData) {
throw new Error('input.blobL2HashData != poseidon(input.blobData)');
}
await db.setProgram(stringToH4(blobL2HashData), hexString2byteArray(input.blobData));
}
// load smt
const smt = new SMT(db, poseidon, Fr);
Expand Down
Loading