-
Notifications
You must be signed in to change notification settings - Fork 28
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
question: are the blobVersionedHash and commitment hash always unique? #337
Comments
Okay, i figured out that the blob hashes are the same if the blob content is the same, cool. BUT, how can we calculate these hashes? I read that it's sha256 of the KZG, but what specifically? Can we do it from the hex data, without any much processing? cc @PJColombo 🤔 |
okay, figure that out too haha... 😆 import { sha256, blobsToCommitments, toBlobs, setupKzg, stringToHex } from "viem";
// import { mainnetTrustedSetupPath } from "viem/node";
import * as cKzg from "c-kzg";
export const kzg = setupKzg(
cKzg,
// mainnetTrustedSetupPath
"./node_modules/viem/trusted-setups/mainnet.json"
);
const blobs = toBlobs({ data: stringToHex("data:,hello world") });
const commitments = blobsToCommitments({ blobs, kzg });
// demo blob
const kzg_commitment = `0x94b54333b009e1e0f12f46282dfd786d5a9a8c17090341430fe265c5cfd493372459d6ec2b33d6af7cbcef92a934e9eb`;
const blob_hash = `0x01b0eb9326690d1dc82e34a5eccefca7713d078d1d0a2a56521d2cbab9ca820a`;
const sha_of_comm = sha256(kzg_commitment).slice(2); // first 2 are `0x`
console.log("commitments", commitments);
console.log(sha_of_comm);
console.log(blob_hash);
console.log(blob_hash === "0x01" + sha_of_comm.slice(2)); for someone else if needed |
Hi @tunnckoCore. Again, sorry for the late reply but I suppose you didn't need me at all to begin with 😅. Yes, everything you said it's correct. A blob hash is the versioned hash of the kzg commitment. The version is contained in the first byte of the hash and the rest of it contains the hashed commitment (see here). You can find the rationale behind it here You can find the rationale behind using kzg commitments here.
Our database schema defines a The many-to-many relational table Currently, our |
I mean, if i send 2 transactions with the same blob, will their blob hash and or commitment match?
How you track "unique blobs"? Can we have such endpoint?
I kinda want some endpoint to check based on
versioneHash
,transaction hash
, or the hexed data that's submitted.The text was updated successfully, but these errors were encountered: