@tevm/voltaire / crypto/P256
crypto/P256
Classes
InvalidPrivateKeyError
Defined in: src/crypto/P256/errors.js:80 Error for invalid private keysSee
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Extends
Constructors
Constructor
new InvalidPrivateKeyError(Defined in: src/crypto/P256/errors.js:85message,options?):InvalidPrivateKeyError
Parameters
message
string
options?
cause?
Error
code?
string
context?
Record<string, unknown>
docsPath?
string
Returns
InvalidPrivateKeyError
Overrides
InvalidPrivateKeyError.constructor
Properties
cause?
Defined in: src/primitives/errors/AbstractError.ts:56 Root cause of this error (for error chaining)optionalcause:Error
Inherited from
InvalidPrivateKeyError.cause
code
code: string
Defined in: src/primitives/errors/AbstractError.ts:39
Machine-readable error code for programmatic handling
Example
Inherited from
InvalidPrivateKeyError.code
context?
Defined in: src/primitives/errors/AbstractError.ts:45 Additional context metadata for debuggingoptionalcontext:Record<string,unknown>
Example
Inherited from
InvalidPrivateKeyError.context
docsPath?
Defined in: src/primitives/errors/AbstractError.ts:51 Path to documentation for this erroroptionaldocsPath:string
Example
Inherited from
InvalidPrivateKeyError.docsPath
name
name: string
Defined in: src/crypto/P256/errors.js:92
Inherited from
BaseInvalidPrivateKeyError.name
Methods
getErrorChain()
getErrorChain(): string
Defined in: src/primitives/errors/AbstractError.ts:94
Get full error chain as string for logging
Returns
string
Inherited from
InvalidPrivateKeyError.getErrorChain
toJSON()
toJSON():Defined in: src/primitives/errors/AbstractError.ts:110 Serialize error to JSON for logging/telemetryRecord<string,unknown>
Returns
Record<string, unknown>
Inherited from
InvalidPrivateKeyError.toJSON
InvalidPublicKeyError
Defined in: src/crypto/P256/errors.js:58 Error for invalid public keysSee
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Extends
Constructors
Constructor
new InvalidPublicKeyError(Defined in: src/crypto/P256/errors.js:63message,options?):InvalidPublicKeyError
Parameters
message
string
options?
cause?
Error
code?
string
context?
Record<string, unknown>
docsPath?
string
Returns
InvalidPublicKeyError
Overrides
InvalidPublicKeyError.constructor
Properties
cause?
Defined in: src/primitives/errors/AbstractError.ts:56 Root cause of this error (for error chaining)optionalcause:Error
Inherited from
InvalidPublicKeyError.cause
code
code: string
Defined in: src/primitives/errors/AbstractError.ts:39
Machine-readable error code for programmatic handling
Example
Inherited from
InvalidPublicKeyError.code
context?
Defined in: src/primitives/errors/AbstractError.ts:45 Additional context metadata for debuggingoptionalcontext:Record<string,unknown>
Example
Inherited from
InvalidPublicKeyError.context
docsPath?
Defined in: src/primitives/errors/AbstractError.ts:51 Path to documentation for this erroroptionaldocsPath:string
Example
Inherited from
InvalidPublicKeyError.docsPath
name
name: string
Defined in: src/crypto/P256/errors.js:70
Inherited from
BaseInvalidPublicKeyError.name
Methods
getErrorChain()
getErrorChain(): string
Defined in: src/primitives/errors/AbstractError.ts:94
Get full error chain as string for logging
Returns
string
Inherited from
InvalidPublicKeyError.getErrorChain
toJSON()
toJSON():Defined in: src/primitives/errors/AbstractError.ts:110 Serialize error to JSON for logging/telemetryRecord<string,unknown>
Returns
Record<string, unknown>
Inherited from
InvalidPublicKeyError.toJSON
InvalidSignatureError
Defined in: src/crypto/P256/errors.js:36 Error for invalid signaturesSee
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Extends
Constructors
Constructor
new InvalidSignatureError(Defined in: src/crypto/P256/errors.js:41message,options?):InvalidSignatureError
Parameters
message
string
options?
cause?
Error
code?
string
context?
Record<string, unknown>
docsPath?
string
Returns
InvalidSignatureError
Overrides
InvalidSignatureError.constructor
Properties
cause?
Defined in: src/primitives/errors/AbstractError.ts:56 Root cause of this error (for error chaining)optionalcause:Error
Inherited from
InvalidSignatureError.cause
code
code: string
Defined in: src/primitives/errors/AbstractError.ts:39
Machine-readable error code for programmatic handling
Example
Inherited from
InvalidSignatureError.code
context?
Defined in: src/primitives/errors/AbstractError.ts:45 Additional context metadata for debuggingoptionalcontext:Record<string,unknown>
Example
Inherited from
InvalidSignatureError.context
docsPath?
Defined in: src/primitives/errors/AbstractError.ts:51 Path to documentation for this erroroptionaldocsPath:string
Example
Inherited from
InvalidSignatureError.docsPath
name
name: string
Defined in: src/crypto/P256/errors.js:48
Inherited from
BaseInvalidSignatureError.name
Methods
getErrorChain()
getErrorChain(): string
Defined in: src/primitives/errors/AbstractError.ts:94
Get full error chain as string for logging
Returns
string
Inherited from
InvalidSignatureError.getErrorChain
toJSON()
toJSON():Defined in: src/primitives/errors/AbstractError.ts:110 Serialize error to JSON for logging/telemetryRecord<string,unknown>
Returns
Record<string, unknown>
Inherited from
InvalidSignatureError.toJSON
P256Error
Defined in: src/crypto/P256/errors.js:14 Base error for P256 operationsSee
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Extends
Constructors
Constructor
new P256Error(Defined in: src/crypto/P256/errors.js:19message,options?):P256Error
Parameters
message
string
options?
cause?
Error
code?
string
context?
Record<string, unknown>
docsPath?
string
Returns
P256Error
Overrides
CryptoError.constructor
Properties
cause?
Defined in: src/primitives/errors/AbstractError.ts:56 Root cause of this error (for error chaining)optionalcause:Error
Inherited from
CryptoError.cause
code
code: string
Defined in: src/primitives/errors/AbstractError.ts:39
Machine-readable error code for programmatic handling
Example
Inherited from
CryptoError.code
context?
Defined in: src/primitives/errors/AbstractError.ts:45 Additional context metadata for debuggingoptionalcontext:Record<string,unknown>
Example
Inherited from
CryptoError.context
docsPath?
Defined in: src/primitives/errors/AbstractError.ts:51 Path to documentation for this erroroptionaldocsPath:string
Example
Inherited from
CryptoError.docsPath
name
name: string
Defined in: src/crypto/P256/errors.js:26
Inherited from
CryptoError.name
Methods
getErrorChain()
getErrorChain(): string
Defined in: src/primitives/errors/AbstractError.ts:94
Get full error chain as string for logging
Returns
string
Inherited from
CryptoError.getErrorChain
toJSON()
toJSON():Defined in: src/primitives/errors/AbstractError.ts:110 Serialize error to JSON for logging/telemetryRecord<string,unknown>
Returns
Record<string, unknown>
Inherited from
CryptoError.toJSON
Interfaces
P256Constructor
Defined in: src/crypto/P256/P256Constructor.ts:15Properties
CURVE_ORDER
CURVE_ORDER: bigint
Defined in: src/crypto/P256/P256Constructor.ts:22
derivePublicKey()
derivePublicKey: (Defined in: src/crypto/P256/P256Constructor.ts:18 Derive public key from private keyprivateKey) =>P256PublicKeyType
Parameters
privateKey
P256PrivateKeyType
32-byte private key
Returns
P256PublicKeyType
64-byte uncompressed public key (x || y coordinates)
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
If private key is invalidExample
ecdh()
ecdh: (Defined in: src/crypto/P256/P256Constructor.ts:19 Perform ECDH key exchange Computes shared secret from your private key and their public key. Returns the x-coordinate of the shared point.privateKey,publicKey) =>Uint8Array<ArrayBufferLike>
Parameters
privateKey
P256PrivateKeyType
Your 32-byte private key
publicKey
P256PublicKeyType
Their 64-byte uncompressed public key
Returns
Uint8Array<ArrayBufferLike>
32-byte shared secret
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
If private key is invalidThrows
If public key is invalidThrows
If ECDH computation failsExample
PRIVATE_KEY_SIZE
PRIVATE_KEY_SIZE: number
Defined in: src/crypto/P256/P256Constructor.ts:23
PUBLIC_KEY_SIZE
PUBLIC_KEY_SIZE: number
Defined in: src/crypto/P256/P256Constructor.ts:24
SHARED_SECRET_SIZE
SHARED_SECRET_SIZE: number
Defined in: src/crypto/P256/P256Constructor.ts:26
sign()
sign: (Defined in: src/crypto/P256/P256Constructor.ts:16 Sign a message hash with a private key Uses deterministic ECDSA (RFC 6979) for signature generation.messageHash,privateKey) =>P256SignatureType
Parameters
messageHash
HashType
32-byte message hash to sign
privateKey
P256PrivateKeyType
32-byte private key
Returns
P256SignatureType
ECDSA signature with r, s components
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
If private key is invalidThrows
If signing failsExample
SIGNATURE_COMPONENT_SIZE
SIGNATURE_COMPONENT_SIZE: number
Defined in: src/crypto/P256/P256Constructor.ts:25
validatePrivateKey()
validatePrivateKey: (Defined in: src/crypto/P256/P256Constructor.ts:20 Validate a private key Checks if the private key is in the valid range [1, n-1]privateKey) =>boolean
Parameters
privateKey
P256PrivateKeyType
Private key to validate
Returns
boolean
True if valid, false otherwise
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
Example
validatePublicKey()
validatePublicKey: (Defined in: src/crypto/P256/P256Constructor.ts:21 Validate a public key Checks if the public key is a valid point on the P256 curvepublicKey) =>boolean
Parameters
publicKey
P256PublicKeyType
Public key to validate
Returns
boolean
True if valid, false otherwise
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
Example
verify()
verify: (Defined in: src/crypto/P256/P256Constructor.ts:17 Verify an ECDSA signaturesignature,messageHash,publicKey) =>boolean
Parameters
signature
P256SignatureType
ECDSA signature to verify (r and s are HashType)
messageHash
HashType
32-byte message hash that was signed
publicKey
P256PublicKeyType
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 public key format is invalidExample
Type Aliases
P256PrivateKeyType
P256PrivateKeyType = Uint8Array
Defined in: src/crypto/P256/P256PrivateKeyType.ts:7
Private key (32 bytes scalar value)
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0P256PublicKeyType
P256PublicKeyType = Uint8Array
Defined in: src/crypto/P256/P256PublicKeyType.ts:9
Uncompressed public key (64 bytes)
Format: x-coordinate (32 bytes) || y-coordinate (32 bytes)
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0P256SignatureType
P256SignatureType = object
Defined in: src/crypto/P256/P256SignatureType.ts:11
ECDSA signature (r, s components)
Components:
- r: x-coordinate of the ephemeral public key (32 bytes, HashType)
- s: signature proof value (32 bytes, HashType)
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Properties
r
r: HashType
Defined in: src/crypto/P256/P256SignatureType.ts:12
s
s: HashType
Defined in: src/crypto/P256/P256SignatureType.ts:13
Variables
CURVE_ORDER
Defined in: src/crypto/P256/constants.js:8 P256 curve order (number of points on the curve)constCURVE_ORDER:bigint=0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551n
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0P256
Defined in: src/crypto/P256/P256.js:67 P256 namespace with cryptographic operationsconstP256:P256Constructor
PRIVATE_KEY_SIZE
Defined in: src/crypto/P256/constants.js:18 Private key size in bytesconstPRIVATE_KEY_SIZE:number=32
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0PUBLIC_KEY_SIZE
Defined in: src/crypto/P256/constants.js:27 Uncompressed public key size in bytes (64 bytes, no prefix)constPUBLIC_KEY_SIZE:number=64
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0SHARED_SECRET_SIZE
Defined in: src/crypto/P256/constants.js:45 ECDH shared secret size in bytesconstSHARED_SECRET_SIZE:number=32
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0SIGNATURE_COMPONENT_SIZE
Defined in: src/crypto/P256/constants.js:36 Signature component size in bytes (r and s are each 32 bytes)constSIGNATURE_COMPONENT_SIZE:number=32
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Functions
derivePublicKey()
derivePublicKey(Defined in: src/crypto/P256/derivePublicKey.js:21 Derive public key from private keyprivateKey):P256PublicKeyType
Parameters
privateKey
P256PrivateKeyType
32-byte private key
Returns
P256PublicKeyType
64-byte uncompressed public key (x || y coordinates)
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
If private key is invalidExample
ecdh()
ecdh(Defined in: src/crypto/P256/ecdh.js:32 Perform ECDH key exchange Computes shared secret from your private key and their public key. Returns the x-coordinate of the shared point.privateKey,publicKey):Uint8Array<ArrayBufferLike>
Parameters
privateKey
P256PrivateKeyType
Your 32-byte private key
publicKey
P256PublicKeyType
Their 64-byte uncompressed public key
Returns
Uint8Array<ArrayBufferLike>
32-byte shared secret
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
If private key is invalidThrows
If public key is invalidThrows
If ECDH computation failsExample
sign()
sign(Defined in: src/crypto/P256/sign.js:28 Sign a message hash with a private key Uses deterministic ECDSA (RFC 6979) for signature generation.messageHash,privateKey):P256SignatureType
Parameters
messageHash
HashType
32-byte message hash to sign
privateKey
P256PrivateKeyType
32-byte private key
Returns
P256SignatureType
ECDSA signature with r, s components
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
If private key is invalidThrows
If signing failsExample
validatePrivateKey()
validatePrivateKey(Defined in: src/crypto/P256/validatePrivateKey.js:22 Validate a private key Checks if the private key is in the valid range [1, n-1]privateKey):boolean
Parameters
privateKey
P256PrivateKeyType
Private key to validate
Returns
boolean
True if valid, false otherwise
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
Example
validatePublicKey()
validatePublicKey(Defined in: src/crypto/P256/validatePublicKey.js:22 Validate a public key Checks if the public key is a valid point on the P256 curvepublicKey):boolean
Parameters
publicKey
P256PublicKeyType
Public key to validate
Returns
boolean
True if valid, false otherwise
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
Example
verify()
verify(Defined in: src/crypto/P256/verify.js:26 Verify an ECDSA signaturesignature,messageHash,publicKey):boolean
Parameters
signature
P256SignatureType
ECDSA signature to verify (r and s are HashType)
messageHash
HashType
32-byte message hash that was signed
publicKey
P256PublicKeyType
64-byte uncompressed public key
Returns
boolean
True if signature is valid, false otherwise

