@tevm/voltaire / crypto/KZG
crypto/KZG
Classes
KzgError
Defined in: src/crypto/KZG/errors.ts:13 Base KZG error for polynomial commitment operationsSee
https://voltaire.tevm.sh/crypto/kzg for KZG documentationSince
0.0.0Extends
Extended by
Constructors
Constructor
new KzgError(Defined in: src/crypto/KZG/errors.ts:14message,options?):KzgError
Parameters
message
string
options?
cause?
Error
code?
string
context?
Record<string, unknown>
docsPath?
string
Returns
KzgError
Overrides
CryptoError.constructor
Properties
cause?
Defined in: src/primitives/errors/AbstractError.ts:56 Root cause of this error (for error chaining)optionalcause:Error
Inherited from
CryptoError.cause
code
code: string
Defined in: src/primitives/errors/AbstractError.ts:39
Machine-readable error code for programmatic handling
Example
Inherited from
CryptoError.code
context?
Defined in: src/primitives/errors/AbstractError.ts:45 Additional context metadata for debuggingoptionalcontext:Record<string,unknown>
Example
Inherited from
CryptoError.context
docsPath?
Defined in: src/primitives/errors/AbstractError.ts:51 Path to documentation for this erroroptionaldocsPath:string
Example
Inherited from
CryptoError.docsPath
Methods
getErrorChain()
getErrorChain(): string
Defined in: src/primitives/errors/AbstractError.ts:94
Get full error chain as string for logging
Returns
string
Inherited from
CryptoError.getErrorChain
toJSON()
toJSON():Defined in: src/primitives/errors/AbstractError.ts:110 Serialize error to JSON for logging/telemetryRecord<string,unknown>
Returns
Record<string, unknown>
Inherited from
CryptoError.toJSON
KzgInvalidBlobError
Defined in: src/crypto/KZG/errors.ts:70 Invalid blob error for EIP-4844 blob validation Thrown when blob data is malformed, wrong length, or contains invalid field elementsSee
https://voltaire.tevm.sh/crypto/kzg/validate-blobSince
0.0.0Extends
Constructors
Constructor
new KzgInvalidBlobError(Defined in: src/crypto/KZG/errors.ts:71message,options?):KzgInvalidBlobError
Parameters
message
string
options?
cause?
Error
code?
string
context?
Record<string, unknown>
docsPath?
string
Returns
KzgInvalidBlobError
Overrides
KzgError.constructor
Properties
cause?
Defined in: src/primitives/errors/AbstractError.ts:56 Root cause of this error (for error chaining)optionalcause:Error
Inherited from
KzgError.cause
code
code: string
Defined in: src/primitives/errors/AbstractError.ts:39
Machine-readable error code for programmatic handling
Example
Inherited from
KzgError.code
context?
Defined in: src/primitives/errors/AbstractError.ts:45 Additional context metadata for debuggingoptionalcontext:Record<string,unknown>
Example
Inherited from
KzgError.context
docsPath?
Defined in: src/primitives/errors/AbstractError.ts:51 Path to documentation for this erroroptionaldocsPath:string
Example
Inherited from
KzgError.docsPath
Methods
getErrorChain()
getErrorChain(): string
Defined in: src/primitives/errors/AbstractError.ts:94
Get full error chain as string for logging
Returns
string
Inherited from
KzgError.getErrorChain
toJSON()
toJSON():Defined in: src/primitives/errors/AbstractError.ts:110 Serialize error to JSON for logging/telemetryRecord<string,unknown>
Returns
Record<string, unknown>
Inherited from
KzgError.toJSON
KzgNotInitializedError
Defined in: src/crypto/KZG/errors.ts:41 Trusted setup not initialized error Thrown when KZG operations are attempted before loadTrustedSetup() is calledSee
https://voltaire.tevm.sh/crypto/kzg/load-trusted-setupSince
0.0.0Extends
Constructors
Constructor
new KzgNotInitializedError(Defined in: src/crypto/KZG/errors.ts:42message,options?):KzgNotInitializedError
Parameters
message
string = "KZG trusted setup not initialized"
options?
cause?
Error
code?
string
context?
Record<string, unknown>
docsPath?
string
Returns
KzgNotInitializedError
Overrides
KzgError.constructor
Properties
cause?
Defined in: src/primitives/errors/AbstractError.ts:56 Root cause of this error (for error chaining)optionalcause:Error
Inherited from
KzgError.cause
code
code: string
Defined in: src/primitives/errors/AbstractError.ts:39
Machine-readable error code for programmatic handling
Example
Inherited from
KzgError.code
context?
Defined in: src/primitives/errors/AbstractError.ts:45 Additional context metadata for debuggingoptionalcontext:Record<string,unknown>
Example
Inherited from
KzgError.context
docsPath?
Defined in: src/primitives/errors/AbstractError.ts:51 Path to documentation for this erroroptionaldocsPath:string
Example
Inherited from
KzgError.docsPath
Methods
getErrorChain()
getErrorChain(): string
Defined in: src/primitives/errors/AbstractError.ts:94
Get full error chain as string for logging
Returns
string
Inherited from
KzgError.getErrorChain
toJSON()
toJSON():Defined in: src/primitives/errors/AbstractError.ts:110 Serialize error to JSON for logging/telemetryRecord<string,unknown>
Returns
Record<string, unknown>
Inherited from
KzgError.toJSON
KzgVerificationError
Defined in: src/crypto/KZG/errors.ts:98 Verification error for KZG proof verification failures Thrown when proof verification fails or verification inputs are invalidSee
https://voltaire.tevm.sh/crypto/kzg/verify-blob-kzg-proofSince
0.0.0Extends
Constructors
Constructor
new KzgVerificationError(Defined in: src/crypto/KZG/errors.ts:99message,options?):KzgVerificationError
Parameters
message
string
options?
cause?
Error
code?
string
context?
Record<string, unknown>
docsPath?
string
Returns
KzgVerificationError
Overrides
KzgError.constructor
Properties
cause?
Defined in: src/primitives/errors/AbstractError.ts:56 Root cause of this error (for error chaining)optionalcause:Error
Inherited from
KzgError.cause
code
code: string
Defined in: src/primitives/errors/AbstractError.ts:39
Machine-readable error code for programmatic handling
Example
Inherited from
KzgError.code
context?
Defined in: src/primitives/errors/AbstractError.ts:45 Additional context metadata for debuggingoptionalcontext:Record<string,unknown>
Example
Inherited from
KzgError.context
docsPath?
Defined in: src/primitives/errors/AbstractError.ts:51 Path to documentation for this erroroptionaldocsPath:string
Example
Inherited from
KzgError.docsPath
Methods
getErrorChain()
getErrorChain(): string
Defined in: src/primitives/errors/AbstractError.ts:94
Get full error chain as string for logging
Returns
string
Inherited from
KzgError.getErrorChain
toJSON()
toJSON():Defined in: src/primitives/errors/AbstractError.ts:110 Serialize error to JSON for logging/telemetryRecord<string,unknown>
Returns
Record<string, unknown>
Inherited from
KzgError.toJSON
Type Aliases
BlobType
BlobType =Defined in: src/crypto/KZG/BlobType.ts:11 Branded type for Blob (EIP-4844) A blob is 131072 bytes (128 KB) containing 4096 field elementsUint8Array&object
Type Declaration
[brand]
readonly[brand]:"Blob"
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0KzgCommitmentType
KzgCommitmentType =Defined in: src/crypto/KZG/KzgCommitmentType.ts:11 Branded type for KZG Commitment (EIP-4844) A KZG commitment is 48 bytes representing a BLS12-381 G1 pointUint8Array&object
Type Declaration
[brand]
readonly[brand]:"KzgCommitment"
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0KzgProofType
KzgProofType =Defined in: src/crypto/KZG/KzgProofType.ts:11 Branded type for KZG Proof (EIP-4844) A KZG proof is 48 bytes representing a BLS12-381 G1 pointUint8Array&object
Type Declaration
[brand]
readonly[brand]:"KzgProof"
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Variables
blobToKzgCommitment()
Defined in: src/crypto/KZG/KZG.js:60 Convert blob to KZG commitmentconstblobToKzgCommitment: (blob) =>Uint8Array
Parameters
blob
Uint8Array
Returns
Uint8Array
BYTES_PER_BLOB
Defined in: src/crypto/KZG/constants.js:13 Total bytes per blob (128 KB)constBYTES_PER_BLOB:number=131072
Since
0.0.0BYTES_PER_COMMITMENT
Defined in: src/crypto/KZG/constants.js:20 Bytes per KZG commitment (BLS12-381 G1 point)constBYTES_PER_COMMITMENT:number=48
Since
0.0.0BYTES_PER_FIELD_ELEMENT
Defined in: src/crypto/KZG/constants.js:34 Bytes per field elementconstBYTES_PER_FIELD_ELEMENT:number=32
Since
0.0.0BYTES_PER_PROOF
Defined in: src/crypto/KZG/constants.js:27 Bytes per KZG proof (BLS12-381 G1 point)constBYTES_PER_PROOF:number=48
Since
0.0.0computeBlobKzgProof()
Defined in: src/crypto/KZG/KZG.js:76 Compute KZG blob proof given commitmentconstcomputeBlobKzgProof: (blob,commitment) =>Uint8Array
Parameters
blob
Uint8Array
commitment
Uint8Array
Returns
Uint8Array
computeKzgProof()
Defined in: src/crypto/KZG/KZG.js:68 Compute KZG proof for a blob at a given pointconstcomputeKzgProof: (blob,z) =>object
Parameters
blob
Uint8Array
z
Uint8Array
Returns
object
proof
proof: Uint8Array
y
y: Uint8Array
FIELD_ELEMENTS_PER_BLOB
Defined in: src/crypto/KZG/constants.js:41 Number of field elements per blobconstFIELD_ELEMENTS_PER_BLOB:number=4096
Since
0.0.0verifyBlobKzgProof()
Defined in: src/crypto/KZG/KZG.js:92 Verify a KZG blob proofconstverifyBlobKzgProof: (blob,commitment,proof) =>boolean
Parameters
blob
Uint8Array
commitment
Uint8Array
proof
Uint8Array
Returns
boolean
verifyBlobKzgProofBatch()
Defined in: src/crypto/KZG/KZG.js:100 Verify multiple KZG blob proofs in batchconstverifyBlobKzgProofBatch: (blobs,commitments,proofs) =>boolean
Parameters
blobs
Uint8Array<ArrayBufferLike>[]
commitments
Uint8Array<ArrayBufferLike>[]
proofs
Uint8Array<ArrayBufferLike>[]
Returns
boolean
verifyKzgProof()
Defined in: src/crypto/KZG/KZG.js:84 Verify a KZG proofconstverifyKzgProof: (commitment,z,y,proof) =>boolean
Parameters
commitment
Uint8Array
z
Uint8Array
y
Uint8Array
proof
Uint8Array
Returns
boolean
Functions
BlobToKzgCommitment()
BlobToKzgCommitment(Defined in: src/crypto/KZG/blobToKzgCommitment.js:21 Factory: Convert blob to KZG commitmentdeps): (blob) =>Uint8Array
Parameters
deps
Crypto dependenciesblobToKzgCommitment
(blob) => Uint8Array
c-kzg blobToKzgCommitment function
Returns
Function that converts blob to KZG commitment(blob):Uint8Array
Parameters
blob
Uint8Array
Returns
Uint8Array
Example
ComputeBlobKzgProof()
ComputeBlobKzgProof(Defined in: src/crypto/KZG/computeBlobKzgProof.js:28 Factory: Compute blob KZG proof for a blob given its commitment This is the optimized version for blob verification (EIP-4844). Unlike computeKzgProof which requires an evaluation point z, this function generates a proof that can be used with verifyBlobKzgProof.deps): (blob,commitment) =>Uint8Array
Parameters
deps
Crypto dependenciescomputeBlobKzgProof
(blob, commitment) => Uint8Array
c-kzg computeBlobKzgProof function
Returns
Function that computes blob KZG proof(blob,commitment):Uint8Array
Parameters
blob
Uint8Array
commitment
Uint8Array
Returns
Uint8Array
Example
ComputeKzgProof()
ComputeKzgProof(Defined in: src/crypto/KZG/computeKzgProof.js:22 Factory: Compute KZG proof for blob at evaluation point zdeps): (blob,z) =>object
Parameters
deps
Crypto dependenciescomputeKzgProof
(blob, z) => [Uint8Array<ArrayBufferLike>, Uint8Array<ArrayBufferLike>]
c-kzg computeKzgProof function
Returns
Function that computes KZG proof(blob,z):object
Parameters
blob
Uint8Array
z
Uint8Array
Returns
object
proof
proof: Uint8Array
y
y: Uint8Array
Example
createEmptyBlob()
createEmptyBlob():Defined in: src/crypto/KZG/createEmptyBlob.js:16 Create empty blob filled with zerosUint8Array<ArrayBufferLike>
Returns
Uint8Array<ArrayBufferLike>
New zero-filled blob
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
Example
freeTrustedSetup()
freeTrustedSetup(): void
Defined in: src/crypto/KZG/loadTrustedSetup.js:53
Free trusted setup resources
Call when KZG operations are no longer needed.
Returns
void
See
https://voltaire.tevm.sh/crypto/kzgSince
0.0.0generateRandomBlob()
generateRandomBlob(Defined in: src/crypto/KZG/generateRandomBlob.js:23 Generate random valid blob (for testing)seed?):Uint8Array<ArrayBufferLike>
Parameters
seed?
number
Optional seed for deterministic generation
Returns
Uint8Array<ArrayBufferLike>
Random blob with valid field elements
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
If crypto.getRandomValues not availableExample
isInitialized()
isInitialized(): boolean
Defined in: src/crypto/KZG/isInitialized.js:18
Check if KZG is initialized
Returns
boolean
true if trusted setup is loaded
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
Example
loadTrustedSetup()
loadTrustedSetup(Defined in: src/crypto/KZG/loadTrustedSetup.js:28 Load trusted setup from embedded data Uses the embedded trusted setup from c-kzg-4844. Call this once during application startup before using any KZG operations. Available in both native FFI and WASM environments._filePath?):void
Parameters
_filePath?
string
Optional path (ignored, uses embedded setup)
Returns
void
See
https://voltaire.tevm.sh/crypto/kzgSince
0.0.0Throws
If loading failsExample
validateBlob()
validateBlob(Defined in: src/crypto/KZG/validateBlob.js:22 Validate blob formatblob):void
Parameters
blob
Uint8Array<ArrayBufferLike>
Blob to validate
Returns
void
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
If blob is invalidExample
VerifyBlobKzgProof()
VerifyBlobKzgProof(Defined in: src/crypto/KZG/verifyBlobKzgProof.js:22 Factory: Verify blob KZG proof (optimized for blob verification)deps): (blob,commitment,proof) =>boolean
Parameters
deps
Crypto dependenciesverifyBlobKzgProof
(blob, commitment, proof) => boolean
c-kzg verifyBlobKzgProof function
Returns
Function that verifies blob KZG proof(blob,commitment,proof):boolean
Parameters
blob
Uint8Array
commitment
Uint8Array
proof
Uint8Array
Returns
boolean
Example
VerifyBlobKzgProofBatch()
VerifyBlobKzgProofBatch(Defined in: src/crypto/KZG/verifyBlobKzgProofBatch.js:21 Factory: Verify multiple blob KZG proofs (batch verification)deps): (blobs,commitments,proofs) =>boolean
Parameters
deps
Crypto dependenciesverifyBlobKzgProofBatch
(blobs, commitments, proofs) => boolean
c-kzg verifyBlobKzgProofBatch function
Returns
Function that verifies batch of blob KZG proofs(blobs,commitments,proofs):boolean
Parameters
blobs
Uint8Array<ArrayBufferLike>[]
commitments
Uint8Array<ArrayBufferLike>[]
proofs
Uint8Array<ArrayBufferLike>[]
Returns
boolean
Example
VerifyKzgProof()
VerifyKzgProof(Defined in: src/crypto/KZG/verifyKzgProof.js:25 Factory: Verify KZG proofdeps): (commitment,z,y,proof) =>boolean
Parameters
deps
Crypto dependenciesverifyKzgProof
(commitment, z, y, proof) => boolean
c-kzg verifyKzgProof function
Returns
Function that verifies KZG proof(commitment,z,y,proof):boolean
Parameters
commitment
Uint8Array
z
Uint8Array
y
Uint8Array
proof
Uint8Array
Returns
boolean

