@tevm/voltaire / native
native
Enumerations
NativeErrorCode
Defined in: src/native-loader/types.ts:204 Runtime error codes from native libraryEnumeration Members
BUFFER_TOO_SMALL
BUFFER_TOO_SMALL: -4
Defined in: src/native-loader/types.ts:209
DECODING_ERROR
DECODING_ERROR: -10
Defined in: src/native-loader/types.ts:215
ENCODING_ERROR
ENCODING_ERROR: -9
Defined in: src/native-loader/types.ts:214
INVALID_CHECKSUM
INVALID_CHECKSUM: -3
Defined in: src/native-loader/types.ts:208
INVALID_HEX
INVALID_HEX: -1
Defined in: src/native-loader/types.ts:206
INVALID_LENGTH
INVALID_LENGTH: -2
Defined in: src/native-loader/types.ts:207
INVALID_PRIVATE_KEY
INVALID_PRIVATE_KEY: -7
Defined in: src/native-loader/types.ts:212
INVALID_PUBLIC_KEY
INVALID_PUBLIC_KEY: -8
Defined in: src/native-loader/types.ts:213
INVALID_RECOVERY_ID
INVALID_RECOVERY_ID: -6
Defined in: src/native-loader/types.ts:211
INVALID_SIGNATURE
INVALID_SIGNATURE: -5
Defined in: src/native-loader/types.ts:210
NULL_POINTER
NULL_POINTER: -11
Defined in: src/native-loader/types.ts:216
OUT_OF_MEMORY
OUT_OF_MEMORY: -12
Defined in: src/native-loader/types.ts:217
SUCCESS
SUCCESS: 0
Defined in: src/native-loader/types.ts:205
UNKNOWN_ERROR
UNKNOWN_ERROR: -99
Defined in: src/native-loader/types.ts:218
Type Aliases
Platform
Platform =Defined in: src/native-loader/platform.ts:5 Platform detection utilities for native bindings"darwin-arm64"|"darwin-x64"|"linux-arm64"|"linux-x64"|"win32-x64"
Variables
Keccak256
Defined in: src/crypto/Keccak256/Keccak256.native.ts:150constKeccak256: (input) =>Promise<Keccak256Hash> &object=Keccak256Hash
Type Declaration
DIGEST_SIZE
DIGEST_SIZE:number=32
from()
from: (Universal constructor - accepts hex, string, or bytesinput) =>Promise<Keccak256Hash>
Parameters
input
Hex string, UTF-8 string, or Uint8Arraystring | Uint8Array<ArrayBufferLike>
Returns
Promise<Keccak256Hash>
32-byte hash
Throws
Error if native operation failsfromHex()
fromHex: (Hash hex string with Keccak-256 using native implementationhex) =>Promise<Keccak256Hash> =hashHex
Parameters
hex
string
Hex string to hash
Returns
Promise<Keccak256Hash>
32-byte hash
Throws
Error if native operation failsfromString()
fromString: (Hash UTF-8 string with Keccak-256 using native implementationstr) =>Promise<Keccak256Hash> =hashString
Parameters
str
string
String to hash
Returns
Promise<Keccak256Hash>
32-byte hash
Throws
Error if native operation failshash()
hash: (Hash data with Keccak-256 using native implementationdata) =>Promise<Keccak256Hash>
Parameters
data
Uint8Array
Data to hash
Returns
Promise<Keccak256Hash>
32-byte hash
Throws
Error if native operation failshashHex()
hashHex: (Hash hex string with Keccak-256 using native implementationhex) =>Promise<Keccak256Hash>
Parameters
hex
string
Hex string to hash
Returns
Promise<Keccak256Hash>
32-byte hash
Throws
Error if native operation failshashString()
hashString: (Hash UTF-8 string with Keccak-256 using native implementationstr) =>Promise<Keccak256Hash>
Parameters
str
string
String to hash
Returns
Promise<Keccak256Hash>
32-byte hash
Throws
Error if native operation failshashSync()
hashSync: (Synchronous hash (for backward compatibility) Throws if native library not loadeddata) =>Keccak256Hash
Parameters
data
Uint8Array
Returns
Keccak256Hash
RATE
RATE:number=136
selector()
selector: (Compute function selector (first 4 bytes of keccak256)signature) =>Promise<string>
Parameters
signature
string
Function signature (e.g., “transfer(address,uint256)“)
Returns
Promise<string>
First 4 bytes of hash as hex string
STATE_SIZE
STATE_SIZE:number=200
topic()
topic: (Compute event topic hashsignature) =>Promise<Keccak256Hash>
Parameters
signature
string
Event signature (e.g., “Transfer(address,address,uint256)“)
Returns
Promise<Keccak256Hash>
32-byte topic hash
Keccak256HashNative
Defined in: src/crypto/Keccak256/Keccak256.native.ts:134 Native Keccak256 namespace objectconstKeccak256HashNative: (input) =>Promise<Keccak256Hash> &object
Type Declaration
DIGEST_SIZE
DIGEST_SIZE:number=32
from()
from: (Universal constructor - accepts hex, string, or bytesinput) =>Promise<Keccak256Hash>
Parameters
input
Hex string, UTF-8 string, or Uint8Arraystring | Uint8Array<ArrayBufferLike>
Returns
Promise<Keccak256Hash>
32-byte hash
Throws
Error if native operation failsfromHex()
fromHex: (Hash hex string with Keccak-256 using native implementationhex) =>Promise<Keccak256Hash> =hashHex
Parameters
hex
string
Hex string to hash
Returns
Promise<Keccak256Hash>
32-byte hash
Throws
Error if native operation failsfromString()
fromString: (Hash UTF-8 string with Keccak-256 using native implementationstr) =>Promise<Keccak256Hash> =hashString
Parameters
str
string
String to hash
Returns
Promise<Keccak256Hash>
32-byte hash
Throws
Error if native operation failshash()
hash: (Hash data with Keccak-256 using native implementationdata) =>Promise<Keccak256Hash>
Parameters
data
Uint8Array
Data to hash
Returns
Promise<Keccak256Hash>
32-byte hash
Throws
Error if native operation failshashHex()
hashHex: (Hash hex string with Keccak-256 using native implementationhex) =>Promise<Keccak256Hash>
Parameters
hex
string
Hex string to hash
Returns
Promise<Keccak256Hash>
32-byte hash
Throws
Error if native operation failshashString()
hashString: (Hash UTF-8 string with Keccak-256 using native implementationstr) =>Promise<Keccak256Hash>
Parameters
str
string
String to hash
Returns
Promise<Keccak256Hash>
32-byte hash
Throws
Error if native operation failshashSync()
hashSync: (Synchronous hash (for backward compatibility) Throws if native library not loadeddata) =>Keccak256Hash
Parameters
data
Uint8Array
Returns
Keccak256Hash
RATE
RATE:number=136
selector()
selector: (Compute function selector (first 4 bytes of keccak256)signature) =>Promise<string>
Parameters
signature
string
Function signature (e.g., “transfer(address,uint256)“)
Returns
Promise<string>
First 4 bytes of hash as hex string
STATE_SIZE
STATE_SIZE:number=200
topic()
topic: (Compute event topic hashsignature) =>Promise<Keccak256Hash>
Parameters
signature
string
Event signature (e.g., “Transfer(address,address,uint256)“)
Returns
Promise<Keccak256Hash>
32-byte topic hash
nativeAPI
Defined in: src/native/index.ts:376 Native API object - satisfies VoltaireAPI interface This ensures compile-time errors if the native API doesn’t have all required namespaces. Note: The actual Keccak256 export is the native async version from Keccak256.native.js, but we use JS Keccak256 here for type checking since native methods are async.constnativeAPI:object
Type Declaration
Abi
Abi: typeof Abi
AccessList
AccessList: object
Namespace for AccessList operations
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: (input,outputLength?) =>Blake2Hash&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
Deprecated
Use Blake2Hash instead Blake2 alias maintained for backward compatibilityBlob
Blob: typeof Blob
BloomFilter
BloomFilter: typeof BloomFilter
Bls12381
Bls12381: object
Bls12381 main export
Example
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: object
BN254 main export
BN254.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
BN254.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
BN254.Fp
Fp: __module
BN254.Fp2
Fp2: __module
BN254.Fr
Fr: __module
BN254.G1
G1: __module
BN254.G2
G2: __module
BN254.Pairing
Pairing: __module
BN254.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
BN254.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
Bytecode
Bytecode: typeof Bytecode
Bytes
Bytes: typeof Bytes
Bytes32
Bytes32: typeof Bytes32
Chain
Chain: typeof Chain
Ed25519
Ed25519: object
Ed25519 Digital Signature Algorithm
Edwards-curve Digital Signature Algorithm (EdDSA) using Curve25519.
Fast, secure, and deterministic signatures without requiring a hash function.
Used in many modern protocols including SSH, TLS 1.3, and cryptocurrency.
Example
Ed25519.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
Ed25519.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
Ed25519.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
Ed25519.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
Ed25519.SEED_SIZE
SEED_SIZE: 32
Ed25519 seed size in bytes.
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Example
Ed25519.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
Ed25519.SIGNATURE_SIZE
SIGNATURE_SIZE: 64
Ed25519 signature size in bytes.
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Example
Ed25519.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
Ed25519.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
Ed25519.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
Ed25519.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
EIP712
EIP712: object
EIP-712 Typed Data Signing
Complete implementation of EIP-712 typed structured data hashing and signing.
Example
EIP712.Domain
Domain: object
EIP712.Domain.hash()
hash: (domain) =>HashType=hashDomain
Parameters
domain
Domain
Returns
HashType
EIP712.encodeData()
encodeData: (primaryType,data,types) =>Uint8Array
Parameters
primaryType
string
data
Message
types
TypeDefinitions
Returns
Uint8Array
EIP712.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
EIP712.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
EIP712.encodeValue()
encodeValue: (type,value,types) =>Uint8Array
Parameters
type
string
value
MessageValue
types
TypeDefinitions
Returns
Uint8Array
EIP712.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
EIP712.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
EIP712.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
EIP712.hashStruct()
hashStruct: (primaryType,data,types) =>HashType
Parameters
primaryType
string
data
Message
types
TypeDefinitions
Returns
HashType
EIP712.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
EIP712.hashType()
hashType: (primaryType,types) =>HashType
Parameters
primaryType
string
types
TypeDefinitions
Returns
HashType
EIP712.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
EIP712.hashTypedData()
hashTypedData: (typedData) =>HashType
Parameters
typedData
TypedData
Returns
HashType
EIP712.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
EIP712.recoverAddress()
recoverAddress: (signature,typedData) =>AddressType
Parameters
signature
Signature
typedData
TypedData
Returns
AddressType
EIP712.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
EIP712.signTypedData()
signTypedData: (typedData,privateKey) =>Signature
Parameters
typedData
any
privateKey
any
Returns
Signature
EIP712.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
EIP712.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
EIP712.verifyTypedData()
verifyTypedData: (signature,typedData,address) =>boolean
Parameters
signature
Signature
typedData
TypedData
address
AddressType
Returns
boolean
EIP712.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
Ether
Ether: EtherConstructor
Gwei
Gwei: GweiConstructor
Hash
Hash: HashConstructor
Hex
Hex: typeof Hex
Keccak256
Keccak256: (input) =>Keccak256Hash&object=Keccak256JS
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
KZG
KZG: typeof KZG
ModExp
ModExp: (ModExp - Modular Exponentiation Computes base^exp mod modulus for arbitrary-precision integers. Used by MODEXP precompile (0x05) per EIP-198/EIP-2565.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
See
- https://eips.ethereum.org/EIPS/eip-198 - ModExp precompile
- https://eips.ethereum.org/EIPS/eip-2565 - Gas cost repricing
Since
0.0.0Example
Opcode
Opcode: typeof Opcode
P256
P256: P256Constructor
P256 namespace with cryptographic operations
Ripemd160
Ripemd160: (input) =>Ripemd160Hash&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
Deprecated
Use Ripemd160Hash instead Ripemd160 alias maintained for backward compatibilityRlp
Rlp: typeof Rlp
Secp256k1
Secp256k1: object
secp256k1/ECDSA Cryptography namespace
Complete ECDSA signing and verification using the secp256k1 elliptic curve.
All operations use the audited @noble/curves library for security.
Full Ethereum compatibility with v = 27/28 recovery IDs.
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
Example
Secp256k1.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
Secp256k1.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
Secp256k1.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
Secp256k1.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
Secp256k1.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
Secp256k1.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
Secp256k1.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
Secp256k1.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
Secp256k1.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
Secp256k1.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
Secp256k1.PrivateKey
PrivateKey:__module=PrivateKeyMethods
Secp256k1.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
Secp256k1.PublicKey
PublicKey:__module=PublicKeyMethods
Secp256k1.randomPrivateKey()
randomPrivateKey: () =>Generate a cryptographically secure random secp256k1 private keyUint8Array<ArrayBufferLike>
Returns
Uint8Array<ArrayBufferLike>
32-byte private key
Example
Secp256k1.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
Secp256k1.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
Secp256k1.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
Secp256k1.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
Secp256k1.Signature
Signature:__module=SignatureMethods
Secp256k1.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
Secp256k1.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
Secp256k1.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
Secp256k1.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
SHA256
SHA256: (input) =>SHA256Hash&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
Deprecated
Use SHA256Hash instead SHA256 alias maintained for backward compatibilitySiwe
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: object
X25519 Elliptic Curve Diffie-Hellman
Curve25519 key exchange algorithm for secure shared secret generation.
Fast, simple, and designed for ECDH key agreement.
Used in modern protocols like TLS 1.3, WireGuard, Signal, and SSH.
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
Example
X25519.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
X25519.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
X25519.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
X25519.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
X25519.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
X25519.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
X25519.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
X25519.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
X25519.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
X25519.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
Functions
allocateOutput()
allocateOutput(Defined in: src/native-loader/index.ts:64 Helper to allocate buffer for outputsize):Uint8Array
Parameters
size
number
Returns
Uint8Array
allocateStringOutput()
allocateStringOutput(Defined in: src/native-loader/index.ts:71 Helper to allocate buffer for string outputsize):object
Parameters
size
number
Returns
object
buffer
buffer: Uint8Array
ptr
ptr: Uint8Array
checkError()
checkError(Defined in: src/native-loader/index.ts:53 Check error code and throw if non-zerocode,operation):void
Parameters
code
number
operation
string
Returns
void
getNativeErrorMessage()
getNativeErrorMessage(Defined in: src/native-loader/types.ts:224 Convert native error code to error messagecode):string
Parameters
code
number
Returns
string
getNativeExtension()
getNativeExtension(): string
Defined in: src/native-loader/platform.ts:45
Get file extension for native libraries on current platform
Returns
string
getPlatform()
getPlatform(): Platform
Defined in: src/native-loader/platform.ts:15
Get current platform identifier
Returns
Platform
isBun()
isBun(): boolean
Defined in: src/native-loader/index.ts:19
Runtime environment detection
Returns
boolean
isNativeSupported()
isNativeSupported(): boolean
Defined in: src/native-loader/platform.ts:63
Check if native bindings are supported on current platform
Returns
boolean
isNode()
isNode(): boolean
Defined in: src/native-loader/index.ts:23
Returns
boolean
loadNative()
loadNative():Defined in: src/native-loader/index.ts:34 Load native library using appropriate loaderPromise<NativeModule|ConvertFns<{primitives_abi_compute_selector: {args: readonly [cstring,ptr];returns:int32_t; };primitives_address_equals: {args: readonly [ptr,ptr];returns:bool; };primitives_address_from_hex: {args: readonly [cstring,ptr];returns:int32_t; };primitives_address_is_zero: {args: readonly [ptr];returns:bool; };primitives_address_to_checksum_hex: {args: readonly [ptr,ptr];returns:int32_t; };primitives_address_to_hex: {args: readonly [ptr,ptr];returns:int32_t; };primitives_blake2b: {args: readonly [ptr,uint64_t,ptr];returns:int32_t; };primitives_bytes_to_hex: {args: readonly [ptr,uint64_t,ptr,ptr];returns:int32_t; };primitives_hash_equals: {args: readonly [ptr,ptr];returns:bool; };primitives_hash_from_hex: {args: readonly [cstring,ptr];returns:int32_t; };primitives_hash_to_hex: {args: readonly [ptr,ptr];returns:int32_t; };primitives_hex_to_bytes: {args: readonly [cstring,ptr,ptr];returns:int32_t; };primitives_keccak256: {args: readonly [ptr,uint64_t,ptr];returns:int32_t; };primitives_ripemd160: {args: readonly [ptr,uint64_t,ptr];returns:int32_t; };primitives_secp256k1_recover_address: {args: readonly [ptr,int32_t,ptr,ptr];returns:int32_t; };primitives_sha256: {args: readonly [ptr,uint64_t,ptr];returns:int32_t; };primitives_solidity_keccak256: {args: readonly [ptr,uint64_t,ptr];returns:int32_t; };primitives_solidity_sha256: {args: readonly [ptr,uint64_t,ptr];returns:int32_t; };secp256k1DerivePublicKey: {args: readonly [ptr,ptr];returns:int32_t; };secp256k1Sign: {args: readonly [ptr,ptr,ptr];returns:int32_t; };secp256k1Verify: {args: readonly [ptr,ptr,ptr];returns:bool; }; }>>
Returns
Promise<NativeModule | ConvertFns<{ primitives_abi_compute_selector: { args: readonly [cstring, ptr]; returns: int32_t; }; primitives_address_equals: { args: readonly [ptr, ptr]; returns: bool; }; primitives_address_from_hex: { args: readonly [cstring, ptr]; returns: int32_t; }; primitives_address_is_zero: { args: readonly [ptr]; returns: bool; }; primitives_address_to_checksum_hex: { args: readonly [ptr, ptr]; returns: int32_t; }; primitives_address_to_hex: { args: readonly [ptr, ptr]; returns: int32_t; }; primitives_blake2b: { args: readonly [ptr, uint64_t, ptr]; returns: int32_t; }; primitives_bytes_to_hex: { args: readonly [ptr, uint64_t, ptr, ptr]; returns: int32_t; }; primitives_hash_equals: { args: readonly [ptr, ptr]; returns: bool; }; primitives_hash_from_hex: { args: readonly [cstring, ptr]; returns: int32_t; }; primitives_hash_to_hex: { args: readonly [ptr, ptr]; returns: int32_t; }; primitives_hex_to_bytes: { args: readonly [cstring, ptr, ptr]; returns: int32_t; }; primitives_keccak256: { args: readonly [ptr, uint64_t, ptr]; returns: int32_t; }; primitives_ripemd160: { args: readonly [ptr, uint64_t, ptr]; returns: int32_t; }; primitives_secp256k1_recover_address: { args: readonly [ptr, int32_t, ptr, ptr]; returns: int32_t; }; primitives_sha256: { args: readonly [ptr, uint64_t, ptr]; returns: int32_t; }; primitives_solidity_keccak256: { args: readonly [ptr, uint64_t, ptr]; returns: int32_t; }; primitives_solidity_sha256: { args: readonly [ptr, uint64_t, ptr]; returns: int32_t; }; secp256k1DerivePublicKey: { args: readonly [ptr, ptr]; returns: int32_t; }; secp256k1Sign: { args: readonly [ptr, ptr, ptr]; returns: int32_t; }; secp256k1Verify: { args: readonly [ptr, ptr, ptr]; returns: bool; }; }>>

