Skip to content

Eip4844Errors

error{
    ExpectedZByte,
    ExpectJsonFile,
    ExpectedBlobData,
    SetupMustBeInitialized,
    SetupAlreadyLoaded,
    InvalidProof,
    InvalidG1Length,
    InvalidG2Length,
    InvalidSize,
}

Blob

[c.BYTES_PER_BLOB]u8

KZGProof

[c.BYTES_PER_PROOF]u8

KZGCommitment

[c.BYTES_PER_COMMITMENT]u8

KZGSettings

c.KZGSettings

KZGProofResult

Properties

struct {
  proof: KZGProof
  y: [c.BYTES_PER_FIELD_ELEMENT]u8
}

JsonTrustedSetup

Properties

struct {
  g1_monomial: []const []const u8
  g2_monomial: []const []const u8
}

Sidecar

Properties

struct {
  blob: Blob
  commitment: KZGCommitment
  proof: KZGProof
}

Sidecars

[]const Sidecar

TransformJsonFileToBytes

Transform the g1_monomial and g2_monomial into their g1 and g2 points representation so that they can be used by the initTrustedSetup method

Signature

pub fn transformJsonFileToBytes(self: *KZG4844, allocator: Allocator, path: []const u8) !Tuple(&[_]type{ [][BYTES_PER_G1_POINT]u8, []const [BYTES_PER_G2_POINT]u8 })

InitTrustedSetup

Inits the trusted setup from a 2d array of g1 and g2 bytes.

Signature

pub fn initTrustedSetup(self: *KZG4844, g1: [][BYTES_PER_G1_POINT]u8, g2: [][BYTES_PER_G2_POINT]u8) !void

InitTrustedSetupFromJsonFile

Inits the trusted setup from a json file

Signature

pub fn initTrustedSetupFromJsonFile(self: *KZG4844, allocator: Allocator, path: []const u8) !void

InitTrustedSetupFromFile

Inits the trusted setup from a trusted setup file.

Signature

pub fn initTrustedSetupFromFile(self: *KZG4844, file_path: [*:0]const u8) !void

DeinitTrustSetupFile

Frees the trusted setup. Will panic if the setup was never loaded.

Signature

pub fn deinitTrustSetupFile(self: *KZG4844) void

BytesToBlobs

Converts slices to blobs. Caller owns the allocated memory.

Signature

pub fn bytesToBlobs(self: *KZG4844, allocator: Allocator, bytes: []const u8) ![]const Blob

BytesToBlob

Converts an array of blob sized bytes into a Blob

Signature

pub fn bytesToBlob(self: *KZG4844, data: [c.BYTES_PER_BLOB]u8) !Blob

SideCarOpts

Properties

struct {
  data: ?[]const u8 = null
  blobs: ?[]const Blob = null
  commitments: ?[]const KZGCommitment = null
  proofs: ?[]const KZGProof = null
  z_bytes: ?[]const [32]u8 = null
}

ToSidecars

Bundles together the blobs, commitments and proofs into a sidecar.

Signature

pub fn toSidecars(self: *KZG4844, allocator: Allocator, opts: SideCarOpts) !Sidecars

SidecarsToVersionedHash

Creates the blobVersioned hashes

Signature

pub fn sidecarsToVersionedHash(self: *KZG4844, allocator: Allocator, sidecars: Sidecars, versions: []const ?u8) ![]const [Sha256.digest_length]u8

BlobsToKZGCommitment

Converts blobs to KZGCommitments. Caller owns the allocated memory.

Signature

pub fn blobsToKZGCommitment(self: *KZG4844, allocator: Allocator, blobs: []const Blob) ![]const KZGCommitment

CommitmentsToVersionedHash

Hashes a slice of KZGCommitments to their version hashes

Signature

pub fn commitmentsToVersionedHash(self: *KZG4844, allocator: Allocator, commitments: []const KZGCommitment, version: ?u8) ![]const [Sha256.digest_length]u8

CommitmentToVersionedHash

Hashes a KZGCommitment.

Signature

pub fn commitmentToVersionedHash(self: *KZG4844, commitment: KZGCommitment, version: ?u8) ![Sha256.digest_length]u8

BlobsToKZGProofs

Computes blobs proof bytes

Signature

pub fn blobsToKZGProofs(self: *KZG4844, allocator: Allocator, blobs: []const Blob, commitments: []const KZGCommitment) ![]const KZGProof

BlobToKZGCommitment

Converts a blob to a KZGCommitment.

Signature

pub fn blobToKZGCommitment(self: *KZG4844, blob: Blob) !KZGCommitment

BlobToKZGProof

Computes blob proof.

Signature

pub fn blobToKZGProof(self: *KZG4844, blob: Blob, commitment: KZGCommitment) !KZGProof

ComputeKZGProof

Computes a given KZGProof from a blob

Signature

pub fn computeKZGProof(self: *KZG4844, blob: Blob, bytes: [32]u8) !KZGProofResult

VerifyKZGProof

Verifies a KZGProof from a commitment.

Signature

pub fn verifyKZGProof(self: *KZG4844, commitment_bytes: KZGCommitment, z_bytes: [32]u8, y_bytes: [32]u8, proof_bytes: KZGProof) !bool

VerifyBlobKZGProof

Verifies a Blob KZG Proof from a commitment.

Signature

pub fn verifyBlobKZGProof(self: *KZG4844, blob: Blob, commitment_bytes: KZGCommitment, proof_bytes: KZGProof) !bool

VerifyBlobKZGProofBatch

Verifies a batch of blob KZG proofs from an array commitments and blobs.

Signature

pub fn verifyBlobKZGProofBatch(self: *KZG4844, blobs: []c.Blob, commitment_bytes: []c.KZGCommitment, proof_bytes: []c.KZGProof) !bool