@tevm/voltaire / index / wasm
wasm
Namespaces
- Blake2Wasm
- Bn254Wasm
- Ed25519Wasm
- Eip712Wasm
- P256Wasm
- Ripemd160Wasm
- Secp256k1Wasm
- Sha256Wasm
- X25519Wasm
Enumerations
TransactionType
Defined in: src/primitives/Transaction/Transaction.wasm.ts:11 Transaction type enumerationEnumeration Members
EIP1559
EIP1559: 2
Defined in: src/primitives/Transaction/Transaction.wasm.ts:17
EIP-1559 fee market transaction
EIP2930
EIP2930: 1
Defined in: src/primitives/Transaction/Transaction.wasm.ts:15
EIP-2930 access list transaction
EIP4844
EIP4844: 3
Defined in: src/primitives/Transaction/Transaction.wasm.ts:19
EIP-4844 blob transaction
EIP7702
EIP7702: 4
Defined in: src/primitives/Transaction/Transaction.wasm.ts:21
EIP-7702 set code transaction
Legacy
Legacy: 0
Defined in: src/primitives/Transaction/Transaction.wasm.ts:13
Legacy transaction (pre-EIP-2718)
Interfaces
ParsedSignature
Defined in: src/crypto/signature.wasm.js:18Properties
r
r:Defined in: src/crypto/signature.wasm.js:12 R component (32 bytes)Uint8Array<ArrayBufferLike>
s
s:Defined in: src/crypto/signature.wasm.js:13 S component (32 bytes)Uint8Array<ArrayBufferLike>
v
v: number
Defined in: src/crypto/signature.wasm.js:14
Recovery ID (0, 1, 27, or 28)
Type Aliases
ParsedSignature
ParsedSignature = undefined
Defined in: src/crypto/signature.wasm.js:18
ParsedSignature type
Variables
Abi
Defined in: src/wasm/index.ts:234constAbi: typeofAbi=AbiJS
AccessList
Defined in: src/wasm/index.ts:236constAccessList:object=AccessListJS
Type Declaration
ADDRESS_COST
ADDRESS_COST: bigint
Gas cost per address in access list (EIP-2930)
addressCount()
addressCount: (list) =>number
Parameters
list
BrandedAccessList
Returns
number
assertValid()
assertValid: (list) =>void
Parameters
list
BrandedAccessList
Returns
void
COLD_ACCOUNT_ACCESS_COST
COLD_ACCOUNT_ACCESS_COST: bigint
Cold account access cost (pre-EIP-2930)
COLD_STORAGE_ACCESS_COST
COLD_STORAGE_ACCESS_COST: bigint
Cold storage access cost (pre-EIP-2930)
create()
create: () => BrandedAccessList
Returns
BrandedAccessList
deduplicate()
deduplicate: (list) =>BrandedAccessList
Parameters
list
BrandedAccessList
Returns
BrandedAccessList
from()
from: (value) =>BrandedAccessList
Parameters
value
Uint8Array<ArrayBufferLike> | readonly Item[]
Returns
BrandedAccessList
fromBytes()
fromBytes: (bytes) =>BrandedAccessList
Parameters
bytes
Uint8Array
Returns
BrandedAccessList
gasCost()
gasCost: (list) =>bigint
Parameters
list
BrandedAccessList
Returns
bigint
gasSavings()
gasSavings: (list) =>bigint
Parameters
list
BrandedAccessList
Returns
bigint
hasSavings()
hasSavings: (list) =>boolean
Parameters
list
BrandedAccessList
Returns
boolean
includesAddress()
includesAddress: (list,address) =>boolean
Parameters
list
BrandedAccessList
address
AddressType
Returns
boolean
includesStorageKey()
includesStorageKey: (list,address,storageKey) =>boolean
Parameters
list
BrandedAccessList
address
AddressType
storageKey
HashType
Returns
boolean
is()
is: (value) =>value is BrandedAccessList
Parameters
value
unknown
Returns
value is BrandedAccessList
isEmpty()
isEmpty: (list) =>boolean
Parameters
list
BrandedAccessList
Returns
boolean
isItem()
isItem: (value) =>value is Item
Parameters
value
unknown
Returns
value is Item
keysFor()
keysFor: (list,address) => readonlyHashType[] |undefined
Parameters
list
BrandedAccessList
address
AddressType
Returns
readonlyHashType[] | undefined
merge()
merge: (…accessLists) =>BrandedAccessList
Parameters
accessLists
…BrandedAccessList[]
Returns
BrandedAccessList
STORAGE_KEY_COST
STORAGE_KEY_COST: bigint
Gas cost per storage key in access list (EIP-2930)
storageKeyCount()
storageKeyCount: (list) =>number
Parameters
list
BrandedAccessList
Returns
number
toBytes()
toBytes: (list) =>Uint8Array
Parameters
list
BrandedAccessList
Returns
Uint8Array
WARM_STORAGE_ACCESS_COST
WARM_STORAGE_ACCESS_COST: bigint
Warm storage access cost (post-EIP-2929)
withAddress()
withAddress: (list,address) =>BrandedAccessList
Parameters
list
BrandedAccessList
address
AddressType
Returns
BrandedAccessList
withStorageKey()
withStorageKey: (list,address,storageKey) =>BrandedAccessList
Parameters
list
BrandedAccessList
address
AddressType
storageKey
HashType
Returns
BrandedAccessList
Address
Defined in: src/wasm/index.ts:229constAddress: typeofAddress=AddressJS
Blake2
Defined in: src/wasm/index.ts:172 Blake2 with WASM accelerationconstBlake2: (input,outputLength?) =>Blake2Hash&object&object
Type Declaration
from()
from: (Hash input with BLAKE2b (constructor pattern) Auto-detects input type and hashes accordingly:input,outputLength?) =>Blake2Hash
- Uint8Array: hash directly
- string: UTF-8 encode then hash
Parameters
input
Data to hashstring | Uint8Array<ArrayBufferLike>
outputLength?
number = 64
Output length in bytes (1-64, default 64)
Returns
Blake2Hash
BLAKE2b hash
See
https://voltaire.tevm.sh/crypto/blake2 for crypto documentationSince
0.0.0Throws
If outputLength is invalidExample
fromString()
fromString: (Hash string with BLAKE2b (convenience function)str,outputLength?) =>Blake2Hash=hashString
Parameters
str
string
Input string to hash
outputLength?
number = 64
Output length in bytes (1-64, default 64)
Returns
Blake2Hash
BLAKE2b hash
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
If outputLength is invalidExample
hash()
hash: (Hash data with BLAKE2bdata,outputLength?) =>Blake2Hash
Parameters
data
Input data to hash (Uint8Array or string)string | Uint8Array<ArrayBufferLike>
outputLength?
number = 64
Output length in bytes (1-64, default 64)
Returns
Blake2Hash
BLAKE2b hash
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
If outputLength is invalidExample
hashString()
hashString: (Hash string with BLAKE2b (convenience function)str,outputLength?) =>Blake2Hash
Parameters
str
string
Input string to hash
outputLength?
number = 64
Output length in bytes (1-64, default 64)
Returns
Blake2Hash
BLAKE2b hash
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
If outputLength is invalidExample
SIZE
SIZE: number
Type Declaration
_wasm
_wasm: typeofBlake2Wasm=Blake2Wasm
Blob
Defined in: src/wasm/index.ts:235constBlob: typeofBlob=BlobJS
BloomFilter
Defined in: src/wasm/index.ts:240constBloomFilter: typeofBloomFilter=BloomFilterJS
Bls12381
Defined in: src/wasm/index.ts:253constBls12381:object=Bls12381JS
Type Declaration
aggregate()
aggregate: (Aggregate multiple BLS signatures into one The aggregated signature can be verified against an aggregated public key (when all signers signed the same message) or via batch verification (when signers signed different messages).signatures) =>Uint8Array<ArrayBufferLike>
Parameters
signatures
Uint8Array<ArrayBufferLike>[]
Array of compressed G1 signatures (48 bytes each)
Returns
Uint8Array<ArrayBufferLike>
Aggregated signature (48 bytes compressed G1)
Throws
If aggregation fails or no signatures providedExample
aggregatePublicKeys()
aggregatePublicKeys: (Aggregate multiple public keys into one Used when multiple signers sign the same message and you want to verify against a single aggregated public key.publicKeys) =>Uint8Array<ArrayBufferLike>
Parameters
publicKeys
Uint8Array<ArrayBufferLike>[]
Array of compressed G2 public keys (96 bytes each)
Returns
Uint8Array<ArrayBufferLike>
Aggregated public key (96 bytes compressed G2)
Throws
If aggregation fails or no public keys providedExample
aggregateVerify()
aggregateVerify: (Verify an aggregated signature where all signers signed the same message This is the most common case in Ethereum consensus - multiple validators sign the same block/attestation.aggregatedSignature,message,publicKeys) =>boolean
Parameters
aggregatedSignature
Uint8Array<ArrayBufferLike>
Aggregated signature (96 bytes)
message
Uint8Array<ArrayBufferLike>
The message that was signed by all parties
publicKeys
Uint8Array<ArrayBufferLike>[]
Public keys of all signers (48 bytes each)
Returns
boolean
True if the aggregated signature is valid
Example
batchVerify()
batchVerify: (Verify an aggregated signature where each signer signed a different message Uses multi-pairing verification: product of e(pk_i, H(msg_i)) == e(G1, aggSig)aggregatedSignature,messages,publicKeys) =>boolean
Parameters
aggregatedSignature
Uint8Array<ArrayBufferLike>
Aggregated signature (96 bytes)
messages
Uint8Array<ArrayBufferLike>[]
Messages that were signed (one per signer)
publicKeys
Uint8Array<ArrayBufferLike>[]
Public keys (one per signer, same order as messages)
Returns
boolean
True if the aggregated signature is valid
Throws
If messages and publicKeys have different lengthsExample
derivePublicKey()
derivePublicKey: (Derive a BLS12-381 public key from a private key Public key = privateKey * G2_generatorprivateKey) =>Uint8Array<ArrayBufferLike>
Parameters
privateKey
Uint8Array<ArrayBufferLike>
32-byte private key (scalar in Fr)
Returns
Uint8Array<ArrayBufferLike>
Compressed G2 public key (96 bytes)
Throws
If private key is invalidExample
derivePublicKeyPoint()
derivePublicKeyPoint: (Derive a BLS12-381 public key as a G1 point (uncompressed)privateKey) =>Bls12381G1PointType
Parameters
privateKey
Uint8Array<ArrayBufferLike>
32-byte private key
Returns
Bls12381G1PointType
Public key as G1 point
Throws
If private key is invalidfastAggregateVerify()
fastAggregateVerify: (Fast aggregate verify (same message case) Optimized for the common case where all signers signed the same message. This is faster than aggregateVerify when you already have the aggregated public key.aggregatedSignature,message,aggregatedPublicKey) =>boolean
Parameters
aggregatedSignature
Uint8Array<ArrayBufferLike>
Aggregated signature (96 bytes)
message
Uint8Array<ArrayBufferLike>
The message that was signed
aggregatedPublicKey
Uint8Array<ArrayBufferLike>
Pre-computed aggregated public key (48 bytes)
Returns
boolean
True if valid
Fp
Fp: Fp
Fp2
Fp2: Fp2
Fr
Fr: Fr
G1
G1: G1
G2
G2: G2
isValidPrivateKey()
isValidPrivateKey: (Check if a private key is valid A valid private key must be:privateKey) =>boolean
- 32 bytes
- Non-zero
- Less than the curve order (Fr modulus)
Parameters
privateKey
Uint8Array<ArrayBufferLike>
Private key to validate
Returns
boolean
True if valid
Example
Pairing
Pairing: Pairing
BLS12-381 Pairing Operations
Optimal Ate pairing implementation for BLS12-381.
e: G1 x G2 -> GT
NOTE: Full pairing implementation requires Fp6, Fp12 tower extensions
and Miller loop computation. For production use, the native blst
library should be used via the Zig FFI bindings.
This module provides the interface and simplified implementations
for testing and educational purposes.
See
https://hackmd.io/@benjaminion/bls12-381 for pairing detailsSince
0.0.0randomPrivateKey()
randomPrivateKey: () =>Generate a random BLS12-381 private key Uses cryptographically secure random number generation. The key is guaranteed to be valid (non-zero and less than curve order).Uint8Array<ArrayBufferLike>
Returns
Uint8Array<ArrayBufferLike>
32-byte private key
Example
sign()
sign: (Sign a message using BLS12-381 Uses the Ethereum consensus “short signatures” scheme:message,privateKey) =>Uint8Array<ArrayBufferLike>
- Signature = privateKey * H(message) where H maps to G1
- Signatures are 48 bytes (compressed G1 point)
Parameters
message
Uint8Array<ArrayBufferLike>
Message to sign
privateKey
Uint8Array<ArrayBufferLike>
32-byte private key (scalar in Fr)
Returns
Uint8Array<ArrayBufferLike>
Signature as compressed G1 point (48 bytes)
Throws
If private key is invalidThrows
If signing failsExample
signPoint()
signPoint: (Sign a pre-hashed message (G2 point) using BLS12-381 For advanced use when you have already hashed the message to G2.messagePoint,privateKey) =>Bls12381G2PointType
Parameters
messagePoint
Bls12381G2PointType
Message as G2 point
privateKey
Uint8Array<ArrayBufferLike>
32-byte private key (scalar in Fr)
Returns
Bls12381G2PointType
Signature as G2 point (projective)
Throws
If private key is invalidThrows
If signing failsverify()
verify: (Verify a BLS12-381 signature Uses pairing check for verification.signature,message,publicKey) =>boolean
Parameters
signature
Uint8Array<ArrayBufferLike>
Compressed G1 signature (48 bytes)
message
Uint8Array<ArrayBufferLike>
Original message that was signed
publicKey
Uint8Array<ArrayBufferLike>
Compressed G2 public key (96 bytes)
Returns
boolean
True if signature is valid
Throws
If verification fails due to invalid inputsExample
verifyPoint()
verifyPoint: (Verify a BLS signature with pre-computed points (advanced) For use when you have already deserialized the points.signaturePoint,messagePoint,publicKeyPoint) =>boolean
Parameters
signaturePoint
Bls12381G2PointType
Signature as G2 point
messagePoint
Bls12381G2PointType
Message hash as G2 point
publicKeyPoint
Bls12381G1PointType
Public key as G1 point
Returns
boolean
True if signature is valid
BN254
Defined in: src/wasm/index.ts:214 BN254 with WASM accelerationconstBN254:object&object
Type Declaration
deserializeG1()
deserializeG1: (Deserialize G1 point from bytesbytes) =>G1PointType
Parameters
bytes
Uint8Array<ArrayBufferLike>
64-byte serialization
Returns
G1PointType
G1 point
See
https://voltaire.tevm.sh/crypto for BN254 cryptography documentationSince
0.0.0Throws
If bytes length is invalid (must be 64 bytes)Example
deserializeG2()
deserializeG2: (Deserialize G2 point from bytesbytes) =>G2PointType
Parameters
bytes
Uint8Array<ArrayBufferLike>
128-byte serialization
Returns
G2PointType
G2 point
See
https://voltaire.tevm.sh/crypto for BN254 cryptography documentationSince
0.0.0Throws
If bytes length is invalid (must be 128 bytes)Example
Fp
Fp: __module
Fp2
Fp2: __module
Fr
Fr: __module
G1
G1: __module
G2
G2: __module
Pairing
Pairing: __module
serializeG1()
serializeG1: (Serialize G1 point to bytes (64 bytes: x || y)point) =>Uint8Array<ArrayBufferLike>
Parameters
point
G1PointType
G1 point
Returns
Uint8Array<ArrayBufferLike>
64-byte serialization
See
https://voltaire.tevm.sh/crypto for BN254 cryptography documentationSince
0.0.0Throws
Example
serializeG2()
serializeG2: (Serialize G2 point to bytes (128 bytes: x.c0 || x.c1 || y.c0 || y.c1)point) =>Uint8Array<ArrayBufferLike>
Parameters
point
G2PointType
G2 point
Returns
Uint8Array<ArrayBufferLike>
128-byte serialization
See
https://voltaire.tevm.sh/crypto for BN254 cryptography documentationSince
0.0.0Throws
Example
Type Declaration
_wasm
_wasm: typeofBn254Wasm=Bn254Wasm
Bytecode
Defined in: src/wasm/index.ts:237constBytecode: typeofBytecode=BytecodeJS
Bytes
Defined in: src/wasm/index.ts:242constBytes: typeofBytes=BytesJS
Bytes32
Defined in: src/wasm/index.ts:243constBytes32: typeofBytes32=Bytes32JS
Chain
Defined in: src/wasm/index.ts:238constChain: typeofChain=ChainJS
Ed25519
Defined in: src/wasm/index.ts:193 Ed25519 with WASM accelerationconstEd25519:object&object
Type Declaration
derivePublicKey()
derivePublicKey: (Derive Ed25519 public key from secret key.secretKey) =>PublicKey
Parameters
secretKey
SecretKey
32-byte Ed25519 secret key (seed)
Returns
PublicKey
32-byte Ed25519 public key
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
If secret key length is invalid or derivation failsExample
keypairFromSeed()
keypairFromSeed: (Generate Ed25519 keypair from seed deterministically.seed) =>object
Parameters
seed
Seed
32-byte seed for deterministic keypair generation
Returns
object
Object containing 32-byte secretKey and 32-byte publicKey
publicKey
publicKey: PublicKey
secretKey
secretKey: SecretKey
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
If seed length is not 32 bytesThrows
If keypair generation failsExample
PUBLIC_KEY_SIZE
PUBLIC_KEY_SIZE: 32
Ed25519 public key size in bytes.
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Example
SECRET_KEY_SIZE
SECRET_KEY_SIZE: 32
Ed25519 secret key size in bytes.
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Example
SEED_SIZE
SEED_SIZE: 32
Ed25519 seed size in bytes.
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Example
sign()
sign: (Sign message with Ed25519 secret key. Produces deterministic signatures using EdDSA.message,secretKey) =>Signature
Parameters
message
Uint8Array<ArrayBufferLike>
Message bytes to sign (any length)
secretKey
SecretKey
32-byte Ed25519 secret key
Returns
Signature
64-byte Ed25519 signature
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
If secret key length is not 32 bytesThrows
If signing operation failsExample
SIGNATURE_SIZE
SIGNATURE_SIZE: 64
Ed25519 signature size in bytes.
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Example
validatePublicKey()
validatePublicKey: (Validate Ed25519 public key format and curve membership.publicKey) =>boolean
Parameters
publicKey
PublicKey
Ed25519 public key to validate
Returns
boolean
True if public key is valid and on curve, false otherwise
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
Example
validateSecretKey()
validateSecretKey: (Validate Ed25519 secret key format. Checks length and attempts public key derivation.secretKey) =>boolean
Parameters
secretKey
SecretKey
Ed25519 secret key to validate
Returns
boolean
True if secret key is valid (32 bytes and can derive public key), false otherwise
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
Example
validateSeed()
validateSeed: (Validate Ed25519 seed format. Checks if seed has correct 32-byte length.seed) =>boolean
Parameters
seed
Seed
Ed25519 seed to validate
Returns
boolean
True if seed is exactly 32 bytes, false otherwise
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
Example
verify()
verify: (Verify Ed25519 signature. Returns false on verification failure instead of throwing.signature,message,publicKey) =>boolean
Parameters
signature
Signature
64-byte Ed25519 signature to verify
message
Uint8Array<ArrayBufferLike>
Original message bytes that were signed
publicKey
PublicKey
32-byte Ed25519 public key
Returns
boolean
True if signature is cryptographically valid, false otherwise
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
If public key length is not 32 bytesThrows
If signature length is not 64 bytesExample
Type Declaration
_wasm
_wasm: typeofEd25519Wasm=Ed25519Wasm
EIP712
Defined in: src/wasm/index.ts:221 EIP712 with WASM accelerationconstEIP712:object&object
Type Declaration
Domain
Domain: object
Domain.hash()
hash: (domain) =>HashType=hashDomain
Parameters
domain
Domain
Returns
HashType
encodeData()
encodeData: (primaryType,data,types) =>Uint8Array
Parameters
primaryType
string
data
Message
types
TypeDefinitions
Returns
Uint8Array
EncodeData()
EncodeData: (Factory: Encode struct data according to EIP-712.deps) => (primaryType,data,types) =>Uint8Array
Parameters
deps
Crypto dependenciesencodeValue
(type, value, types) => Uint8Array
Encode value function
hashType
(primaryType, types) => HashType
Hash type function
Returns
Function that encodes data(primaryType,data,types):Uint8Array
Parameters
primaryType
string
data
Message
types
TypeDefinitions
Returns
Uint8Array
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
If primaryType is not found in typesThrows
If required field is missing from dataExample
encodeType()
encodeType: (Encode type string for EIP-712 hashing. Produces type encoding like “Mail(Person from,Person to,string contents)Person(string name,address wallet)“primaryType,types) =>string
Parameters
primaryType
string
Primary type name to encode
types
TypeDefinitions
Type definitions mapping
Returns
string
Encoded type string with primary type followed by referenced types in alphabetical order
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
If primaryType or any referenced type is not foundExample
encodeValue()
encodeValue: (type,value,types) =>Uint8Array
Parameters
type
string
value
MessageValue
types
TypeDefinitions
Returns
Uint8Array
EncodeValue()
EncodeValue: (Factory: Encode single value to 32 bytes according to EIP-712. Handles primitive types, arrays, strings, bytes, and custom structs. Addresses must be pre-validated BrandedAddress types.deps) => (type,value,types) =>Uint8Array
Parameters
deps
Crypto dependencieshashStruct
(type, data, types) => HashType
Hash struct function
keccak256
(data) => Uint8Array
Keccak256 hash function
Returns
Function that encodes value(type,value,types):Uint8Array
Parameters
type
string
value
MessageValue
types
TypeDefinitions
Returns
Uint8Array
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
If type is unsupported or value format is invalidExample
format()
format: (Format typed data for human-readable display.typedData) =>string
Parameters
typedData
TypedData
Typed data to format
Returns
string
Human-readable multi-line string representation
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
Example
HashDomain()
HashDomain: (Factory: Hash EIP-712 domain separator. Only includes fields that are defined in the domain object.deps) => (domain) =>HashType
Parameters
deps
Crypto dependencieshashStruct
(primaryType, data, types) => HashType
Hash struct function
Returns
Function that hashes domain(domain):HashType
Parameters
domain
Domain
Returns
HashType
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
If domain type encoding failsExample
hashStruct()
hashStruct: (primaryType,data,types) =>HashType
Parameters
primaryType
string
data
Message
types
TypeDefinitions
Returns
HashType
HashStruct()
HashStruct: (Factory: Hash struct according to EIP-712 specification. Computes keccak256 of the encoded struct data.deps) => (primaryType,data,types) =>HashType
Parameters
deps
Crypto dependenciesencodeData
(primaryType, data, types) => Uint8Array
Encode data function
keccak256
(data) => Uint8Array
Keccak256 hash function
Returns
Function that hashes struct(primaryType,data,types):HashType
Parameters
primaryType
string
data
Message
types
TypeDefinitions
Returns
HashType
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
If type is not foundThrows
If message data is invalidExample
hashType()
hashType: (primaryType,types) =>HashType
Parameters
primaryType
string
types
TypeDefinitions
Returns
HashType
HashType()
HashType: (Factory: Hash type string according to EIP-712. Computes keccak256 of the encoded type string.deps) => (primaryType,types) =>HashType
Parameters
deps
Crypto dependencieskeccak256
(data) => Uint8Array
Keccak256 hash function
Returns
Function that hashes type string(primaryType,types):HashType
Parameters
primaryType
string
types
TypeDefinitions
Returns
HashType
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
If type is not foundExample
hashTypedData()
hashTypedData: (typedData) =>HashType
Parameters
typedData
TypedData
Returns
HashType
HashTypedData()
HashTypedData: (Factory: Hash typed data according to EIP-712 specification. Computes: keccak256(“\x19\x01” ‖ domainSeparator ‖ hashStruct(message))deps) => (typedData) =>HashType
Parameters
deps
Crypto dependencieshashDomain
(domain) => HashType
Hash domain function
hashStruct
(primaryType, data, types) => HashType
Hash struct function
keccak256
(data) => Uint8Array
Keccak256 hash function
Returns
Function that hashes typed data(typedData):HashType
Parameters
typedData
TypedData
Returns
HashType
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
If types are not foundThrows
If message data is invalidExample
recoverAddress()
recoverAddress: (signature,typedData) =>AddressType
Parameters
signature
Signature
typedData
TypedData
Returns
AddressType
RecoverAddress()
RecoverAddress: (Factory: Recover Ethereum address from EIP-712 typed data signature. Uses ECDSA public key recovery to determine the signer’s address.deps) => (signature,typedData) =>AddressType
Parameters
deps
Crypto dependencieshashTypedData
(typedData) => HashType
Hash typed data function
keccak256
(data) => Uint8Array
Keccak256 hash function
recoverPublicKey
(signature, hash, recoveryBit) => Uint8Array
Secp256k1 public key recovery function
Returns
Function that recovers address(signature,typedData):AddressType
Parameters
signature
Signature
typedData
TypedData
Returns
AddressType
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
If signature recovery fails or public key format is invalidExample
signTypedData()
signTypedData: (typedData,privateKey) =>Signature
Parameters
typedData
any
privateKey
any
Returns
Signature
SignTypedData()
SignTypedData: (Factory: Sign EIP-712 typed data with ECDSA private key. Produces a signature that can be verified against the signer’s address.deps) => (typedData,privateKey) =>Signature
Parameters
deps
Crypto dependencieshashTypedData
(typedData) => HashType
Hash typed data function
sign
(hash, privateKey) => Signature
Secp256k1 sign function
Returns
Function that signs typed data(typedData,privateKey):Signature
Parameters
typedData
TypedData
privateKey
Uint8Array
Returns
Signature
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
If private key length is invalid or signing failsExample
validate()
validate: (Validate typed data structure against EIP-712 specification. Checks domain, types, primaryType, and message structure.typedData) =>void
Parameters
typedData
TypedData
Typed data to validate
Returns
void
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
If structure is invalid or missing required fieldsExample
verifyTypedData()
verifyTypedData: (signature,typedData,address) =>boolean
Parameters
signature
Signature
typedData
TypedData
address
AddressType
Returns
boolean
VerifyTypedData()
VerifyTypedData: (Factory: Verify EIP-712 typed data signature against expected signer address. Uses constant-time comparison to prevent timing attacks.deps) => (signature,typedData,address) =>boolean
Parameters
deps
Crypto dependenciesrecoverAddress
(signature, typedData) => AddressType
Recover address function
Returns
Function that verifies signature(signature,typedData,address):boolean
Parameters
signature
Signature
typedData
TypedData
address
AddressType
Returns
boolean
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
Example
Type Declaration
_wasm
_wasm: typeofEip712Wasm=Eip712Wasm
Ether
Defined in: src/wasm/index.ts:247constEther:EtherConstructor=EtherJS
Gwei
Defined in: src/wasm/index.ts:246constGwei:GweiConstructor=GweiJS
Hash
Defined in: src/wasm/index.ts:230constHash:HashConstructor=HashJS
Hex
Defined in: src/wasm/index.ts:231constHex: typeofHex=HexJS
Keccak256
Defined in: src/wasm/index.ts:157 Keccak256 with WASM acceleration Falls back to JS implementation, but WASM methods available viaconstKeccak256: (input) =>Keccak256Hash&object&object
_wasm
Type Declaration
contractAddress()
contractAddress: (Compute contract address from deployer and nonce Uses CREATE formula: keccak256(rlp([sender, nonce]))[12:]sender,nonce) =>Uint8Array<ArrayBufferLike>
Parameters
sender
Uint8Array<ArrayBufferLike>
Deployer address (20 bytes)
nonce
bigint
Transaction nonce
Returns
Uint8Array<ArrayBufferLike>
Contract address (20 bytes)
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
If sender is not 20 bytesExample
create2Address()
create2Address: (Compute CREATE2 address Uses CREATE2 formula: keccak256(0xff ++ sender ++ salt ++ keccak256(init_code))[12:]sender,salt,initCodeHash) =>Uint8Array<ArrayBufferLike>
Parameters
sender
Uint8Array<ArrayBufferLike>
Deployer address (20 bytes)
salt
Uint8Array<ArrayBufferLike>
32-byte salt
initCodeHash
Uint8Array<ArrayBufferLike>
Hash of initialization code
Returns
Uint8Array<ArrayBufferLike>
Contract address (20 bytes)
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
If sender is not 20 bytesThrows
If salt is not 32 bytesThrows
If initCodeHash is not 32 bytesExample
DIGEST_SIZE
DIGEST_SIZE: number
Digest size in bytes (32 bytes = 256 bits)
Since
0.0.0from()
from: (Hash input with Keccak-256 (constructor pattern) Auto-detects input type and hashes accordingly:input) =>Keccak256Hash
- Uint8Array: hash directly
- string starting with 0x: parse as hex
- string: UTF-8 encode then hash
Parameters
input
Data to hashstring | Uint8Array<ArrayBufferLike>
Returns
Keccak256Hash
32-byte hash
See
https://voltaire.tevm.sh/crypto/keccak256 for crypto documentationSince
0.0.0Throws
If hex string is invalidExample
fromHex()
fromHex: (Hash hex string with Keccak-256hex) =>Keccak256Hash=hashHex
Parameters
hex
string
Hex string to hash (with or without 0x prefix)
Returns
Keccak256Hash
32-byte hash
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
If hex string is invalid or has odd lengthExample
fromString()
fromString: (Hash string with Keccak-256 String is UTF-8 encoded before hashing.str) =>Keccak256Hash=hashString
Parameters
str
string
String to hash
Returns
Keccak256Hash
32-byte hash
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
Example
fromTopic()
fromTopic: (Compute event topic (32-byte Keccak-256 hash) Used for Ethereum event signatures.signature) =>Keccak256Hash=topic
Parameters
signature
string
Event signature string
Returns
Keccak256Hash
32-byte topic
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
Example
hash()
hash: (Hash data with Keccak-256data) =>Keccak256Hash
Parameters
data
Uint8Array<ArrayBufferLike>
Data to hash
Returns
Keccak256Hash
32-byte hash
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
Example
hashHex()
hashHex: (Hash hex string with Keccak-256hex) =>Keccak256Hash
Parameters
hex
string
Hex string to hash (with or without 0x prefix)
Returns
Keccak256Hash
32-byte hash
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
If hex string is invalid or has odd lengthExample
hashMultiple()
hashMultiple: (Hash multiple data chunks in sequence Equivalent to hashing the concatenation of all chunks.chunks) =>Keccak256Hash
Parameters
chunks
readonlyUint8Array<ArrayBufferLike>[]
Array of data chunks to hash
Returns
Keccak256Hash
32-byte hash
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
Example
hashString()
hashString: (Hash string with Keccak-256 String is UTF-8 encoded before hashing.str) =>Keccak256Hash
Parameters
str
string
String to hash
Returns
Keccak256Hash
32-byte hash
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
Example
RATE
RATE: number
Rate in bytes for Keccak256 (136 bytes = 1088 bits)
Since
0.0.0selector()
selector: (Compute function selector (first 4 bytes of Keccak-256 hash) Used for Ethereum function signatures.signature) =>Uint8Array<ArrayBufferLike>
Parameters
signature
string
Function signature string
Returns
Uint8Array<ArrayBufferLike>
4-byte selector
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
Example
STATE_SIZE
STATE_SIZE: number
State size (25 u64 words = 1600 bits)
Since
0.0.0topic()
topic: (Compute event topic (32-byte Keccak-256 hash) Used for Ethereum event signatures.signature) =>Keccak256Hash
Parameters
signature
string
Event signature string
Returns
Keccak256Hash
32-byte topic
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
Example
Type Declaration
_wasm
_wasm:object=Keccak256Wasm
_wasm.contractAddress()
contractAddress: (Compute CREATE contract addresssender,nonce) =>Uint8Array
Parameters
sender
Uint8Array
Sender address (20 bytes)
nonce
bigint
Transaction nonce
Returns
Uint8Array
Contract address (20 bytes)
_wasm.create2Address()
create2Address: (Compute CREATE2 contract addresssender,salt,initCodeHash) =>Uint8Array
Parameters
sender
Uint8Array
Sender address (20 bytes)
salt
Uint8Array
Salt (32 bytes)
initCodeHash
Uint8Array
Init code hash (32 bytes)
Returns
Uint8Array
Contract address (20 bytes)
_wasm.DIGEST_SIZE
DIGEST_SIZE:number=32
_wasm.hash()
hash: (Hash bytes using Keccak256data) =>HashType
Parameters
data
Uint8Array
Input bytes to hash
Returns
HashType
32-byte Keccak256 hash
_wasm.hashHex()
hashHex: (Hash a hex stringhex) =>HashType
Parameters
hex
string
Hex string to hash (with or without 0x prefix)
Returns
HashType
32-byte Keccak256 hash
_wasm.hashMultiple()
hashMultiple: (Hash multiple byte arrays in sequencechunks) =>HashType
Parameters
chunks
Uint8Array<ArrayBufferLike>[]
Array of byte arrays to hash
Returns
HashType
32-byte Keccak256 hash
_wasm.hashString()
hashString: (Hash a UTF-8 stringstr) =>HashType
Parameters
str
string
String to hash
Returns
HashType
32-byte Keccak256 hash
_wasm.init()
init: () =>Initialize WASM module (must be called before using any functions)Promise<void>
Returns
Promise<void>
_wasm.isReady()
isReady: () => boolean
Check if WASM is initialized
Returns
boolean
_wasm.RATE
RATE:number=136
_wasm.selector()
selector: (Compute function selector (first 4 bytes of hash)signature) =>Uint8Array
Parameters
signature
string
Function signature string (e.g., “transfer(address,uint256)“)
Returns
Uint8Array
4-byte function selector
_wasm.STATE_SIZE
STATE_SIZE:number=25
_wasm.topic()
topic: (Compute event topic (full 32-byte hash)signature) =>HashType
Parameters
signature
string
Event signature string (e.g., “Transfer(address,address,uint256)“)
Returns
HashType
32-byte event topic as HashType
Keccak256Wasm
Defined in: src/crypto/keccak256.wasm.ts:238constKeccak256Wasm:object
Type Declaration
contractAddress()
contractAddress: (Compute CREATE contract addresssender,nonce) =>Uint8Array
Parameters
sender
Uint8Array
Sender address (20 bytes)
nonce
bigint
Transaction nonce
Returns
Uint8Array
Contract address (20 bytes)
create2Address()
create2Address: (Compute CREATE2 contract addresssender,salt,initCodeHash) =>Uint8Array
Parameters
sender
Uint8Array
Sender address (20 bytes)
salt
Uint8Array
Salt (32 bytes)
initCodeHash
Uint8Array
Init code hash (32 bytes)
Returns
Uint8Array
Contract address (20 bytes)
DIGEST_SIZE
DIGEST_SIZE:number=32
hash()
hash: (Hash bytes using Keccak256data) =>HashType
Parameters
data
Uint8Array
Input bytes to hash
Returns
HashType
32-byte Keccak256 hash
hashHex()
hashHex: (Hash a hex stringhex) =>HashType
Parameters
hex
string
Hex string to hash (with or without 0x prefix)
Returns
HashType
32-byte Keccak256 hash
hashMultiple()
hashMultiple: (Hash multiple byte arrays in sequencechunks) =>HashType
Parameters
chunks
Uint8Array<ArrayBufferLike>[]
Array of byte arrays to hash
Returns
HashType
32-byte Keccak256 hash
hashString()
hashString: (Hash a UTF-8 stringstr) =>HashType
Parameters
str
string
String to hash
Returns
HashType
32-byte Keccak256 hash
init()
init: () =>Initialize WASM module (must be called before using any functions)Promise<void>
Returns
Promise<void>
isReady()
isReady: () => boolean
Check if WASM is initialized
Returns
boolean
RATE
RATE:number=136
selector()
selector: (Compute function selector (first 4 bytes of hash)signature) =>Uint8Array
Parameters
signature
string
Function signature string (e.g., “transfer(address,uint256)“)
Returns
Uint8Array
4-byte function selector
STATE_SIZE
STATE_SIZE:number=25
topic()
topic: (Compute event topic (full 32-byte hash)signature) =>HashType
Parameters
signature
string
Event signature string (e.g., “Transfer(address,address,uint256)“)
Returns
HashType
32-byte event topic as HashType
KZG
Defined in: src/wasm/index.ts:254constKZG: typeofKZG=KZGJS
ModExp
Defined in: src/wasm/index.ts:255constModExp: (base,exp,modulus) =>bigint&object=ModExpJS
Type Declaration
calculateGas()
calculateGas: (Calculate gas cost for MODEXP operation per EIP-2565 Gas formula: max(200, floor(mult_complexity * iteration_count / 3))baseLen,expLen,modLen,expHead) =>bigint
Parameters
baseLen
bigint
Length of base in bytes
expLen
bigint
Length of exponent in bytes
modLen
bigint
Length of modulus in bytes
expHead
bigint
First 32 bytes of exponent as BigInt (for leading zeros calc)
Returns
bigint
Gas cost
See
https://eips.ethereum.org/EIPS/eip-2565Since
0.0.0Example
modexp()
modexp: (Modular exponentiation: base^exp mod modulus Computes arbitrary-precision modular exponentiation using native BigInt. Used by MODEXP precompile (0x05) per EIP-198. WARNING: This implementation is for general use. For cryptographic applications, consider timing attack resistance.base,exp,modulus) =>bigint
Parameters
base
bigint
Base value
exp
bigint
Exponent value
modulus
bigint
Modulus value (must be > 0)
Returns
bigint
Result of base^exp mod modulus
See
https://eips.ethereum.org/EIPS/eip-198Since
0.0.0Throws
If modulus is zeroExample
modexpBytes()
modexpBytes: (Modular exponentiation with byte array inputs/outputs Computes base^exp mod modulus where inputs are big-endian byte arrays. Output is padded to modulus length per EIP-198 spec.baseBytes,expBytes,modBytes) =>Uint8Array<ArrayBufferLike>
Parameters
baseBytes
Uint8Array<ArrayBufferLike>
Base as big-endian bytes
expBytes
Uint8Array<ArrayBufferLike>
Exponent as big-endian bytes
modBytes
Uint8Array<ArrayBufferLike>
Modulus as big-endian bytes
Returns
Uint8Array<ArrayBufferLike>
Result as big-endian bytes, padded to modulus length
See
https://eips.ethereum.org/EIPS/eip-198Since
0.0.0Throws
If modulus is zeroExample
Opcode
Defined in: src/wasm/index.ts:239constOpcode: typeofOpcode=OpcodeJS
P256
Defined in: src/wasm/index.ts:200 P256 with WASM accelerationconstP256:P256Constructor&object
Type Declaration
_wasm
_wasm: typeofP256Wasm=P256Wasm
Ripemd160
Defined in: src/wasm/index.ts:179 Ripemd160 with WASM accelerationconstRipemd160: (input) =>Ripemd160Hash&object&object
Type Declaration
from()
from: (Hash input with RIPEMD160 (constructor pattern) Auto-detects input type and hashes accordingly:input) =>Ripemd160Hash
- Uint8Array: hash directly
- string: UTF-8 encode then hash
Parameters
input
Data to hashstring | Uint8Array<ArrayBufferLike>
Returns
Ripemd160Hash
20-byte hash
See
https://voltaire.tevm.sh/crypto/ripemd160 for crypto documentationSince
0.0.0Throws
Example
fromHex()
fromHex: (Compute RIPEMD160 hash of hex string (without 0x prefix)hex) =>Ripemd160Hash=hashHex
Parameters
hex
string
Hex string (with or without 0x prefix)
Returns
Ripemd160Hash
20-byte hash
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
Example
fromString()
fromString: (Compute RIPEMD160 hash of UTF-8 stringstr) =>Ripemd160Hash=hashString
Parameters
str
string
Input string
Returns
Ripemd160Hash
20-byte hash
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
Example
hash()
hash: (Compute RIPEMD160 hash (20 bytes)data) =>Ripemd160Hash
Parameters
data
Input data (Uint8Array or string)string | Uint8Array<ArrayBufferLike>
Returns
Ripemd160Hash
20-byte hash
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
Example
hashHex()
hashHex: (Compute RIPEMD160 hash of hex string (without 0x prefix)hex) =>Ripemd160Hash
Parameters
hex
string
Hex string (with or without 0x prefix)
Returns
Ripemd160Hash
20-byte hash
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
Example
hashString()
hashString: (Compute RIPEMD160 hash of UTF-8 stringstr) =>Ripemd160Hash
Parameters
str
string
Input string
Returns
Ripemd160Hash
20-byte hash
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
Example
HEX_SIZE
HEX_SIZE: number
Size of RIPEMD160 hash in hex characters (without 0x prefix)
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
Example
SIZE
SIZE: number
Size of RIPEMD160 hash in bytes (160 bits)
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
Example
Type Declaration
_wasm
_wasm: typeofRipemd160Wasm=Ripemd160Wasm
Rlp
Defined in: src/wasm/index.ts:233constRlp: typeofRlp=RlpJS
Secp256k1
Defined in: src/wasm/index.ts:186 Secp256k1 with WASM accelerationconstSecp256k1:object&object
Type Declaration
addPoints()
addPoints: (Add two secp256k1 public key points Performs elliptic curve point addition: P1 + P2. Used in ERC-5564 stealth address generation.pubKey1,pubKey2) =>Secp256k1PublicKeyType
Parameters
pubKey1
Secp256k1PublicKeyType
First 64-byte uncompressed public key
pubKey2
Secp256k1PublicKeyType
Second 64-byte uncompressed public key
Returns
Secp256k1PublicKeyType
Result 64-byte uncompressed public key
See
- https://voltaire.tevm.sh/crypto for crypto documentation
- https://eips.ethereum.org/EIPS/eip-5564 for ERC-5564 stealth addresses
Since
0.0.0Throws
If either public key is invalidThrows
If point addition failsExample
createKeyPair()
createKeyPair: () => object
Generate a new secp256k1 key pair
Returns
object
Key pair with 32-byte private key and 65-byte uncompressed public key
privateKey
privateKey: Uint8Array
publicKey
publicKey: Uint8Array
Example
CURVE_ORDER
CURVE_ORDER: bigint
secp256k1 curve order (number of points on the curve)
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
Example
derivePublicKey()
derivePublicKey: (Derive public key from private key Computes the public key point from a private key using scalar multiplication on the secp256k1 curve.privateKey) =>Secp256k1PublicKeyType
Parameters
privateKey
PrivateKeyType
32-byte private key
Returns
Secp256k1PublicKeyType
64-byte uncompressed public key
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
If private key is invalidExample
ecdh()
ecdh: (Perform ECDH key exchange Computes shared secret from your private key and their public key. Returns the x-coordinate of the shared point (32 bytes).privateKey,publicKey) =>Uint8Array<ArrayBufferLike>
Parameters
privateKey
PrivateKeyType
Your 32-byte private key
publicKey
Secp256k1PublicKeyType
Their 64-byte uncompressed public key
Returns
Uint8Array<ArrayBufferLike>
32-byte shared secret (x-coordinate)
See
- https://voltaire.tevm.sh/crypto for crypto documentation
- https://eips.ethereum.org/EIPS/eip-5564 for ERC-5564 stealth addresses
Since
0.0.0Throws
If private key is invalidThrows
If public key is invalidThrows
If ECDH computation failsExample
getSharedSecret()
getSharedSecret: (Perform ECDH key exchange Computes shared secret from your private key and their public key. Returns the x-coordinate of the shared point (32 bytes).privateKey,publicKey) =>Uint8Array<ArrayBufferLike> =ecdh
Parameters
privateKey
PrivateKeyType
Your 32-byte private key
publicKey
Secp256k1PublicKeyType
Their 64-byte uncompressed public key
Returns
Uint8Array<ArrayBufferLike>
32-byte shared secret (x-coordinate)
See
- https://voltaire.tevm.sh/crypto for crypto documentation
- https://eips.ethereum.org/EIPS/eip-5564 for ERC-5564 stealth addresses
Since
0.0.0Throws
If private key is invalidThrows
If public key is invalidThrows
If ECDH computation failsExample
isValidPrivateKey()
isValidPrivateKey: (Validate private key Checks that the private key is within valid range [1, n-1] where n is the curve order.privateKey) =>boolean
Parameters
privateKey
Uint8Array<ArrayBufferLike>
32-byte private key
Returns
boolean
true if private key is valid, false otherwise
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
Example
isValidPublicKey()
isValidPublicKey: (Validate public key Checks that the public key is a valid point on the secp256k1 curve.publicKey) =>publicKey is Secp256k1PublicKeyType
Parameters
publicKey
Uint8Array<ArrayBufferLike>
64-byte uncompressed public key
Returns
publicKey is Secp256k1PublicKeyType
true if public key is valid, false otherwise
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
Example
isValidSignature()
isValidSignature: (Validate signature components Checks that r and s are within valid range [1, n-1] where n is the curve order. Also enforces low-s values to prevent malleability.signature) =>boolean
Parameters
signature
Secp256k1SignatureType
ECDSA signature to validate (r and s are HashType)
Returns
boolean
true if signature is valid, false otherwise
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
Example
PRIVATE_KEY_SIZE
PRIVATE_KEY_SIZE: number
Private key size in bytes
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
Example
PrivateKey
PrivateKey:__module=PrivateKeyMethods
PUBLIC_KEY_SIZE
PUBLIC_KEY_SIZE: number
Uncompressed public key size in bytes (64 bytes, no prefix)
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
Example
PublicKey
PublicKey:__module=PublicKeyMethods
randomPrivateKey()
randomPrivateKey: () =>Generate a cryptographically secure random secp256k1 private keyUint8Array<ArrayBufferLike>
Returns
Uint8Array<ArrayBufferLike>
32-byte private key
Example
recoverPublicKey()
recoverPublicKey: (Recover public key from signature and message hash Uses the recovery id (v) to recover the exact public key that created the signature. This is what enables Ethereum’s address recovery from transaction signatures.signature,messageHash) =>Secp256k1PublicKeyType
Parameters
signature
ECDSA signature componentsr
Uint8Array<ArrayBufferLike>
32-byte signature component r
s
Uint8Array<ArrayBufferLike>
32-byte signature component s
v
number
Recovery id (27/28 or 0/1)
messageHash
HashType
32-byte message hash that was signed
Returns
Secp256k1PublicKeyType
64-byte uncompressed public key
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
If signature or recovery failsExample
recoverPublicKeyFromHash()
recoverPublicKeyFromHash: (Recover public key from signature and pre-hashed message This is the hash-level API that operates directly on a 32-byte hash. Use this when you need custom hashing schemes or interop with other libraries. For standard Ethereum signing, use recoverPublicKey() instead. Uses the recovery id (v) to recover the exact public key that created the signature. This is what enables Ethereum’s address recovery from transaction signatures.signature,hash) =>Secp256k1PublicKeyType
Parameters
signature
ECDSA signature componentsr
Uint8Array<ArrayBufferLike>
32-byte signature component r
s
Uint8Array<ArrayBufferLike>
32-byte signature component s
v
number
Recovery id (27/28 or 0/1)
hash
HashType
32-byte hash that was signed (pre-hashed message)
Returns
Secp256k1PublicKeyType
64-byte uncompressed public key
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
If signature or recovery failsThrows
If hash is not 32 bytesExample
scalarMultiply()
scalarMultiply: (Multiply generator point by scalar Performs scalar multiplication: scalar * G (generator point). Used in ERC-5564 stealth address generation.scalar) =>Secp256k1PublicKeyType
Parameters
scalar
Uint8Array<ArrayBufferLike>
32-byte scalar value
Returns
Secp256k1PublicKeyType
Result 64-byte uncompressed public key
See
- https://voltaire.tevm.sh/crypto for crypto documentation
- https://eips.ethereum.org/EIPS/eip-5564 for ERC-5564 stealth addresses
Since
0.0.0Throws
If scalar multiplication failsExample
sign()
sign: (Sign a message hash with a private key Uses deterministic ECDSA (RFC 6979) for signature generation. Returns signature with Ethereum-compatible v value (27 or 28).messageHash,privateKey) =>Secp256k1SignatureType
Parameters
messageHash
HashType
32-byte message hash to sign
privateKey
PrivateKeyType
32-byte private key
Returns
Secp256k1SignatureType
ECDSA signature with r, s, v components
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
If private key is invalidThrows
If signing failsExample
Signature
Signature:__module=SignatureMethods
SIGNATURE_COMPONENT_SIZE
SIGNATURE_COMPONENT_SIZE: number
Signature component size in bytes (r and s are each 32 bytes)
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
Example
signHash()
signHash: (Sign a pre-hashed message with a private key This is the hash-level API that operates directly on a 32-byte hash. Use this when you need custom hashing schemes or interop with other libraries. For standard Ethereum signing, use sign() instead. Uses deterministic ECDSA (RFC 6979) for signature generation. Returns signature with Ethereum-compatible v value (27 or 28).hash,privateKey) =>Secp256k1SignatureType
Parameters
hash
HashType
32-byte hash to sign (pre-hashed message)
privateKey
PrivateKeyType
32-byte private key
Returns
Secp256k1SignatureType
ECDSA signature with r, s, v components
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
If private key is invalidThrows
If signing fails or hash is not 32 bytesExample
verify()
verify: (Verify an ECDSA signaturesignature,messageHash,publicKey) =>boolean
Parameters
signature
Secp256k1SignatureType
ECDSA signature with r, s, v components (r and s are HashType)
messageHash
HashType
32-byte message hash that was signed
publicKey
Secp256k1PublicKeyType
64-byte uncompressed public key
Returns
boolean
true if signature is valid, false otherwise
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
If signature v is invalidExample
verifyHash()
verifyHash: (Verify an ECDSA signature against a pre-hashed message This is the hash-level API that operates directly on a 32-byte hash. Use this when you need custom hashing schemes or interop with other libraries. For standard Ethereum signing, use verify() instead.signature,hash,publicKey) =>boolean
Parameters
signature
Secp256k1SignatureType
ECDSA signature with r, s, v components (r and s are HashType)
hash
HashType
32-byte hash that was signed (pre-hashed message)
publicKey
Secp256k1PublicKeyType
64-byte uncompressed public key
Returns
boolean
true if signature is valid, false otherwise
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
If hash is not 32 bytesExample
Type Declaration
_wasm
_wasm: typeofSecp256k1Wasm=Secp256k1Wasm
SHA256
Defined in: src/wasm/index.ts:165 SHA256 with WASM accelerationconstSHA256: (input) =>SHA256Hash&object&object
Type Declaration
BLOCK_SIZE
BLOCK_SIZE: number
SHA256 block size in bytes
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
Example
create()
create: () => object
Incremental hasher for streaming data
Returns
object
Hasher instance
digest()
digest: () => Uint8Array
Returns
Uint8Array
update()
update: (data) =>void
Parameters
data
Uint8Array
Returns
void
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
Example
from()
from: (Hash input with SHA256 (constructor pattern) Auto-detects input type and hashes accordingly:input) =>SHA256Hash
- Uint8Array: hash directly
- string starting with 0x: parse as hex
- string: UTF-8 encode then hash
Parameters
input
Data to hashstring | Uint8Array<ArrayBufferLike>
Returns
SHA256Hash
32-byte hash
See
https://voltaire.tevm.sh/crypto/sha256 for crypto documentationSince
0.0.0Throws
Example
fromHex()
fromHex: (Compute SHA256 hash of hex string (without 0x prefix)hex) =>SHA256Hash=hashHex
Parameters
hex
string
Hex string (with or without 0x prefix)
Returns
SHA256Hash
32-byte hash
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
Example
fromString()
fromString: (Compute SHA256 hash of UTF-8 stringstr) =>SHA256Hash=hashString
Parameters
str
string
Input string
Returns
SHA256Hash
32-byte hash
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
Example
hash()
hash: (Compute SHA256 hash of input datadata) =>SHA256Hash
Parameters
data
Uint8Array<ArrayBufferLike>
Input data as Uint8Array
Returns
SHA256Hash
32-byte hash
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
Example
hashHex()
hashHex: (Compute SHA256 hash of hex string (without 0x prefix)hex) =>SHA256Hash
Parameters
hex
string
Hex string (with or without 0x prefix)
Returns
SHA256Hash
32-byte hash
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
Example
hashString()
hashString: (Compute SHA256 hash of UTF-8 stringstr) =>SHA256Hash
Parameters
str
string
Input string
Returns
SHA256Hash
32-byte hash
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
Example
OUTPUT_SIZE
OUTPUT_SIZE: number
SHA256 output size in bytes (256 bits / 8)
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
Example
toHex()
toHex: (Convert hash output to hex stringhash) =>string
Parameters
hash
Uint8Array<ArrayBufferLike>
Hash bytes
Returns
string
Hex string with 0x prefix
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
Example
Type Declaration
_wasm
_wasm: typeofSha256Wasm=Sha256Wasm
Siwe
Defined in: src/wasm/index.ts:241constSiwe: typeofSiwe=SiweJS
StorageKey
Defined in: src/wasm/index.ts:244constStorageKey:object=StorageKeyJS
Type Declaration
create()
create: (address,slot) =>StorageKeyType
Parameters
address
AddressType
slot
bigint
Returns
StorageKeyType
equals()
equals: (a,b) =>boolean
Parameters
a
StorageKeyLike
b
StorageKeyLike
Returns
boolean
from()
from: (value) =>StorageKeyType
Parameters
value
StorageKeyLike
Returns
StorageKeyType
fromString()
fromString: (str) =>StorageKeyType|undefined
Parameters
str
string
Returns
StorageKeyType | undefined
hashCode()
hashCode: (key) =>number
Parameters
key
StorageKeyLike
Returns
number
is()
is: (value) =>value is StorageKeyType
Parameters
value
unknown
Returns
value is StorageKeyType
toString()
toString: (key) =>string
Parameters
key
StorageKeyLike
Returns
string
Uint
Defined in: src/wasm/index.ts:232constUint: typeofUint=UintJS
wasmAPI
Defined in: src/wasm/index.ts:264constwasmAPI:object
Type Declaration
Abi
Abi: typeof Abi
AccessList
AccessList: object
AccessList.ADDRESS_COST
ADDRESS_COST: bigint
Gas cost per address in access list (EIP-2930)
AccessList.addressCount()
addressCount: (list) =>number
Parameters
list
BrandedAccessList
Returns
number
AccessList.assertValid()
assertValid: (list) =>void
Parameters
list
BrandedAccessList
Returns
void
AccessList.COLD_ACCOUNT_ACCESS_COST
COLD_ACCOUNT_ACCESS_COST: bigint
Cold account access cost (pre-EIP-2930)
AccessList.COLD_STORAGE_ACCESS_COST
COLD_STORAGE_ACCESS_COST: bigint
Cold storage access cost (pre-EIP-2930)
AccessList.create()
create: () => BrandedAccessList
Returns
BrandedAccessList
AccessList.deduplicate()
deduplicate: (list) =>BrandedAccessList
Parameters
list
BrandedAccessList
Returns
BrandedAccessList
AccessList.from()
from: (value) =>BrandedAccessList
Parameters
value
Uint8Array<ArrayBufferLike> | readonly Item[]
Returns
BrandedAccessList
AccessList.fromBytes()
fromBytes: (bytes) =>BrandedAccessList
Parameters
bytes
Uint8Array
Returns
BrandedAccessList
AccessList.gasCost()
gasCost: (list) =>bigint
Parameters
list
BrandedAccessList
Returns
bigint
AccessList.gasSavings()
gasSavings: (list) =>bigint
Parameters
list
BrandedAccessList
Returns
bigint
AccessList.hasSavings()
hasSavings: (list) =>boolean
Parameters
list
BrandedAccessList
Returns
boolean
AccessList.includesAddress()
includesAddress: (list,address) =>boolean
Parameters
list
BrandedAccessList
address
AddressType
Returns
boolean
AccessList.includesStorageKey()
includesStorageKey: (list,address,storageKey) =>boolean
Parameters
list
BrandedAccessList
address
AddressType
storageKey
HashType
Returns
boolean
AccessList.is()
is: (value) =>value is BrandedAccessList
Parameters
value
unknown
Returns
value is BrandedAccessList
AccessList.isEmpty()
isEmpty: (list) =>boolean
Parameters
list
BrandedAccessList
Returns
boolean
AccessList.isItem()
isItem: (value) =>value is Item
Parameters
value
unknown
Returns
value is Item
AccessList.keysFor()
keysFor: (list,address) => readonlyHashType[] |undefined
Parameters
list
BrandedAccessList
address
AddressType
Returns
readonlyHashType[] | undefined
AccessList.merge()
merge: (…accessLists) =>BrandedAccessList
Parameters
accessLists
…BrandedAccessList[]
Returns
BrandedAccessList
AccessList.STORAGE_KEY_COST
STORAGE_KEY_COST: bigint
Gas cost per storage key in access list (EIP-2930)
AccessList.storageKeyCount()
storageKeyCount: (list) =>number
Parameters
list
BrandedAccessList
Returns
number
AccessList.toBytes()
toBytes: (list) =>Uint8Array
Parameters
list
BrandedAccessList
Returns
Uint8Array
AccessList.WARM_STORAGE_ACCESS_COST
WARM_STORAGE_ACCESS_COST: bigint
Warm storage access cost (post-EIP-2929)
AccessList.withAddress()
withAddress: (list,address) =>BrandedAccessList
Parameters
list
BrandedAccessList
address
AddressType
Returns
BrandedAccessList
AccessList.withStorageKey()
withStorageKey: (list,address,storageKey) =>BrandedAccessList
Parameters
list
BrandedAccessList
address
AddressType
storageKey
HashType
Returns
BrandedAccessList
Address
Address: typeof Address
Blake2
Blake2: (Blake2 with WASM accelerationinput,outputLength?) =>Blake2Hash&object&object
Type Declaration
from()
from: (Hash input with BLAKE2b (constructor pattern) Auto-detects input type and hashes accordingly:input,outputLength?) =>Blake2Hash
- Uint8Array: hash directly
- string: UTF-8 encode then hash
Parameters
input
Data to hashstring | Uint8Array<ArrayBufferLike>
outputLength?
number = 64
Output length in bytes (1-64, default 64)
Returns
Blake2Hash
BLAKE2b hash
See
https://voltaire.tevm.sh/crypto/blake2 for crypto documentationSince
0.0.0Throws
If outputLength is invalidExample
fromString()
fromString: (Hash string with BLAKE2b (convenience function)str,outputLength?) =>Blake2Hash=hashString
Parameters
str
string
Input string to hash
outputLength?
number = 64
Output length in bytes (1-64, default 64)
Returns
Blake2Hash
BLAKE2b hash
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
If outputLength is invalidExample
hash()
hash: (Hash data with BLAKE2bdata,outputLength?) =>Blake2Hash
Parameters
data
Input data to hash (Uint8Array or string)string | Uint8Array<ArrayBufferLike>
outputLength?
number = 64
Output length in bytes (1-64, default 64)
Returns
Blake2Hash
BLAKE2b hash
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
If outputLength is invalidExample
hashString()
hashString: (Hash string with BLAKE2b (convenience function)str,outputLength?) =>Blake2Hash
Parameters
str
string
Input string to hash
outputLength?
number = 64
Output length in bytes (1-64, default 64)
Returns
Blake2Hash
BLAKE2b hash
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
If outputLength is invalidExample
SIZE
SIZE: number
Type Declaration
_wasm
_wasm: typeofBlake2Wasm=Blake2Wasm
Blob
Blob: typeof Blob
BloomFilter
BloomFilter: typeof BloomFilter
Bls12381
Bls12381: object
Bls12381.aggregate()
aggregate: (Aggregate multiple BLS signatures into one The aggregated signature can be verified against an aggregated public key (when all signers signed the same message) or via batch verification (when signers signed different messages).signatures) =>Uint8Array<ArrayBufferLike>
Parameters
signatures
Uint8Array<ArrayBufferLike>[]
Array of compressed G1 signatures (48 bytes each)
Returns
Uint8Array<ArrayBufferLike>
Aggregated signature (48 bytes compressed G1)
Throws
If aggregation fails or no signatures providedExample
Bls12381.aggregatePublicKeys()
aggregatePublicKeys: (Aggregate multiple public keys into one Used when multiple signers sign the same message and you want to verify against a single aggregated public key.publicKeys) =>Uint8Array<ArrayBufferLike>
Parameters
publicKeys
Uint8Array<ArrayBufferLike>[]
Array of compressed G2 public keys (96 bytes each)
Returns
Uint8Array<ArrayBufferLike>
Aggregated public key (96 bytes compressed G2)
Throws
If aggregation fails or no public keys providedExample
Bls12381.aggregateVerify()
aggregateVerify: (Verify an aggregated signature where all signers signed the same message This is the most common case in Ethereum consensus - multiple validators sign the same block/attestation.aggregatedSignature,message,publicKeys) =>boolean
Parameters
aggregatedSignature
Uint8Array<ArrayBufferLike>
Aggregated signature (96 bytes)
message
Uint8Array<ArrayBufferLike>
The message that was signed by all parties
publicKeys
Uint8Array<ArrayBufferLike>[]
Public keys of all signers (48 bytes each)
Returns
boolean
True if the aggregated signature is valid
Example
Bls12381.batchVerify()
batchVerify: (Verify an aggregated signature where each signer signed a different message Uses multi-pairing verification: product of e(pk_i, H(msg_i)) == e(G1, aggSig)aggregatedSignature,messages,publicKeys) =>boolean
Parameters
aggregatedSignature
Uint8Array<ArrayBufferLike>
Aggregated signature (96 bytes)
messages
Uint8Array<ArrayBufferLike>[]
Messages that were signed (one per signer)
publicKeys
Uint8Array<ArrayBufferLike>[]
Public keys (one per signer, same order as messages)
Returns
boolean
True if the aggregated signature is valid
Throws
If messages and publicKeys have different lengthsExample
Bls12381.derivePublicKey()
derivePublicKey: (Derive a BLS12-381 public key from a private key Public key = privateKey * G2_generatorprivateKey) =>Uint8Array<ArrayBufferLike>
Parameters
privateKey
Uint8Array<ArrayBufferLike>
32-byte private key (scalar in Fr)
Returns
Uint8Array<ArrayBufferLike>
Compressed G2 public key (96 bytes)
Throws
If private key is invalidExample
Bls12381.derivePublicKeyPoint()
derivePublicKeyPoint: (Derive a BLS12-381 public key as a G1 point (uncompressed)privateKey) =>Bls12381G1PointType
Parameters
privateKey
Uint8Array<ArrayBufferLike>
32-byte private key
Returns
Bls12381G1PointType
Public key as G1 point
Throws
If private key is invalidBls12381.fastAggregateVerify()
fastAggregateVerify: (Fast aggregate verify (same message case) Optimized for the common case where all signers signed the same message. This is faster than aggregateVerify when you already have the aggregated public key.aggregatedSignature,message,aggregatedPublicKey) =>boolean
Parameters
aggregatedSignature
Uint8Array<ArrayBufferLike>
Aggregated signature (96 bytes)
message
Uint8Array<ArrayBufferLike>
The message that was signed
aggregatedPublicKey
Uint8Array<ArrayBufferLike>
Pre-computed aggregated public key (48 bytes)
Returns
boolean
True if valid
Bls12381.Fp
Fp: Fp
Bls12381.Fp2
Fp2: Fp2
Bls12381.Fr
Fr: Fr
Bls12381.G1
G1: G1
Bls12381.G2
G2: G2
Bls12381.isValidPrivateKey()
isValidPrivateKey: (Check if a private key is valid A valid private key must be:privateKey) =>boolean
- 32 bytes
- Non-zero
- Less than the curve order (Fr modulus)
Parameters
privateKey
Uint8Array<ArrayBufferLike>
Private key to validate
Returns
boolean
True if valid
Example
Bls12381.Pairing
Pairing: Pairing
BLS12-381 Pairing Operations
Optimal Ate pairing implementation for BLS12-381.
e: G1 x G2 -> GT
NOTE: Full pairing implementation requires Fp6, Fp12 tower extensions
and Miller loop computation. For production use, the native blst
library should be used via the Zig FFI bindings.
This module provides the interface and simplified implementations
for testing and educational purposes.
See
https://hackmd.io/@benjaminion/bls12-381 for pairing detailsSince
0.0.0Bls12381.randomPrivateKey()
randomPrivateKey: () =>Generate a random BLS12-381 private key Uses cryptographically secure random number generation. The key is guaranteed to be valid (non-zero and less than curve order).Uint8Array<ArrayBufferLike>
Returns
Uint8Array<ArrayBufferLike>
32-byte private key
Example
Bls12381.sign()
sign: (Sign a message using BLS12-381 Uses the Ethereum consensus “short signatures” scheme:message,privateKey) =>Uint8Array<ArrayBufferLike>
- Signature = privateKey * H(message) where H maps to G1
- Signatures are 48 bytes (compressed G1 point)
Parameters
message
Uint8Array<ArrayBufferLike>
Message to sign
privateKey
Uint8Array<ArrayBufferLike>
32-byte private key (scalar in Fr)
Returns
Uint8Array<ArrayBufferLike>
Signature as compressed G1 point (48 bytes)
Throws
If private key is invalidThrows
If signing failsExample
Bls12381.signPoint()
signPoint: (Sign a pre-hashed message (G2 point) using BLS12-381 For advanced use when you have already hashed the message to G2.messagePoint,privateKey) =>Bls12381G2PointType
Parameters
messagePoint
Bls12381G2PointType
Message as G2 point
privateKey
Uint8Array<ArrayBufferLike>
32-byte private key (scalar in Fr)
Returns
Bls12381G2PointType
Signature as G2 point (projective)
Throws
If private key is invalidThrows
If signing failsBls12381.verify()
verify: (Verify a BLS12-381 signature Uses pairing check for verification.signature,message,publicKey) =>boolean
Parameters
signature
Uint8Array<ArrayBufferLike>
Compressed G1 signature (48 bytes)
message
Uint8Array<ArrayBufferLike>
Original message that was signed
publicKey
Uint8Array<ArrayBufferLike>
Compressed G2 public key (96 bytes)
Returns
boolean
True if signature is valid
Throws
If verification fails due to invalid inputsExample
Bls12381.verifyPoint()
verifyPoint: (Verify a BLS signature with pre-computed points (advanced) For use when you have already deserialized the points.signaturePoint,messagePoint,publicKeyPoint) =>boolean
Parameters
signaturePoint
Bls12381G2PointType
Signature as G2 point
messagePoint
Bls12381G2PointType
Message hash as G2 point
publicKeyPoint
Bls12381G1PointType
Public key as G1 point
Returns
boolean
True if signature is valid
BN254
BN254:BN254 with WASM accelerationobject&object
Type Declaration
deserializeG1()
deserializeG1: (Deserialize G1 point from bytesbytes) =>G1PointType
Parameters
bytes
Uint8Array<ArrayBufferLike>
64-byte serialization
Returns
G1PointType
G1 point
See
https://voltaire.tevm.sh/crypto for BN254 cryptography documentationSince
0.0.0Throws
If bytes length is invalid (must be 64 bytes)Example
deserializeG2()
deserializeG2: (Deserialize G2 point from bytesbytes) =>G2PointType
Parameters
bytes
Uint8Array<ArrayBufferLike>
128-byte serialization
Returns
G2PointType
G2 point
See
https://voltaire.tevm.sh/crypto for BN254 cryptography documentationSince
0.0.0Throws
If bytes length is invalid (must be 128 bytes)Example
Fp
Fp: __module
Fp2
Fp2: __module
Fr
Fr: __module
G1
G1: __module
G2
G2: __module
Pairing
Pairing: __module
serializeG1()
serializeG1: (Serialize G1 point to bytes (64 bytes: x || y)point) =>Uint8Array<ArrayBufferLike>
Parameters
point
G1PointType
G1 point
Returns
Uint8Array<ArrayBufferLike>
64-byte serialization
See
https://voltaire.tevm.sh/crypto for BN254 cryptography documentationSince
0.0.0Throws
Example
serializeG2()
serializeG2: (Serialize G2 point to bytes (128 bytes: x.c0 || x.c1 || y.c0 || y.c1)point) =>Uint8Array<ArrayBufferLike>
Parameters
point
G2PointType
G2 point
Returns
Uint8Array<ArrayBufferLike>
128-byte serialization
See
https://voltaire.tevm.sh/crypto for BN254 cryptography documentationSince
0.0.0Throws
Example
Type Declaration
_wasm
_wasm: typeofBn254Wasm=Bn254Wasm
Bytecode
Bytecode: typeof Bytecode
Bytes
Bytes: typeof Bytes
Bytes32
Bytes32: typeof Bytes32
Chain
Chain: typeof Chain
Ed25519
Ed25519:Ed25519 with WASM accelerationobject&object
Type Declaration
derivePublicKey()
derivePublicKey: (Derive Ed25519 public key from secret key.secretKey) =>PublicKey
Parameters
secretKey
SecretKey
32-byte Ed25519 secret key (seed)
Returns
PublicKey
32-byte Ed25519 public key
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
If secret key length is invalid or derivation failsExample
keypairFromSeed()
keypairFromSeed: (Generate Ed25519 keypair from seed deterministically.seed) =>object
Parameters
seed
Seed
32-byte seed for deterministic keypair generation
Returns
object
Object containing 32-byte secretKey and 32-byte publicKey
publicKey
publicKey: PublicKey
secretKey
secretKey: SecretKey
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
If seed length is not 32 bytesThrows
If keypair generation failsExample
PUBLIC_KEY_SIZE
PUBLIC_KEY_SIZE: 32
Ed25519 public key size in bytes.
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Example
SECRET_KEY_SIZE
SECRET_KEY_SIZE: 32
Ed25519 secret key size in bytes.
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Example
SEED_SIZE
SEED_SIZE: 32
Ed25519 seed size in bytes.
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Example
sign()
sign: (Sign message with Ed25519 secret key. Produces deterministic signatures using EdDSA.message,secretKey) =>Signature
Parameters
message
Uint8Array<ArrayBufferLike>
Message bytes to sign (any length)
secretKey
SecretKey
32-byte Ed25519 secret key
Returns
Signature
64-byte Ed25519 signature
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
If secret key length is not 32 bytesThrows
If signing operation failsExample
SIGNATURE_SIZE
SIGNATURE_SIZE: 64
Ed25519 signature size in bytes.
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Example
validatePublicKey()
validatePublicKey: (Validate Ed25519 public key format and curve membership.publicKey) =>boolean
Parameters
publicKey
PublicKey
Ed25519 public key to validate
Returns
boolean
True if public key is valid and on curve, false otherwise
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
Example
validateSecretKey()
validateSecretKey: (Validate Ed25519 secret key format. Checks length and attempts public key derivation.secretKey) =>boolean
Parameters
secretKey
SecretKey
Ed25519 secret key to validate
Returns
boolean
True if secret key is valid (32 bytes and can derive public key), false otherwise
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
Example
validateSeed()
validateSeed: (Validate Ed25519 seed format. Checks if seed has correct 32-byte length.seed) =>boolean
Parameters
seed
Seed
Ed25519 seed to validate
Returns
boolean
True if seed is exactly 32 bytes, false otherwise
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
Example
verify()
verify: (Verify Ed25519 signature. Returns false on verification failure instead of throwing.signature,message,publicKey) =>boolean
Parameters
signature
Signature
64-byte Ed25519 signature to verify
message
Uint8Array<ArrayBufferLike>
Original message bytes that were signed
publicKey
PublicKey
32-byte Ed25519 public key
Returns
boolean
True if signature is cryptographically valid, false otherwise
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
If public key length is not 32 bytesThrows
If signature length is not 64 bytesExample
Type Declaration
_wasm
_wasm: typeofEd25519Wasm=Ed25519Wasm
EIP712
EIP712:EIP712 with WASM accelerationobject&object
Type Declaration
Domain
Domain: object
Domain.hash()
hash: (domain) =>HashType=hashDomain
Parameters
domain
Domain
Returns
HashType
encodeData()
encodeData: (primaryType,data,types) =>Uint8Array
Parameters
primaryType
string
data
Message
types
TypeDefinitions
Returns
Uint8Array
EncodeData()
EncodeData: (Factory: Encode struct data according to EIP-712.deps) => (primaryType,data,types) =>Uint8Array
Parameters
deps
Crypto dependenciesencodeValue
(type, value, types) => Uint8Array
Encode value function
hashType
(primaryType, types) => HashType
Hash type function
Returns
Function that encodes data(primaryType,data,types):Uint8Array
Parameters
primaryType
string
data
Message
types
TypeDefinitions
Returns
Uint8Array
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
If primaryType is not found in typesThrows
If required field is missing from dataExample
encodeType()
encodeType: (Encode type string for EIP-712 hashing. Produces type encoding like “Mail(Person from,Person to,string contents)Person(string name,address wallet)“primaryType,types) =>string
Parameters
primaryType
string
Primary type name to encode
types
TypeDefinitions
Type definitions mapping
Returns
string
Encoded type string with primary type followed by referenced types in alphabetical order
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
If primaryType or any referenced type is not foundExample
encodeValue()
encodeValue: (type,value,types) =>Uint8Array
Parameters
type
string
value
MessageValue
types
TypeDefinitions
Returns
Uint8Array
EncodeValue()
EncodeValue: (Factory: Encode single value to 32 bytes according to EIP-712. Handles primitive types, arrays, strings, bytes, and custom structs. Addresses must be pre-validated BrandedAddress types.deps) => (type,value,types) =>Uint8Array
Parameters
deps
Crypto dependencieshashStruct
(type, data, types) => HashType
Hash struct function
keccak256
(data) => Uint8Array
Keccak256 hash function
Returns
Function that encodes value(type,value,types):Uint8Array
Parameters
type
string
value
MessageValue
types
TypeDefinitions
Returns
Uint8Array
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
If type is unsupported or value format is invalidExample
format()
format: (Format typed data for human-readable display.typedData) =>string
Parameters
typedData
TypedData
Typed data to format
Returns
string
Human-readable multi-line string representation
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
Example
HashDomain()
HashDomain: (Factory: Hash EIP-712 domain separator. Only includes fields that are defined in the domain object.deps) => (domain) =>HashType
Parameters
deps
Crypto dependencieshashStruct
(primaryType, data, types) => HashType
Hash struct function
Returns
Function that hashes domain(domain):HashType
Parameters
domain
Domain
Returns
HashType
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
If domain type encoding failsExample
hashStruct()
hashStruct: (primaryType,data,types) =>HashType
Parameters
primaryType
string
data
Message
types
TypeDefinitions
Returns
HashType
HashStruct()
HashStruct: (Factory: Hash struct according to EIP-712 specification. Computes keccak256 of the encoded struct data.deps) => (primaryType,data,types) =>HashType
Parameters
deps
Crypto dependenciesencodeData
(primaryType, data, types) => Uint8Array
Encode data function
keccak256
(data) => Uint8Array
Keccak256 hash function
Returns
Function that hashes struct(primaryType,data,types):HashType
Parameters
primaryType
string
data
Message
types
TypeDefinitions
Returns
HashType
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
If type is not foundThrows
If message data is invalidExample
hashType()
hashType: (primaryType,types) =>HashType
Parameters
primaryType
string
types
TypeDefinitions
Returns
HashType
HashType()
HashType: (Factory: Hash type string according to EIP-712. Computes keccak256 of the encoded type string.deps) => (primaryType,types) =>HashType
Parameters
deps
Crypto dependencieskeccak256
(data) => Uint8Array
Keccak256 hash function
Returns
Function that hashes type string(primaryType,types):HashType
Parameters
primaryType
string
types
TypeDefinitions
Returns
HashType
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
If type is not foundExample
hashTypedData()
hashTypedData: (typedData) =>HashType
Parameters
typedData
TypedData
Returns
HashType
HashTypedData()
HashTypedData: (Factory: Hash typed data according to EIP-712 specification. Computes: keccak256(“\x19\x01” ‖ domainSeparator ‖ hashStruct(message))deps) => (typedData) =>HashType
Parameters
deps
Crypto dependencieshashDomain
(domain) => HashType
Hash domain function
hashStruct
(primaryType, data, types) => HashType
Hash struct function
keccak256
(data) => Uint8Array
Keccak256 hash function
Returns
Function that hashes typed data(typedData):HashType
Parameters
typedData
TypedData
Returns
HashType
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
If types are not foundThrows
If message data is invalidExample
recoverAddress()
recoverAddress: (signature,typedData) =>AddressType
Parameters
signature
Signature
typedData
TypedData
Returns
AddressType
RecoverAddress()
RecoverAddress: (Factory: Recover Ethereum address from EIP-712 typed data signature. Uses ECDSA public key recovery to determine the signer’s address.deps) => (signature,typedData) =>AddressType
Parameters
deps
Crypto dependencieshashTypedData
(typedData) => HashType
Hash typed data function
keccak256
(data) => Uint8Array
Keccak256 hash function
recoverPublicKey
(signature, hash, recoveryBit) => Uint8Array
Secp256k1 public key recovery function
Returns
Function that recovers address(signature,typedData):AddressType
Parameters
signature
Signature
typedData
TypedData
Returns
AddressType
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
If signature recovery fails or public key format is invalidExample
signTypedData()
signTypedData: (typedData,privateKey) =>Signature
Parameters
typedData
any
privateKey
any
Returns
Signature
SignTypedData()
SignTypedData: (Factory: Sign EIP-712 typed data with ECDSA private key. Produces a signature that can be verified against the signer’s address.deps) => (typedData,privateKey) =>Signature
Parameters
deps
Crypto dependencieshashTypedData
(typedData) => HashType
Hash typed data function
sign
(hash, privateKey) => Signature
Secp256k1 sign function
Returns
Function that signs typed data(typedData,privateKey):Signature
Parameters
typedData
TypedData
privateKey
Uint8Array
Returns
Signature
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
If private key length is invalid or signing failsExample
validate()
validate: (Validate typed data structure against EIP-712 specification. Checks domain, types, primaryType, and message structure.typedData) =>void
Parameters
typedData
TypedData
Typed data to validate
Returns
void
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
If structure is invalid or missing required fieldsExample
verifyTypedData()
verifyTypedData: (signature,typedData,address) =>boolean
Parameters
signature
Signature
typedData
TypedData
address
AddressType
Returns
boolean
VerifyTypedData()
VerifyTypedData: (Factory: Verify EIP-712 typed data signature against expected signer address. Uses constant-time comparison to prevent timing attacks.deps) => (signature,typedData,address) =>boolean
Parameters
deps
Crypto dependenciesrecoverAddress
(signature, typedData) => AddressType
Recover address function
Returns
Function that verifies signature(signature,typedData,address):boolean
Parameters
signature
Signature
typedData
TypedData
address
AddressType
Returns
boolean
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
Example
Type Declaration
_wasm
_wasm: typeofEip712Wasm=Eip712Wasm
Ether
Ether: EtherConstructor
Gwei
Gwei: GweiConstructor
Hash
Hash: HashConstructor
Hex
Hex: typeof Hex
Keccak256
Keccak256: (Keccak256 with WASM acceleration Falls back to JS implementation, but WASM methods available viainput) =>Keccak256Hash&object&object
_wasm
Type Declaration
contractAddress()
contractAddress: (Compute contract address from deployer and nonce Uses CREATE formula: keccak256(rlp([sender, nonce]))[12:]sender,nonce) =>Uint8Array<ArrayBufferLike>
Parameters
sender
Uint8Array<ArrayBufferLike>
Deployer address (20 bytes)
nonce
bigint
Transaction nonce
Returns
Uint8Array<ArrayBufferLike>
Contract address (20 bytes)
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
If sender is not 20 bytesExample
create2Address()
create2Address: (Compute CREATE2 address Uses CREATE2 formula: keccak256(0xff ++ sender ++ salt ++ keccak256(init_code))[12:]sender,salt,initCodeHash) =>Uint8Array<ArrayBufferLike>
Parameters
sender
Uint8Array<ArrayBufferLike>
Deployer address (20 bytes)
salt
Uint8Array<ArrayBufferLike>
32-byte salt
initCodeHash
Uint8Array<ArrayBufferLike>
Hash of initialization code
Returns
Uint8Array<ArrayBufferLike>
Contract address (20 bytes)
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
If sender is not 20 bytesThrows
If salt is not 32 bytesThrows
If initCodeHash is not 32 bytesExample
DIGEST_SIZE
DIGEST_SIZE: number
Digest size in bytes (32 bytes = 256 bits)
Since
0.0.0from()
from: (Hash input with Keccak-256 (constructor pattern) Auto-detects input type and hashes accordingly:input) =>Keccak256Hash
- Uint8Array: hash directly
- string starting with 0x: parse as hex
- string: UTF-8 encode then hash
Parameters
input
Data to hashstring | Uint8Array<ArrayBufferLike>
Returns
Keccak256Hash
32-byte hash
See
https://voltaire.tevm.sh/crypto/keccak256 for crypto documentationSince
0.0.0Throws
If hex string is invalidExample
fromHex()
fromHex: (Hash hex string with Keccak-256hex) =>Keccak256Hash=hashHex
Parameters
hex
string
Hex string to hash (with or without 0x prefix)
Returns
Keccak256Hash
32-byte hash
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
If hex string is invalid or has odd lengthExample
fromString()
fromString: (Hash string with Keccak-256 String is UTF-8 encoded before hashing.str) =>Keccak256Hash=hashString
Parameters
str
string
String to hash
Returns
Keccak256Hash
32-byte hash
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
Example
fromTopic()
fromTopic: (Compute event topic (32-byte Keccak-256 hash) Used for Ethereum event signatures.signature) =>Keccak256Hash=topic
Parameters
signature
string
Event signature string
Returns
Keccak256Hash
32-byte topic
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
Example
hash()
hash: (Hash data with Keccak-256data) =>Keccak256Hash
Parameters
data
Uint8Array<ArrayBufferLike>
Data to hash
Returns
Keccak256Hash
32-byte hash
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
Example
hashHex()
hashHex: (Hash hex string with Keccak-256hex) =>Keccak256Hash
Parameters
hex
string
Hex string to hash (with or without 0x prefix)
Returns
Keccak256Hash
32-byte hash
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
If hex string is invalid or has odd lengthExample
hashMultiple()
hashMultiple: (Hash multiple data chunks in sequence Equivalent to hashing the concatenation of all chunks.chunks) =>Keccak256Hash
Parameters
chunks
readonlyUint8Array<ArrayBufferLike>[]
Array of data chunks to hash
Returns
Keccak256Hash
32-byte hash
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
Example
hashString()
hashString: (Hash string with Keccak-256 String is UTF-8 encoded before hashing.str) =>Keccak256Hash
Parameters
str
string
String to hash
Returns
Keccak256Hash
32-byte hash
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
Example
RATE
RATE: number
Rate in bytes for Keccak256 (136 bytes = 1088 bits)
Since
0.0.0selector()
selector: (Compute function selector (first 4 bytes of Keccak-256 hash) Used for Ethereum function signatures.signature) =>Uint8Array<ArrayBufferLike>
Parameters
signature
string
Function signature string
Returns
Uint8Array<ArrayBufferLike>
4-byte selector
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
Example
STATE_SIZE
STATE_SIZE: number
State size (25 u64 words = 1600 bits)
Since
0.0.0topic()
topic: (Compute event topic (32-byte Keccak-256 hash) Used for Ethereum event signatures.signature) =>Keccak256Hash
Parameters
signature
string
Event signature string
Returns
Keccak256Hash
32-byte topic
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
Example
Type Declaration
_wasm
_wasm:object=Keccak256Wasm
_wasm.contractAddress()
contractAddress: (Compute CREATE contract addresssender,nonce) =>Uint8Array
Parameters
sender
Uint8Array
Sender address (20 bytes)
nonce
bigint
Transaction nonce
Returns
Uint8Array
Contract address (20 bytes)
_wasm.create2Address()
create2Address: (Compute CREATE2 contract addresssender,salt,initCodeHash) =>Uint8Array
Parameters
sender
Uint8Array
Sender address (20 bytes)
salt
Uint8Array
Salt (32 bytes)
initCodeHash
Uint8Array
Init code hash (32 bytes)
Returns
Uint8Array
Contract address (20 bytes)
_wasm.DIGEST_SIZE
DIGEST_SIZE:number=32
_wasm.hash()
hash: (Hash bytes using Keccak256data) =>HashType
Parameters
data
Uint8Array
Input bytes to hash
Returns
HashType
32-byte Keccak256 hash
_wasm.hashHex()
hashHex: (Hash a hex stringhex) =>HashType
Parameters
hex
string
Hex string to hash (with or without 0x prefix)
Returns
HashType
32-byte Keccak256 hash
_wasm.hashMultiple()
hashMultiple: (Hash multiple byte arrays in sequencechunks) =>HashType
Parameters
chunks
Uint8Array<ArrayBufferLike>[]
Array of byte arrays to hash
Returns
HashType
32-byte Keccak256 hash
_wasm.hashString()
hashString: (Hash a UTF-8 stringstr) =>HashType
Parameters
str
string
String to hash
Returns
HashType
32-byte Keccak256 hash
_wasm.init()
init: () =>Initialize WASM module (must be called before using any functions)Promise<void>
Returns
Promise<void>
_wasm.isReady()
isReady: () => boolean
Check if WASM is initialized
Returns
boolean
_wasm.RATE
RATE:number=136
_wasm.selector()
selector: (Compute function selector (first 4 bytes of hash)signature) =>Uint8Array
Parameters
signature
string
Function signature string (e.g., “transfer(address,uint256)“)
Returns
Uint8Array
4-byte function selector
_wasm.STATE_SIZE
STATE_SIZE:number=25
_wasm.topic()
topic: (Compute event topic (full 32-byte hash)signature) =>HashType
Parameters
signature
string
Event signature string (e.g., “Transfer(address,address,uint256)“)
Returns
HashType
32-byte event topic as HashType
KZG
KZG: typeof KZG
ModExp
ModExp: (base,exp,modulus) =>bigint&object
Type Declaration
calculateGas()
calculateGas: (Calculate gas cost for MODEXP operation per EIP-2565 Gas formula: max(200, floor(mult_complexity * iteration_count / 3))baseLen,expLen,modLen,expHead) =>bigint
Parameters
baseLen
bigint
Length of base in bytes
expLen
bigint
Length of exponent in bytes
modLen
bigint
Length of modulus in bytes
expHead
bigint
First 32 bytes of exponent as BigInt (for leading zeros calc)
Returns
bigint
Gas cost
See
https://eips.ethereum.org/EIPS/eip-2565Since
0.0.0Example
modexp()
modexp: (Modular exponentiation: base^exp mod modulus Computes arbitrary-precision modular exponentiation using native BigInt. Used by MODEXP precompile (0x05) per EIP-198. WARNING: This implementation is for general use. For cryptographic applications, consider timing attack resistance.base,exp,modulus) =>bigint
Parameters
base
bigint
Base value
exp
bigint
Exponent value
modulus
bigint
Modulus value (must be > 0)
Returns
bigint
Result of base^exp mod modulus
See
https://eips.ethereum.org/EIPS/eip-198Since
0.0.0Throws
If modulus is zeroExample
modexpBytes()
modexpBytes: (Modular exponentiation with byte array inputs/outputs Computes base^exp mod modulus where inputs are big-endian byte arrays. Output is padded to modulus length per EIP-198 spec.baseBytes,expBytes,modBytes) =>Uint8Array<ArrayBufferLike>
Parameters
baseBytes
Uint8Array<ArrayBufferLike>
Base as big-endian bytes
expBytes
Uint8Array<ArrayBufferLike>
Exponent as big-endian bytes
modBytes
Uint8Array<ArrayBufferLike>
Modulus as big-endian bytes
Returns
Uint8Array<ArrayBufferLike>
Result as big-endian bytes, padded to modulus length
See
https://eips.ethereum.org/EIPS/eip-198Since
0.0.0Throws
If modulus is zeroExample
Opcode
Opcode: typeof Opcode
P256
P256:P256 with WASM accelerationP256Constructor&object
Type Declaration
_wasm
_wasm: typeofP256Wasm=P256Wasm
Ripemd160
Ripemd160: (Ripemd160 with WASM accelerationinput) =>Ripemd160Hash&object&object
Type Declaration
from()
from: (Hash input with RIPEMD160 (constructor pattern) Auto-detects input type and hashes accordingly:input) =>Ripemd160Hash
- Uint8Array: hash directly
- string: UTF-8 encode then hash
Parameters
input
Data to hashstring | Uint8Array<ArrayBufferLike>
Returns
Ripemd160Hash
20-byte hash
See
https://voltaire.tevm.sh/crypto/ripemd160 for crypto documentationSince
0.0.0Throws
Example
fromHex()
fromHex: (Compute RIPEMD160 hash of hex string (without 0x prefix)hex) =>Ripemd160Hash=hashHex
Parameters
hex
string
Hex string (with or without 0x prefix)
Returns
Ripemd160Hash
20-byte hash
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
Example
fromString()
fromString: (Compute RIPEMD160 hash of UTF-8 stringstr) =>Ripemd160Hash=hashString
Parameters
str
string
Input string
Returns
Ripemd160Hash
20-byte hash
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
Example
hash()
hash: (Compute RIPEMD160 hash (20 bytes)data) =>Ripemd160Hash
Parameters
data
Input data (Uint8Array or string)string | Uint8Array<ArrayBufferLike>
Returns
Ripemd160Hash
20-byte hash
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
Example
hashHex()
hashHex: (Compute RIPEMD160 hash of hex string (without 0x prefix)hex) =>Ripemd160Hash
Parameters
hex
string
Hex string (with or without 0x prefix)
Returns
Ripemd160Hash
20-byte hash
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
Example
hashString()
hashString: (Compute RIPEMD160 hash of UTF-8 stringstr) =>Ripemd160Hash
Parameters
str
string
Input string
Returns
Ripemd160Hash
20-byte hash
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
Example
HEX_SIZE
HEX_SIZE: number
Size of RIPEMD160 hash in hex characters (without 0x prefix)
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
Example
SIZE
SIZE: number
Size of RIPEMD160 hash in bytes (160 bits)
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
Example
Type Declaration
_wasm
_wasm: typeofRipemd160Wasm=Ripemd160Wasm
Rlp
Rlp: typeof Rlp
Secp256k1
Secp256k1:Secp256k1 with WASM accelerationobject&object
Type Declaration
addPoints()
addPoints: (Add two secp256k1 public key points Performs elliptic curve point addition: P1 + P2. Used in ERC-5564 stealth address generation.pubKey1,pubKey2) =>Secp256k1PublicKeyType
Parameters
pubKey1
Secp256k1PublicKeyType
First 64-byte uncompressed public key
pubKey2
Secp256k1PublicKeyType
Second 64-byte uncompressed public key
Returns
Secp256k1PublicKeyType
Result 64-byte uncompressed public key
See
- https://voltaire.tevm.sh/crypto for crypto documentation
- https://eips.ethereum.org/EIPS/eip-5564 for ERC-5564 stealth addresses
Since
0.0.0Throws
If either public key is invalidThrows
If point addition failsExample
createKeyPair()
createKeyPair: () => object
Generate a new secp256k1 key pair
Returns
object
Key pair with 32-byte private key and 65-byte uncompressed public key
privateKey
privateKey: Uint8Array
publicKey
publicKey: Uint8Array
Example
CURVE_ORDER
CURVE_ORDER: bigint
secp256k1 curve order (number of points on the curve)
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
Example
derivePublicKey()
derivePublicKey: (Derive public key from private key Computes the public key point from a private key using scalar multiplication on the secp256k1 curve.privateKey) =>Secp256k1PublicKeyType
Parameters
privateKey
PrivateKeyType
32-byte private key
Returns
Secp256k1PublicKeyType
64-byte uncompressed public key
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
If private key is invalidExample
ecdh()
ecdh: (Perform ECDH key exchange Computes shared secret from your private key and their public key. Returns the x-coordinate of the shared point (32 bytes).privateKey,publicKey) =>Uint8Array<ArrayBufferLike>
Parameters
privateKey
PrivateKeyType
Your 32-byte private key
publicKey
Secp256k1PublicKeyType
Their 64-byte uncompressed public key
Returns
Uint8Array<ArrayBufferLike>
32-byte shared secret (x-coordinate)
See
- https://voltaire.tevm.sh/crypto for crypto documentation
- https://eips.ethereum.org/EIPS/eip-5564 for ERC-5564 stealth addresses
Since
0.0.0Throws
If private key is invalidThrows
If public key is invalidThrows
If ECDH computation failsExample
getSharedSecret()
getSharedSecret: (Perform ECDH key exchange Computes shared secret from your private key and their public key. Returns the x-coordinate of the shared point (32 bytes).privateKey,publicKey) =>Uint8Array<ArrayBufferLike> =ecdh
Parameters
privateKey
PrivateKeyType
Your 32-byte private key
publicKey
Secp256k1PublicKeyType
Their 64-byte uncompressed public key
Returns
Uint8Array<ArrayBufferLike>
32-byte shared secret (x-coordinate)
See
- https://voltaire.tevm.sh/crypto for crypto documentation
- https://eips.ethereum.org/EIPS/eip-5564 for ERC-5564 stealth addresses
Since
0.0.0Throws
If private key is invalidThrows
If public key is invalidThrows
If ECDH computation failsExample
isValidPrivateKey()
isValidPrivateKey: (Validate private key Checks that the private key is within valid range [1, n-1] where n is the curve order.privateKey) =>boolean
Parameters
privateKey
Uint8Array<ArrayBufferLike>
32-byte private key
Returns
boolean
true if private key is valid, false otherwise
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
Example
isValidPublicKey()
isValidPublicKey: (Validate public key Checks that the public key is a valid point on the secp256k1 curve.publicKey) =>publicKey is Secp256k1PublicKeyType
Parameters
publicKey
Uint8Array<ArrayBufferLike>
64-byte uncompressed public key
Returns
publicKey is Secp256k1PublicKeyType
true if public key is valid, false otherwise
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
Example
isValidSignature()
isValidSignature: (Validate signature components Checks that r and s are within valid range [1, n-1] where n is the curve order. Also enforces low-s values to prevent malleability.signature) =>boolean
Parameters
signature
Secp256k1SignatureType
ECDSA signature to validate (r and s are HashType)
Returns
boolean
true if signature is valid, false otherwise
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
Example
PRIVATE_KEY_SIZE
PRIVATE_KEY_SIZE: number
Private key size in bytes
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
Example
PrivateKey
PrivateKey:__module=PrivateKeyMethods
PUBLIC_KEY_SIZE
PUBLIC_KEY_SIZE: number
Uncompressed public key size in bytes (64 bytes, no prefix)
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
Example
PublicKey
PublicKey:__module=PublicKeyMethods
randomPrivateKey()
randomPrivateKey: () =>Generate a cryptographically secure random secp256k1 private keyUint8Array<ArrayBufferLike>
Returns
Uint8Array<ArrayBufferLike>
32-byte private key
Example
recoverPublicKey()
recoverPublicKey: (Recover public key from signature and message hash Uses the recovery id (v) to recover the exact public key that created the signature. This is what enables Ethereum’s address recovery from transaction signatures.signature,messageHash) =>Secp256k1PublicKeyType
Parameters
signature
ECDSA signature componentsr
Uint8Array<ArrayBufferLike>
32-byte signature component r
s
Uint8Array<ArrayBufferLike>
32-byte signature component s
v
number
Recovery id (27/28 or 0/1)
messageHash
HashType
32-byte message hash that was signed
Returns
Secp256k1PublicKeyType
64-byte uncompressed public key
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
If signature or recovery failsExample
recoverPublicKeyFromHash()
recoverPublicKeyFromHash: (Recover public key from signature and pre-hashed message This is the hash-level API that operates directly on a 32-byte hash. Use this when you need custom hashing schemes or interop with other libraries. For standard Ethereum signing, use recoverPublicKey() instead. Uses the recovery id (v) to recover the exact public key that created the signature. This is what enables Ethereum’s address recovery from transaction signatures.signature,hash) =>Secp256k1PublicKeyType
Parameters
signature
ECDSA signature componentsr
Uint8Array<ArrayBufferLike>
32-byte signature component r
s
Uint8Array<ArrayBufferLike>
32-byte signature component s
v
number
Recovery id (27/28 or 0/1)
hash
HashType
32-byte hash that was signed (pre-hashed message)
Returns
Secp256k1PublicKeyType
64-byte uncompressed public key
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
If signature or recovery failsThrows
If hash is not 32 bytesExample
scalarMultiply()
scalarMultiply: (Multiply generator point by scalar Performs scalar multiplication: scalar * G (generator point). Used in ERC-5564 stealth address generation.scalar) =>Secp256k1PublicKeyType
Parameters
scalar
Uint8Array<ArrayBufferLike>
32-byte scalar value
Returns
Secp256k1PublicKeyType
Result 64-byte uncompressed public key
See
- https://voltaire.tevm.sh/crypto for crypto documentation
- https://eips.ethereum.org/EIPS/eip-5564 for ERC-5564 stealth addresses
Since
0.0.0Throws
If scalar multiplication failsExample
sign()
sign: (Sign a message hash with a private key Uses deterministic ECDSA (RFC 6979) for signature generation. Returns signature with Ethereum-compatible v value (27 or 28).messageHash,privateKey) =>Secp256k1SignatureType
Parameters
messageHash
HashType
32-byte message hash to sign
privateKey
PrivateKeyType
32-byte private key
Returns
Secp256k1SignatureType
ECDSA signature with r, s, v components
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
If private key is invalidThrows
If signing failsExample
Signature
Signature:__module=SignatureMethods
SIGNATURE_COMPONENT_SIZE
SIGNATURE_COMPONENT_SIZE: number
Signature component size in bytes (r and s are each 32 bytes)
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
Example
signHash()
signHash: (Sign a pre-hashed message with a private key This is the hash-level API that operates directly on a 32-byte hash. Use this when you need custom hashing schemes or interop with other libraries. For standard Ethereum signing, use sign() instead. Uses deterministic ECDSA (RFC 6979) for signature generation. Returns signature with Ethereum-compatible v value (27 or 28).hash,privateKey) =>Secp256k1SignatureType
Parameters
hash
HashType
32-byte hash to sign (pre-hashed message)
privateKey
PrivateKeyType
32-byte private key
Returns
Secp256k1SignatureType
ECDSA signature with r, s, v components
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
If private key is invalidThrows
If signing fails or hash is not 32 bytesExample
verify()
verify: (Verify an ECDSA signaturesignature,messageHash,publicKey) =>boolean
Parameters
signature
Secp256k1SignatureType
ECDSA signature with r, s, v components (r and s are HashType)
messageHash
HashType
32-byte message hash that was signed
publicKey
Secp256k1PublicKeyType
64-byte uncompressed public key
Returns
boolean
true if signature is valid, false otherwise
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
If signature v is invalidExample
verifyHash()
verifyHash: (Verify an ECDSA signature against a pre-hashed message This is the hash-level API that operates directly on a 32-byte hash. Use this when you need custom hashing schemes or interop with other libraries. For standard Ethereum signing, use verify() instead.signature,hash,publicKey) =>boolean
Parameters
signature
Secp256k1SignatureType
ECDSA signature with r, s, v components (r and s are HashType)
hash
HashType
32-byte hash that was signed (pre-hashed message)
publicKey
Secp256k1PublicKeyType
64-byte uncompressed public key
Returns
boolean
true if signature is valid, false otherwise
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
If hash is not 32 bytesExample
Type Declaration
_wasm
_wasm: typeofSecp256k1Wasm=Secp256k1Wasm
SHA256
SHA256: (SHA256 with WASM accelerationinput) =>SHA256Hash&object&object
Type Declaration
BLOCK_SIZE
BLOCK_SIZE: number
SHA256 block size in bytes
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
Example
create()
create: () => object
Incremental hasher for streaming data
Returns
object
Hasher instance
digest()
digest: () => Uint8Array
Returns
Uint8Array
update()
update: (data) =>void
Parameters
data
Uint8Array
Returns
void
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
Example
from()
from: (Hash input with SHA256 (constructor pattern) Auto-detects input type and hashes accordingly:input) =>SHA256Hash
- Uint8Array: hash directly
- string starting with 0x: parse as hex
- string: UTF-8 encode then hash
Parameters
input
Data to hashstring | Uint8Array<ArrayBufferLike>
Returns
SHA256Hash
32-byte hash
See
https://voltaire.tevm.sh/crypto/sha256 for crypto documentationSince
0.0.0Throws
Example
fromHex()
fromHex: (Compute SHA256 hash of hex string (without 0x prefix)hex) =>SHA256Hash=hashHex
Parameters
hex
string
Hex string (with or without 0x prefix)
Returns
SHA256Hash
32-byte hash
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
Example
fromString()
fromString: (Compute SHA256 hash of UTF-8 stringstr) =>SHA256Hash=hashString
Parameters
str
string
Input string
Returns
SHA256Hash
32-byte hash
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
Example
hash()
hash: (Compute SHA256 hash of input datadata) =>SHA256Hash
Parameters
data
Uint8Array<ArrayBufferLike>
Input data as Uint8Array
Returns
SHA256Hash
32-byte hash
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
Example
hashHex()
hashHex: (Compute SHA256 hash of hex string (without 0x prefix)hex) =>SHA256Hash
Parameters
hex
string
Hex string (with or without 0x prefix)
Returns
SHA256Hash
32-byte hash
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
Example
hashString()
hashString: (Compute SHA256 hash of UTF-8 stringstr) =>SHA256Hash
Parameters
str
string
Input string
Returns
SHA256Hash
32-byte hash
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
Example
OUTPUT_SIZE
OUTPUT_SIZE: number
SHA256 output size in bytes (256 bits / 8)
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
Example
toHex()
toHex: (Convert hash output to hex stringhash) =>string
Parameters
hash
Uint8Array<ArrayBufferLike>
Hash bytes
Returns
string
Hex string with 0x prefix
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
Example
Type Declaration
_wasm
_wasm: typeofSha256Wasm=Sha256Wasm
Siwe
Siwe: typeof Siwe
StorageKey
StorageKey: object
StorageKey.create()
create: (address,slot) =>StorageKeyType
Parameters
address
AddressType
slot
bigint
Returns
StorageKeyType
StorageKey.equals()
equals: (a,b) =>boolean
Parameters
a
StorageKeyLike
b
StorageKeyLike
Returns
boolean
StorageKey.from()
from: (value) =>StorageKeyType
Parameters
value
StorageKeyLike
Returns
StorageKeyType
StorageKey.fromString()
fromString: (str) =>StorageKeyType|undefined
Parameters
str
string
Returns
StorageKeyType | undefined
StorageKey.hashCode()
hashCode: (key) =>number
Parameters
key
StorageKeyLike
Returns
number
StorageKey.is()
is: (value) =>value is StorageKeyType
Parameters
value
unknown
Returns
value is StorageKeyType
StorageKey.toString()
toString: (key) =>string
Parameters
key
StorageKeyLike
Returns
string
Uint
Uint: typeof Uint
Wei
Wei: WeiConstructor
X25519
X25519:X25519 with WASM accelerationobject&object
Type Declaration
derivePublicKey()
derivePublicKey: (Derive public key from secret keysecretKey) =>PublicKey
Parameters
secretKey
SecretKey
32-byte secret key
Returns
PublicKey
32-byte public key
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
If secret key is invalidExample
generateKeypair()
generateKeypair: () => object
Generate random keypair
Uses crypto.getRandomValues for secure random generation
Returns
object
Object with secretKey and publicKey
publicKey
publicKey: PublicKey
secretKey
secretKey: SecretKey
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
Example
generateSecretKey()
generateSecretKey: () => SecretKey
Generate random secret key
Uses crypto.getRandomValues for secure random generation
Returns
SecretKey
32-byte random secret key
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
Example
keypairFromSeed()
keypairFromSeed: (Generate X25519 keypair from seedseed) =>object
Parameters
seed
Uint8Array<ArrayBufferLike>
32-byte seed for deterministic generation
Returns
object
Object with secretKey and publicKey
publicKey
publicKey: PublicKey
secretKey
secretKey: SecretKey
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
If seed length is invalidExample
PUBLIC_KEY_SIZE
PUBLIC_KEY_SIZE: 32
Public key size in bytes
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
Example
scalarmult()
scalarmult: (Perform X25519 scalar multiplication (ECDH) Computes shared secret from your secret key and their public key.secretKey,publicKey) =>SharedSecret
Parameters
secretKey
SecretKey
Your 32-byte secret key
publicKey
PublicKey
Their 32-byte public key
Returns
SharedSecret
32-byte shared secret
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
If secret key is invalidThrows
If public key is invalidThrows
If scalar multiplication failsExample
SECRET_KEY_SIZE
SECRET_KEY_SIZE: 32
Secret key size in bytes
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
Example
SHARED_SECRET_SIZE
SHARED_SECRET_SIZE: 32
Shared secret size in bytes
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
Example
validatePublicKey()
validatePublicKey: (Validate a public key Checks if the public key has correct lengthpublicKey) =>boolean
Parameters
publicKey
PublicKey
Public key to validate
Returns
boolean
True if valid, false otherwise
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
Example
validateSecretKey()
validateSecretKey: (Validate a secret key Checks if the secret key has correct length and can derive a public keysecretKey) =>boolean
Parameters
secretKey
SecretKey
Secret key to validate
Returns
boolean
True if valid, false otherwise
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
Example
Type Declaration
_wasm
_wasm: typeofX25519Wasm=X25519Wasm
Wei
Defined in: src/wasm/index.ts:245constWei:WeiConstructor=WeiJS
X25519
Defined in: src/wasm/index.ts:207 X25519 with WASM accelerationconstX25519:object&object
Type Declaration
derivePublicKey()
derivePublicKey: (Derive public key from secret keysecretKey) =>PublicKey
Parameters
secretKey
SecretKey
32-byte secret key
Returns
PublicKey
32-byte public key
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
If secret key is invalidExample
generateKeypair()
generateKeypair: () => object
Generate random keypair
Uses crypto.getRandomValues for secure random generation
Returns
object
Object with secretKey and publicKey
publicKey
publicKey: PublicKey
secretKey
secretKey: SecretKey
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
Example
generateSecretKey()
generateSecretKey: () => SecretKey
Generate random secret key
Uses crypto.getRandomValues for secure random generation
Returns
SecretKey
32-byte random secret key
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
Example
keypairFromSeed()
keypairFromSeed: (Generate X25519 keypair from seedseed) =>object
Parameters
seed
Uint8Array<ArrayBufferLike>
32-byte seed for deterministic generation
Returns
object
Object with secretKey and publicKey
publicKey
publicKey: PublicKey
secretKey
secretKey: SecretKey
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
If seed length is invalidExample
PUBLIC_KEY_SIZE
PUBLIC_KEY_SIZE: 32
Public key size in bytes
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
Example
scalarmult()
scalarmult: (Perform X25519 scalar multiplication (ECDH) Computes shared secret from your secret key and their public key.secretKey,publicKey) =>SharedSecret
Parameters
secretKey
SecretKey
Your 32-byte secret key
publicKey
PublicKey
Their 32-byte public key
Returns
SharedSecret
32-byte shared secret
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
If secret key is invalidThrows
If public key is invalidThrows
If scalar multiplication failsExample
SECRET_KEY_SIZE
SECRET_KEY_SIZE: 32
Secret key size in bytes
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
Example
SHARED_SECRET_SIZE
SHARED_SECRET_SIZE: 32
Shared secret size in bytes
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
Example
validatePublicKey()
validatePublicKey: (Validate a public key Checks if the public key has correct lengthpublicKey) =>boolean
Parameters
publicKey
PublicKey
Public key to validate
Returns
boolean
True if valid, false otherwise
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
Example
validateSecretKey()
validateSecretKey: (Validate a secret key Checks if the secret key has correct length and can derive a public keysecretKey) =>boolean
Parameters
secretKey
SecretKey
Secret key to validate
Returns
boolean
True if valid, false otherwise
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
Example
Type Declaration
_wasm
_wasm: typeofX25519Wasm=X25519Wasm
Functions
accessListGasCost()
accessListGasCost(Defined in: src/primitives/AccessList/AccessList.wasm.ts:16 Calculate total gas cost for access listaccessList):bigint
Parameters
accessList
BrandedAccessList
Access list to calculate cost for
Returns
bigint
Gas cost as bigint
accessListGasSavings()
accessListGasSavings(Defined in: src/primitives/AccessList/AccessList.wasm.ts:26 Calculate gas savings from using access listaccessList):bigint
Parameters
accessList
BrandedAccessList
Access list to calculate savings for
Returns
bigint
Gas savings as bigint
accessListIncludesAddress()
accessListIncludesAddress(Defined in: src/primitives/AccessList/AccessList.wasm.ts:37 Check if address is in access listaccessList,address):boolean
Parameters
accessList
BrandedAccessList
Access list to check
address
AddressType
Address to look for
Returns
boolean
True if address is in list
accessListIncludesStorageKey()
accessListIncludesStorageKey(Defined in: src/primitives/AccessList/AccessList.wasm.ts:52 Check if storage key is in access list for addressaccessList,address,storageKey):boolean
Parameters
accessList
BrandedAccessList
Access list to check
address
AddressType
Address to look for
storageKey
HashType
Storage key to look for
Returns
boolean
True if storage key is in list for address
analyzeJumpDestinations()
analyzeJumpDestinations(Defined in: src/primitives/Bytecode/Bytecode.wasm.ts:32 Analyze bytecode to find all valid JUMPDEST locations (WASM accelerated)bytecode):number[]
Parameters
bytecode
BrandedBytecode
EVM bytecode
Returns
number[]
Array of valid JUMPDEST positions
Example
blake2b()
blake2b(Defined in: src/primitives/Hash/Hash.wasm.ts:41 Compute BLAKE2b hashdata):Uint8Array
Parameters
data
Input data (string or Uint8Array)string | Uint8Array<ArrayBufferLike>
Returns
Uint8Array
64-byte BLAKE2b hash
blobCalculateExcessGas()
blobCalculateExcessGas(Defined in: src/primitives/Blob/Blob.wasm.ts:114 Calculate excess blob gas for next block using WASMparentExcess,parentUsed):bigint
Parameters
parentExcess
bigint
Parent block excess blob gas
parentUsed
bigint
Parent block blob gas used
Returns
bigint
Excess blob gas for next block
Example
blobCalculateGas()
blobCalculateGas(Defined in: src/primitives/Blob/Blob.wasm.ts:71 Calculate blob gas for number of blobs using WASMblobCount):bigint
Parameters
blobCount
number
Number of blobs
Returns
bigint
Total blob gas
Example
blobCalculateGasPrice()
blobCalculateGasPrice(Defined in: src/primitives/Blob/Blob.wasm.ts:99 Calculate blob gas price from excess blob gas using WASMexcessBlobGas):bigint
Parameters
excessBlobGas
bigint
Excess blob gas
Returns
bigint
Blob gas price
Example
blobEstimateCount()
blobEstimateCount(Defined in: src/primitives/Blob/Blob.wasm.ts:85 Estimate number of blobs needed for data using WASMdataSize):number
Parameters
dataSize
number
Size of data in bytes
Returns
number
Number of blobs required
Example
blobFromData()
blobFromData(Defined in: src/primitives/Blob/Blob.wasm.ts:26 Encode data as blob using WASM (with length prefix)data):Uint8Array
Parameters
data
Uint8Array
Data to encode (max ~131KB)
Returns
Uint8Array
Blob containing encoded data
Example
blobIsValid()
blobIsValid(Defined in: src/primitives/Blob/Blob.wasm.ts:57 Validate blob size using WASMblobLen):boolean
Parameters
blobLen
number
Length to validate
Returns
boolean
true if blob is exactly 131072 bytes
Example
blobToData()
blobToData(Defined in: src/primitives/Blob/Blob.wasm.ts:41 Extract data from blob using WASMblob):Uint8Array
Parameters
blob
Uint8Array
Blob data (131072 bytes)
Returns
Uint8Array
Original data
Example
bytesToHex()
bytesToHex(Defined in: src/primitives/Hex/Hex.wasm.ts:22 Convert bytes to hex stringdata):string
Parameters
data
Uint8Array
Raw bytes
Returns
string
Hex string with 0x prefix
compressPublicKey()
compressPublicKey(Defined in: src/crypto/wallet.wasm.js:21 Compress an uncompressed public key (64 bytes) to compressed form (33 bytes)uncompressed):Uint8Array<ArrayBufferLike>
Parameters
uncompressed
Uint8Array<ArrayBufferLike>
Uncompressed public key (64 bytes)
Returns
Uint8Array<ArrayBufferLike>
Compressed public key (33 bytes)
detectTransactionType()
detectTransactionType(Defined in: src/primitives/Transaction/Transaction.wasm.ts:29 Detect transaction type from RLP-encoded datadata):TransactionType
Parameters
data
Uint8Array
RLP-encoded transaction data
Returns
TransactionType
Transaction type (0-4)
eip191HashMessage()
eip191HashMessage(Defined in: src/crypto/keccak.wasm.js:29message):Promise<Uint8Array<ArrayBufferLike>>
Parameters
message
string | Uint8Array<ArrayBufferLike>
Returns
Promise<Uint8Array<ArrayBufferLike>>
generatePrivateKey()
generatePrivateKey():Defined in: src/crypto/wallet.wasm.js:12 Generate a random private key (32 bytes)Uint8Array<ArrayBufferLike>
Returns
Uint8Array<ArrayBufferLike>
Random private key
hexToBytes()
hexToBytes(Defined in: src/primitives/Hex/Hex.wasm.ts:13 Convert hex string to byteshex):Uint8Array
Parameters
hex
string
Hex string (with or without 0x prefix)
Returns
Uint8Array
Raw bytes
isBytecodeBoundary()
isBytecodeBoundary(Defined in: src/primitives/Bytecode/Bytecode.wasm.ts:52 Check if a position is at a bytecode boundary (WASM accelerated) Position must not be inside PUSH databytecode,position):boolean
Parameters
bytecode
BrandedBytecode
EVM bytecode
position
number
Position to check
Returns
boolean
True if position is a valid instruction boundary
Example
isValidJumpDest()
isValidJumpDest(Defined in: src/primitives/Bytecode/Bytecode.wasm.ts:74 Check if a position contains a valid JUMPDEST (WASM accelerated)bytecode,position):boolean
Parameters
bytecode
BrandedBytecode
EVM bytecode
position
number
Position to check
Returns
boolean
True if position contains JUMPDEST opcode
Example
keccak256()
keccak256(Defined in: src/crypto/keccak.wasm.js:17data):Promise<Uint8Array<ArrayBufferLike>>
Parameters
data
string | Uint8Array<ArrayBufferLike>
Returns
Promise<Uint8Array<ArrayBufferLike>>
ripemd160()
ripemd160(Defined in: src/primitives/Hash/Hash.wasm.ts:27 Compute RIPEMD-160 hashdata):Uint8Array
Parameters
data
Input data (string or Uint8Array)string | Uint8Array<ArrayBufferLike>
Returns
Uint8Array
20-byte RIPEMD-160 hash
rlpEncodeBytes()
rlpEncodeBytes(Defined in: src/primitives/Rlp/Rlp.wasm.ts:13 Encode bytes as RLPdata):Uint8Array
Parameters
data
Uint8Array
Data to encode
Returns
Uint8Array
RLP-encoded bytes
rlpEncodeUint()
rlpEncodeUint(Defined in: src/primitives/Rlp/Rlp.wasm.ts:23 Encode unsigned integer (u256) as RLPvalue):Uint8Array
Parameters
value
Uint8Array
32-byte big-endian u256 value
Returns
Uint8Array
RLP-encoded bytes
rlpEncodeUintFromBigInt()
rlpEncodeUintFromBigInt(Defined in: src/primitives/Rlp/Rlp.wasm.ts:36 Encode unsigned integer from bigintvalue):Uint8Array
Parameters
value
bigint
BigInt value
Returns
Uint8Array
RLP-encoded bytes
rlpFromHex()
rlpFromHex(Defined in: src/primitives/Rlp/Rlp.wasm.ts:61 Convert hex string to RLP byteshex):Uint8Array
Parameters
hex
string
Hex string (with or without 0x prefix)
Returns
Uint8Array
RLP bytes
rlpToHex()
rlpToHex(Defined in: src/primitives/Rlp/Rlp.wasm.ts:51 Convert RLP bytes to hex stringrlpData):string
Parameters
rlpData
Uint8Array
RLP-encoded data
Returns
string
Hex string with 0x prefix
secp256k1PubkeyFromPrivate()
secp256k1PubkeyFromPrivate(Defined in: src/crypto/signature.wasm.js:51 Derive public key from private keyprivateKey):Uint8Array<ArrayBufferLike>
Parameters
privateKey
Uint8Array<ArrayBufferLike>
Private key (32 bytes)
Returns
Uint8Array<ArrayBufferLike>
Public key (64 bytes)
secp256k1RecoverAddress()
secp256k1RecoverAddress(Defined in: src/crypto/signature.wasm.js:40 Recover Ethereum address from signaturemessageHash,signature):Uint8Array<ArrayBufferLike>
Parameters
messageHash
Uint8Array<ArrayBufferLike>
Hash of signed message
signature
Uint8Array<ArrayBufferLike>
65-byte signature (r+s+v)
Returns
Uint8Array<ArrayBufferLike>
Recovered address (20 bytes)
secp256k1RecoverPubkey()
secp256k1RecoverPubkey(Defined in: src/crypto/signature.wasm.js:26 Recover public key from signaturemessageHash,signature):Uint8Array<ArrayBufferLike>
Parameters
messageHash
Uint8Array<ArrayBufferLike>
Hash of signed message
signature
Uint8Array<ArrayBufferLike>
65-byte signature (r+s+v)
Returns
Uint8Array<ArrayBufferLike>
Recovered public key (64 bytes)
secp256k1ValidateSignature()
secp256k1ValidateSignature(Defined in: src/crypto/signature.wasm.js:62 Validate signature against public keysignature,messageHash,publicKey):boolean
Parameters
signature
Uint8Array<ArrayBufferLike>
65-byte signature
messageHash
Uint8Array<ArrayBufferLike>
Hash of signed message
publicKey
Uint8Array<ArrayBufferLike>
Public key (64 bytes)
Returns
boolean
True if signature is valid
sha256()
sha256(Defined in: src/primitives/Hash/Hash.wasm.ts:13 Compute SHA-256 hashdata):Uint8Array
Parameters
data
Input data (string or Uint8Array)string | Uint8Array<ArrayBufferLike>
Returns
Uint8Array
32-byte SHA-256 hash
signatureIsCanonical()
signatureIsCanonical(Defined in: src/crypto/signature.wasm.js:96 Check if signature is in canonical formsignature):boolean
Parameters
signature
Uint8Array<ArrayBufferLike>
65-byte signature
Returns
boolean
True if signature is canonical
signatureNormalize()
signatureNormalize(Defined in: src/crypto/signature.wasm.js:75 Normalize signature to low-s formsignature):Uint8Array<ArrayBufferLike>
Parameters
signature
Uint8Array<ArrayBufferLike>
65-byte signature
Returns
Uint8Array<ArrayBufferLike>
Normalized signature
signatureParse()
signatureParse(Defined in: src/crypto/signature.wasm.js:106 Parse signature from bytessignature):ParsedSignature
Parameters
signature
Uint8Array<ArrayBufferLike>
65-byte signature (r+s+v)
Returns
ParsedSignature
Parsed signature object
signatureSerialize()
signatureSerialize(Defined in: src/crypto/signature.wasm.js:115 Serialize signature to bytessignature):Uint8Array<ArrayBufferLike>
Parameters
signature
ParsedSignature
Parsed signature object
Returns
Uint8Array<ArrayBufferLike>
65-byte signature (r+s+v)
solidityKeccak256()
solidityKeccak256(Defined in: src/primitives/Hash/Hash.wasm.ts:55 Compute Solidity-style Keccak-256 hash of tightly packed datapackedData):Uint8Array
Parameters
packedData
Uint8Array
Pre-packed data bytes
Returns
Uint8Array
32-byte Keccak-256 hash
soliditySha256()
soliditySha256(Defined in: src/primitives/Hash/Hash.wasm.ts:66 Compute Solidity-style SHA-256 hash of tightly packed datapackedData):Uint8Array
Parameters
packedData
Uint8Array
Pre-packed data bytes
Returns
Uint8Array
32-byte SHA-256 hash
u256FromBigInt()
u256FromBigInt(Defined in: src/primitives/Uint/Uint256.wasm.ts:46 Convert bigint to U256 bytesvalue):Uint8Array
Parameters
value
bigint
BigInt value
Returns
Uint8Array
32-byte U256 value
Throws
If value is negativeThrows
If value exceeds maximumu256FromHex()
u256FromHex(Defined in: src/primitives/Uint/Uint256.wasm.ts:18 Convert hex string to U256 (32-byte big-endian)hex):Uint8Array
Parameters
hex
string
Hex string (with or without 0x prefix)
Returns
Uint8Array
32-byte U256 value
u256ToBigInt()
u256ToBigInt(Defined in: src/primitives/Uint/Uint256.wasm.ts:70 Convert U256 bytes to bigintvalue):bigint
Parameters
value
Uint8Array
32-byte U256 value
Returns
bigint
BigInt value
Throws
If value is not 32 bytesu256ToHex()
u256ToHex(Defined in: src/primitives/Uint/Uint256.wasm.ts:28 Convert U256 to hex stringvalue):string
Parameters
value
Uint8Array
32-byte U256 value (big-endian)
Returns
string
Hex string with 0x prefix
Throws
If value is not 32 bytesvalidateBytecode()
validateBytecode(Defined in: src/primitives/Bytecode/Bytecode.wasm.ts:94 Validate bytecode structure (WASM accelerated) Checks that PUSH instructions have enough data bytesbytecode):void
Parameters
bytecode
BrandedBytecode
EVM bytecode
Returns
void

