@tevm/voltaire / primitives/PrivateKey
primitives/PrivateKey
Type Aliases
PrivateKeyType
PrivateKeyType =Defined in: src/primitives/PrivateKey/PrivateKeyType.ts:7 Branded PrivateKey type - 32 byte private key for cryptographic operations Prevents accidental exposure or misuse of sensitive key materialUint8Array&object
Type Declaration
[brand]
readonly[brand]:"PrivateKey"
length
readonlylength:32
Variables
_sign()
Defined in: src/primitives/PrivateKey/index.ts:25const_sign: (privateKey,hash) =>Secp256k1SignatureType
Parameters
privateKey
PrivateKeyType
hash
HashType
Returns
Secp256k1SignatureType
PrivateKey
Defined in: src/primitives/PrivateKey/index.ts:51constPrivateKey:object
Type Declaration
from()
from: (Create PrivateKey from hex stringhex) =>PrivateKeyType
Parameters
hex
string
Hex string (32 bytes)
Returns
PrivateKeyType
Private key
Throws
If hex string format is invalidThrows
If hex is not 32 bytesExample
fromBytes()
fromBytes: (Create PrivateKey from raw bytesbytes) =>PrivateKeyType
Parameters
bytes
Uint8Array<ArrayBufferLike>
Raw bytes (must be 32 bytes)
Returns
PrivateKeyType
Private key
Throws
If bytes is not 32 bytesExample
sign()
sign: (privateKey,hash) =>Secp256k1SignatureType
Parameters
privateKey
string
hash
HashType
Returns
Secp256k1SignatureType
toAddress()
toAddress: (privateKey) =>AddressType
Parameters
privateKey
string
Returns
AddressType
toHex()
toHex: (privateKey) =>string
Parameters
privateKey
string
Returns
string
toPublicKey()
toPublicKey: (privateKey) =>PublicKeyType
Parameters
privateKey
string
Returns
PublicKeyType
Functions
_toAddress()
_toAddress(Defined in: src/primitives/PrivateKey/toAddress.ts:17 Derive Ethereum address from private keythis):AddressType
Parameters
this
PrivateKeyType
Private key
Returns
AddressType
Ethereum address (20 bytes)
Example
_toHex()
_toHex(Defined in: src/primitives/PrivateKey/toHex.ts:14 Convert PrivateKey to hex stringthis):string
Parameters
this
PrivateKeyType
Private key
Returns
string
Hex string
Example
_toPublicKey()
_toPublicKey(Defined in: src/primitives/PrivateKey/toPublicKey.ts:16 Derive public key from private keythis):PublicKeyType
Parameters
this
PrivateKeyType
Private key
Returns
PublicKeyType
Public key (uncompressed 64 bytes)
Example
from()
from(Defined in: src/primitives/PrivateKey/from.ts:22 Create PrivateKey from hex stringhex):PrivateKeyType
Parameters
hex
string
Hex string (32 bytes)
Returns
PrivateKeyType
Private key
Throws
If hex string format is invalidThrows
If hex is not 32 bytesExample
fromBytes()
fromBytes(Defined in: src/primitives/PrivateKey/fromBytes.js:17 Create PrivateKey from raw bytesbytes):PrivateKeyType
Parameters
bytes
Uint8Array<ArrayBufferLike>
Raw bytes (must be 32 bytes)
Returns
PrivateKeyType
Private key
Throws
If bytes is not 32 bytesExample
sign()
sign(Defined in: src/primitives/PrivateKey/index.ts:40privateKey,hash):Secp256k1SignatureType
Parameters
privateKey
string
hash
HashType
Returns
Secp256k1SignatureType
Sign()
Sign(Defined in: src/primitives/PrivateKey/sign.js:7 Factory: Sign a message hash with private keydeps): (privateKey,hash) =>Secp256k1SignatureType
Parameters
deps
Crypto dependenciessecp256k1Sign
(messageHash, privateKey) => Secp256k1SignatureType
Secp256k1 signing function
Returns
Function that creates ECDSA signature(privateKey,hash):Secp256k1SignatureType
Parameters
privateKey
PrivateKeyType
hash
HashType
Returns
Secp256k1SignatureType
toAddress()
toAddress(Defined in: src/primitives/PrivateKey/index.ts:36privateKey):AddressType
Parameters
privateKey
string
Returns
AddressType
toHex()
toHex(Defined in: src/primitives/PrivateKey/index.ts:28privateKey):string
Parameters
privateKey
string
Returns
string
toPublicKey()
toPublicKey(Defined in: src/primitives/PrivateKey/index.ts:32privateKey):PublicKeyType
Parameters
privateKey
string
Returns
PublicKeyType

