Skip to main content
@tevm/voltaire
@tevm/voltaire / primitives/Signature

primitives/Signature

Classes

InvalidAlgorithmError

Defined in: src/primitives/Signature/errors.js:103 Error for invalid signature algorithm

Example

Extends

Constructors

Constructor
new InvalidAlgorithmError(message, options?): InvalidAlgorithmError
Defined in: src/primitives/Signature/errors.js:114
Parameters
message
string
options?
cause?
Error
code?
string
context?
Record<string, unknown>
docsPath?
string
expected?
string
value?
unknown
Returns
InvalidAlgorithmError
Overrides
InvalidSignatureError.constructor

Properties

cause?
optional cause: Error
Defined in: src/primitives/errors/AbstractError.ts:56 Root cause of this error (for error chaining)
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?
optional context: Record<string, unknown>
Defined in: src/primitives/errors/AbstractError.ts:45 Additional context metadata for debugging
Example
Inherited from
InvalidSignatureError.context
docsPath?
optional docsPath: string
Defined in: src/primitives/errors/AbstractError.ts:51 Path to documentation for this error
Example
Inherited from
InvalidSignatureError.docsPath
name
name: string
Defined in: src/primitives/Signature/errors.js:125
Inherited from
InvalidSignatureError.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(): Record<string, unknown>
Defined in: src/primitives/errors/AbstractError.ts:110 Serialize error to JSON for logging/telemetry
Returns
Record<string, unknown>
Inherited from
InvalidSignatureError.toJSON

InvalidDERError

Defined in: src/primitives/Signature/errors.js:187 Error for invalid DER encoding

Example

Extends

Constructors

Constructor
new InvalidDERError(message, options?): InvalidDERError
Defined in: src/primitives/Signature/errors.js:198
Parameters
message
string
options?
cause?
Error
code?
string
context?
Record<string, unknown>
docsPath?
string
expected?
string
value?
unknown
Returns
InvalidDERError
Overrides
InvalidFormatError.constructor

Properties

cause?
optional cause: Error
Defined in: src/primitives/errors/AbstractError.ts:56 Root cause of this error (for error chaining)
Inherited from
InvalidFormatError.cause
code
code: string
Defined in: src/primitives/errors/AbstractError.ts:39 Machine-readable error code for programmatic handling
Example
Inherited from
InvalidFormatError.code
context?
optional context: Record<string, unknown>
Defined in: src/primitives/errors/AbstractError.ts:45 Additional context metadata for debugging
Example
Inherited from
InvalidFormatError.context
docsPath?
optional docsPath: string
Defined in: src/primitives/errors/AbstractError.ts:51 Path to documentation for this error
Example
Inherited from
InvalidFormatError.docsPath
expected
expected: string
Defined in: src/primitives/errors/ValidationError.ts:19
Inherited from
InvalidFormatError.expected
name
name: string
Defined in: src/primitives/Signature/errors.js:208
Inherited from
InvalidFormatError.name
value
value: unknown
Defined in: src/primitives/errors/ValidationError.ts:18
Inherited from
InvalidFormatError.value

Methods

getErrorChain()
getErrorChain(): string
Defined in: src/primitives/errors/AbstractError.ts:94 Get full error chain as string for logging
Returns
string
Inherited from
InvalidFormatError.getErrorChain
toJSON()
toJSON(): Record<string, unknown>
Defined in: src/primitives/errors/AbstractError.ts:110 Serialize error to JSON for logging/telemetry
Returns
Record<string, unknown>
Inherited from
InvalidFormatError.toJSON

InvalidSignatureFormatError

Defined in: src/primitives/Signature/errors.js:63 Error for invalid signature format

Example

Extends

Constructors

Constructor
new InvalidSignatureFormatError(message, options?): InvalidSignatureFormatError
Defined in: src/primitives/Signature/errors.js:74
Parameters
message
string
options?
cause?
Error
code?
string
context?
Record<string, unknown>
docsPath?
string
expected?
string
value?
unknown
Returns
InvalidSignatureFormatError
Overrides
InvalidFormatError.constructor

Properties

cause?
optional cause: Error
Defined in: src/primitives/errors/AbstractError.ts:56 Root cause of this error (for error chaining)
Inherited from
InvalidFormatError.cause
code
code: string
Defined in: src/primitives/errors/AbstractError.ts:39 Machine-readable error code for programmatic handling
Example
Inherited from
InvalidFormatError.code
context?
optional context: Record<string, unknown>
Defined in: src/primitives/errors/AbstractError.ts:45 Additional context metadata for debugging
Example
Inherited from
InvalidFormatError.context
docsPath?
optional docsPath: string
Defined in: src/primitives/errors/AbstractError.ts:51 Path to documentation for this error
Example
Inherited from
InvalidFormatError.docsPath
expected
expected: string
Defined in: src/primitives/errors/ValidationError.ts:19
Inherited from
InvalidFormatError.expected
name
name: string
Defined in: src/primitives/Signature/errors.js:83
Inherited from
InvalidFormatError.name
value
value: unknown
Defined in: src/primitives/errors/ValidationError.ts:18
Inherited from
InvalidFormatError.value

Methods

getErrorChain()
getErrorChain(): string
Defined in: src/primitives/errors/AbstractError.ts:94 Get full error chain as string for logging
Returns
string
Inherited from
InvalidFormatError.getErrorChain
toJSON()
toJSON(): Record<string, unknown>
Defined in: src/primitives/errors/AbstractError.ts:110 Serialize error to JSON for logging/telemetry
Returns
Record<string, unknown>
Inherited from
InvalidFormatError.toJSON

InvalidSignatureLengthError

Defined in: src/primitives/Signature/errors.js:23 Error for invalid signature length

Example

Extends

Constructors

Constructor
new InvalidSignatureLengthError(message, options?): InvalidSignatureLengthError
Defined in: src/primitives/Signature/errors.js:34
Parameters
message
string
options?
cause?
Error
code?
string
context?
Record<string, unknown>
docsPath?
string
expected?
string
value?
unknown
Returns
InvalidSignatureLengthError
Overrides
InvalidLengthError.constructor

Properties

cause?
optional cause: Error
Defined in: src/primitives/errors/AbstractError.ts:56 Root cause of this error (for error chaining)
Inherited from
InvalidLengthError.cause
code
code: string
Defined in: src/primitives/errors/AbstractError.ts:39 Machine-readable error code for programmatic handling
Example
Inherited from
InvalidLengthError.code
context?
optional context: Record<string, unknown>
Defined in: src/primitives/errors/AbstractError.ts:45 Additional context metadata for debugging
Example
Inherited from
InvalidLengthError.context
docsPath?
optional docsPath: string
Defined in: src/primitives/errors/AbstractError.ts:51 Path to documentation for this error
Example
Inherited from
InvalidLengthError.docsPath
expected
expected: string
Defined in: src/primitives/errors/ValidationError.ts:19
Inherited from
InvalidLengthError.expected
name
name: string
Defined in: src/primitives/Signature/errors.js:43
Inherited from
InvalidLengthError.name
value
value: unknown
Defined in: src/primitives/errors/ValidationError.ts:18
Inherited from
InvalidLengthError.value

Methods

getErrorChain()
getErrorChain(): string
Defined in: src/primitives/errors/AbstractError.ts:94 Get full error chain as string for logging
Returns
string
Inherited from
InvalidLengthError.getErrorChain
toJSON()
toJSON(): Record<string, unknown>
Defined in: src/primitives/errors/AbstractError.ts:110 Serialize error to JSON for logging/telemetry
Returns
Record<string, unknown>
Inherited from
InvalidLengthError.toJSON

NonCanonicalSignatureError

Defined in: src/primitives/Signature/errors.js:145 Error for non-canonical signature

Example

Extends

Constructors

Constructor
new NonCanonicalSignatureError(message, options?): NonCanonicalSignatureError
Defined in: src/primitives/Signature/errors.js:156
Parameters
message
string
options?
cause?
Error
code?
string
context?
Record<string, unknown>
docsPath?
string
expected?
string
value?
unknown
Returns
NonCanonicalSignatureError
Overrides
InvalidSignatureError.constructor

Properties

cause?
optional cause: Error
Defined in: src/primitives/errors/AbstractError.ts:56 Root cause of this error (for error chaining)
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?
optional context: Record<string, unknown>
Defined in: src/primitives/errors/AbstractError.ts:45 Additional context metadata for debugging
Example
Inherited from
InvalidSignatureError.context
docsPath?
optional docsPath: string
Defined in: src/primitives/errors/AbstractError.ts:51 Path to documentation for this error
Example
Inherited from
InvalidSignatureError.docsPath
name
name: string
Defined in: src/primitives/Signature/errors.js:167
Inherited from
InvalidSignatureError.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(): Record<string, unknown>
Defined in: src/primitives/errors/AbstractError.ts:110 Serialize error to JSON for logging/telemetry
Returns
Record<string, unknown>
Inherited from
InvalidSignatureError.toJSON

Type Aliases

SignatureAlgorithm

SignatureAlgorithm = "secp256k1" | "p256" | "ed25519"
Defined in: src/primitives/Signature/SignatureType.ts:6 Algorithm types supported by the Signature primitive

SignatureType

SignatureType = Uint8Array & object
Defined in: src/primitives/Signature/SignatureType.ts:17 Unified signature type with algorithm tagging Structure:
  • For ECDSA (secp256k1, p256): r (32 bytes) + s (32 bytes) + optional v (1 byte for secp256k1)
  • For Ed25519: signature (64 bytes)
Algorithm is tracked in metadata, not in the bytes

Type Declaration

[brand]
readonly [brand]: "Signature"
algorithm
readonly algorithm: SignatureAlgorithm
v?
readonly optional v: number

Variables

COMPONENT_SIZE

const COMPONENT_SIZE: 32 = 32
Defined in: src/primitives/Signature/constants.js:15 Size of r or s component in bytes

ECDSA_SIZE

const ECDSA_SIZE: 64 = 64
Defined in: src/primitives/Signature/constants.js:6 Size of ECDSA signature (r + s) in bytes

ECDSA_WITH_V_SIZE

const ECDSA_WITH_V_SIZE: 65 = 65
Defined in: src/primitives/Signature/constants.js:9 Size of ECDSA signature with recovery ID (r + s + v) in bytes

ED25519_SIZE

const ED25519_SIZE: 64 = 64
Defined in: src/primitives/Signature/constants.js:12 Size of Ed25519 signature in bytes

RECOVERY_ID_MAX

const RECOVERY_ID_MAX: 28 = 28
Defined in: src/primitives/Signature/constants.js:19

RECOVERY_ID_MIN

const RECOVERY_ID_MIN: 27 = 27
Defined in: src/primitives/Signature/constants.js:18 Ethereum recovery ID values

Signature

const Signature: object
Defined in: src/primitives/Signature/index.ts:69

Type Declaration

equals()
equals: (a, b) => boolean
Check if two signatures are equal
Parameters
a
SignatureType First signature
b
SignatureType Second signature
Returns
boolean True if signatures are equal
Example
from()
from: (value) => SignatureType
Create Signature from various input types (universal constructor)
Parameters
value
Signature data Uint8Array<ArrayBufferLike> | { algorithm?: SignatureAlgorithm; r: Uint8Array; s: Uint8Array; v?: number; } | { algorithm: "ed25519"; signature: Uint8Array; }
Returns
SignatureType Signature
Throws
If value format is unsupported or invalid
Throws
If signature length is invalid
Example
fromBytes()
fromBytes: (bytes, algorithmOrV?) => SignatureType
Create Signature from raw bytes Wrapper around fromCompact with clearer semantics for byte input. Formats supported:
  • 64 bytes: ECDSA r+s (with optional EIP-2098 yParity in bit 255) or Ed25519 signature
  • 65 bytes: ECDSA r+s+v (secp256k1 only)
Parameters
bytes
Uint8Array<ArrayBufferLike> Signature bytes
algorithmOrV?
Algorithm or explicit v value number | SignatureAlgorithm
Returns
SignatureType Signature
Throws
If bytes length is invalid
Example
fromCompact()
fromCompact: (bytes, algorithmOrV) => SignatureType
Create Signature from compact format (EIP-2098: supports yParity in bit 255 of s)
Parameters
bytes
Uint8Array<ArrayBufferLike> Compact signature bytes (64 or 65 bytes)
algorithmOrV
Algorithm or explicit v value number | SignatureAlgorithm
Returns
SignatureType Signature
Throws
If bytes length is invalid
Example
fromDER()
fromDER: (der, algorithm, v?) => SignatureType
Create Signature from DER-encoded ECDSA signature
Parameters
der
Uint8Array<ArrayBufferLike> DER-encoded signature
algorithm
SignatureAlgorithm Algorithm (secp256k1 or p256)
v?
number Optional recovery ID for secp256k1
Returns
SignatureType Signature
Throws
If DER encoding is invalid
Example
fromEd25519()
fromEd25519: (signature) => SignatureType
Create Signature from Ed25519 signature
Parameters
signature
Uint8Array<ArrayBufferLike> Ed25519 signature (64 bytes)
Returns
SignatureType Signature
Throws
If signature is not 64 bytes
Example
fromHex()
fromHex: (value, algorithm?) => SignatureType
Create Signature from hex string Formats supported:
  • 128 hex chars (64 bytes): ECDSA r+s or Ed25519 signature
  • 130 hex chars (65 bytes): ECDSA r+s+v
Parameters
value
string Hex string (with or without 0x prefix)
algorithm?
SignatureAlgorithm = "secp256k1" Signature algorithm
Returns
SignatureType Signature
Throws
If value is not a string
Throws
If hex length is invalid
Example
fromP256()
fromP256: (r, s) => SignatureType
Create Signature from P-256 ECDSA signature
Parameters
r
Uint8Array<ArrayBufferLike> r component (32 bytes)
s
Uint8Array<ArrayBufferLike> s component (32 bytes)
Returns
SignatureType Signature
Example
fromRpc()
fromRpc: (rpc) => SignatureType
Create Signature from RPC format
Parameters
rpc
RPC format signature
r
string
s
string
v?
string | number
yParity?
string | number
Returns
SignatureType Signature
Example
fromSecp256k1()
fromSecp256k1: (r, s, v?) => SignatureType
Create Signature from secp256k1 ECDSA signature
Parameters
r
Uint8Array<ArrayBufferLike> r component (32 bytes)
s
Uint8Array<ArrayBufferLike> s component (32 bytes)
v?
number Optional recovery ID (27 or 28 for Ethereum)
Returns
SignatureType Signature
Example
fromTuple()
fromTuple: (tuple, chainId?) => SignatureType
Create Signature from tuple format [yParity, r, s]
Parameters
tuple
[number, Uint8Array<ArrayBufferLike>, Uint8Array<ArrayBufferLike>] Tuple [yParity, r, s]
chainId?
number Optional chain ID for EIP-155 v encoding
Returns
SignatureType Signature
Example
getAlgorithm()
getAlgorithm: (signature) => SignatureAlgorithm
Get the algorithm of a signature
Parameters
signature
SignatureType Signature to check
Returns
SignatureAlgorithm Signature algorithm
Example
getR()
getR: (signature) => HashType
Get r component from ECDSA signature
Parameters
signature
SignatureType Signature
Returns
HashType r component (32 bytes, HashType)
Throws
If signature is not ECDSA
Example
getS()
getS: (signature) => HashType
Get s component from ECDSA signature
Parameters
signature
SignatureType Signature
Returns
HashType s component (32 bytes, HashType)
Throws
If signature is not ECDSA
Example
getV()
getV: (signature) => number | undefined
Get v (recovery ID) from secp256k1 signature
Parameters
signature
SignatureType Signature
Returns
number | undefined Recovery ID (27 or 28) or undefined
Throws
If signature is not secp256k1
Example
is()
is: (value) => value is SignatureType
Check if value is a SignatureType
Parameters
value
unknown Value to check
Returns
value is SignatureType True if value is a SignatureType
Example
isCanonical()
isCanonical: (signature) => boolean
Check if ECDSA signature has canonical s-value (s is less than or equal to n/2) For secp256k1 and p256, a signature is canonical if s is at most curve_order / 2 This prevents signature malleability.
Parameters
signature
SignatureType Signature to check
Returns
boolean True if signature is canonical or Ed25519
Example
normalize()
normalize: (signature) => SignatureType
Normalize ECDSA signature to canonical form (s = n - s if s > n/2)
Parameters
signature
SignatureType Signature to normalize
Returns
SignatureType Normalized signature
Example
toBytes()
toBytes: (signature) => Uint8Array<ArrayBufferLike>
Convert Signature to raw bytes (without metadata)
Parameters
signature
SignatureType Signature to convert
Returns
Uint8Array<ArrayBufferLike> Raw signature bytes
Example
toCompact()
toCompact: (signature) => Uint8Array<ArrayBufferLike>
Convert Signature to compact format (EIP-2098: yParity encoded in bit 255 of s)
Parameters
signature
SignatureType Signature to convert
Returns
Uint8Array<ArrayBufferLike> Compact signature (64 bytes with yParity in bit 255 of s)
Example
toDER()
toDER: (signature) => Uint8Array<ArrayBufferLike>
Convert ECDSA signature to DER encoding
Parameters
signature
SignatureType Signature to convert
Returns
Uint8Array<ArrayBufferLike> DER-encoded signature
Throws
If signature is not ECDSA (secp256k1 or p256)
Example
toHex()
toHex: (signature, includeV?) => string
Convert Signature to hex string Formats:
  • ECDSA without v: 128 hex chars (64 bytes: r + s)
  • ECDSA with v: 130 hex chars (65 bytes: r + s + v)
  • Ed25519: 128 hex chars (64 bytes)
Parameters
signature
SignatureType Signature to convert
includeV?
boolean = true Include v byte for secp256k1 (if present)
Returns
string Hex string with 0x prefix
Example
toRpc()
toRpc: (signature) => object
Convert Signature to RPC format (r, s, yParity as hex strings)
Parameters
signature
SignatureType Signature to convert
Returns
object RPC format signature
r
r: string
s
s: string
v?
optional v: string
yParity
yParity: string
Throws
If signature is not secp256k1
Example
toTuple()
toTuple: (signature) => [number, Uint8Array<ArrayBufferLike>, Uint8Array<ArrayBufferLike>]
Convert Signature to tuple format [yParity, r, s] for transaction envelopes
Parameters
signature
SignatureType Signature to convert
Returns
[number, Uint8Array<ArrayBufferLike>, Uint8Array<ArrayBufferLike>] Tuple [yParity, r, s]
Throws
If signature is not secp256k1 or has no v value
Example
verify()
verify: (signature, _message, _publicKey) => boolean
Verify signature against message and public key Note: This is a placeholder. Actual verification requires crypto implementations. Use this in conjunction with crypto library functions.
Parameters
signature
SignatureType Signature to verify
_message
Uint8Array<ArrayBufferLike> Message that was signed
_publicKey
Uint8Array<ArrayBufferLike> Public key to verify against
Returns
boolean True if signature is valid
Throws
If algorithm-specific verification is not available
Example

Functions

equals()

equals(a, b): boolean
Defined in: src/primitives/Signature/equals.js:13 Check if two signatures are equal

Parameters

a
SignatureType First signature
b
SignatureType Second signature

Returns

boolean True if signatures are equal

Example


from()

from(value): SignatureType
Defined in: src/primitives/Signature/from.js:29 Create Signature from various input types (universal constructor)

Parameters

value
Signature data Uint8Array<ArrayBufferLike> | { algorithm?: SignatureAlgorithm; r: Uint8Array; s: Uint8Array; v?: number; } | { algorithm: "ed25519"; signature: Uint8Array; }

Returns

SignatureType Signature

Throws

If value format is unsupported or invalid

Throws

If signature length is invalid

Example


fromBytes()

fromBytes(bytes, algorithmOrV?): SignatureType
Defined in: src/primitives/Signature/fromBytes.js:32 Create Signature from raw bytes Wrapper around fromCompact with clearer semantics for byte input. Formats supported:
  • 64 bytes: ECDSA r+s (with optional EIP-2098 yParity in bit 255) or Ed25519 signature
  • 65 bytes: ECDSA r+s+v (secp256k1 only)

Parameters

bytes
Uint8Array<ArrayBufferLike> Signature bytes
algorithmOrV?
Algorithm or explicit v value number | SignatureAlgorithm

Returns

SignatureType Signature

Throws

If bytes length is invalid

Example


fromCompact()

fromCompact(bytes, algorithmOrV): SignatureType
Defined in: src/primitives/Signature/fromCompact.js:35 Create Signature from compact format (EIP-2098: supports yParity in bit 255 of s)

Parameters

bytes
Uint8Array<ArrayBufferLike> Compact signature bytes (64 or 65 bytes)
algorithmOrV
Algorithm or explicit v value number | SignatureAlgorithm

Returns

SignatureType Signature

Throws

If bytes length is invalid

Example


fromDER()

fromDER(der, algorithm, v?): SignatureType
Defined in: src/primitives/Signature/fromDER.js:20 Create Signature from DER-encoded ECDSA signature

Parameters

der
Uint8Array<ArrayBufferLike> DER-encoded signature
algorithm
SignatureAlgorithm Algorithm (secp256k1 or p256)
v?
number Optional recovery ID for secp256k1

Returns

SignatureType Signature

Throws

If DER encoding is invalid

Example


fromEd25519()

fromEd25519(signature): SignatureType
Defined in: src/primitives/Signature/fromEd25519.js:16 Create Signature from Ed25519 signature

Parameters

signature
Uint8Array<ArrayBufferLike> Ed25519 signature (64 bytes)

Returns

SignatureType Signature

Throws

If signature is not 64 bytes

Example


fromHex()

fromHex(value, algorithm?): SignatureType
Defined in: src/primitives/Signature/fromHex.js:36 Create Signature from hex string Formats supported:
  • 128 hex chars (64 bytes): ECDSA r+s or Ed25519 signature
  • 130 hex chars (65 bytes): ECDSA r+s+v

Parameters

value
string Hex string (with or without 0x prefix)
algorithm?
SignatureAlgorithm = "secp256k1" Signature algorithm

Returns

SignatureType Signature

Throws

If value is not a string

Throws

If hex length is invalid

Example


fromP256()

fromP256(r, s): SignatureType
Defined in: src/primitives/Signature/fromP256.js:16 Create Signature from P-256 ECDSA signature

Parameters

r
Uint8Array<ArrayBufferLike> r component (32 bytes)
s
Uint8Array<ArrayBufferLike> s component (32 bytes)

Returns

SignatureType Signature

Example


fromRpc()

fromRpc(rpc): SignatureType
Defined in: src/primitives/Signature/fromRpc.js:19 Create Signature from RPC format

Parameters

rpc
RPC format signature
r
string
s
string
v?
string | number
yParity?
string | number

Returns

SignatureType Signature

Example


fromSecp256k1()

fromSecp256k1(r, s, v?): SignatureType
Defined in: src/primitives/Signature/fromSecp256k1.js:17 Create Signature from secp256k1 ECDSA signature

Parameters

r
Uint8Array<ArrayBufferLike> r component (32 bytes)
s
Uint8Array<ArrayBufferLike> s component (32 bytes)
v?
number Optional recovery ID (27 or 28 for Ethereum)

Returns

SignatureType Signature

Example


fromTuple()

fromTuple(tuple, chainId?): SignatureType
Defined in: src/primitives/Signature/fromTuple.js:18 Create Signature from tuple format [yParity, r, s]

Parameters

tuple
[number, Uint8Array<ArrayBufferLike>, Uint8Array<ArrayBufferLike>] Tuple [yParity, r, s]
chainId?
number Optional chain ID for EIP-155 v encoding

Returns

SignatureType Signature

Example


getAlgorithm()

getAlgorithm(signature): SignatureAlgorithm
Defined in: src/primitives/Signature/getAlgorithm.js:13 Get the algorithm of a signature

Parameters

signature
SignatureType Signature to check

Returns

SignatureAlgorithm Signature algorithm

Example


getR()

getR(signature): HashType
Defined in: src/primitives/Signature/getR.js:16 Get r component from ECDSA signature

Parameters

signature
SignatureType Signature

Returns

HashType r component (32 bytes, HashType)

Throws

If signature is not ECDSA

Example


getS()

getS(signature): HashType
Defined in: src/primitives/Signature/getS.js:16 Get s component from ECDSA signature

Parameters

signature
SignatureType Signature

Returns

HashType s component (32 bytes, HashType)

Throws

If signature is not ECDSA

Example


getV()

getV(signature): number | undefined
Defined in: src/primitives/Signature/getV.js:15 Get v (recovery ID) from secp256k1 signature

Parameters

signature
SignatureType Signature

Returns

number | undefined Recovery ID (27 or 28) or undefined

Throws

If signature is not secp256k1

Example


is()

is(value): value is SignatureType
Defined in: src/primitives/Signature/is.js:14 Check if value is a SignatureType

Parameters

value
unknown Value to check

Returns

value is SignatureType True if value is a SignatureType

Example


isCanonical()

isCanonical(signature): boolean
Defined in: src/primitives/Signature/isCanonical.js:19 Check if ECDSA signature has canonical s-value (s is less than or equal to n/2) For secp256k1 and p256, a signature is canonical if s is at most curve_order / 2 This prevents signature malleability.

Parameters

signature
SignatureType Signature to check

Returns

boolean True if signature is canonical or Ed25519

Example


normalize()

normalize(signature): SignatureType
Defined in: src/primitives/Signature/normalize.js:19 Normalize ECDSA signature to canonical form (s = n - s if s > n/2)

Parameters

signature
SignatureType Signature to normalize

Returns

SignatureType Normalized signature

Example


toBytes()

toBytes(signature): Uint8Array<ArrayBufferLike>
Defined in: src/primitives/Signature/toBytes.js:13 Convert Signature to raw bytes (without metadata)

Parameters

signature
SignatureType Signature to convert

Returns

Uint8Array<ArrayBufferLike> Raw signature bytes

Example


toCompact()

toCompact(signature): Uint8Array<ArrayBufferLike>
Defined in: src/primitives/Signature/toCompact.js:13 Convert Signature to compact format (EIP-2098: yParity encoded in bit 255 of s)

Parameters

signature
SignatureType Signature to convert

Returns

Uint8Array<ArrayBufferLike> Compact signature (64 bytes with yParity in bit 255 of s)

Example


toDER()

toDER(signature): Uint8Array<ArrayBufferLike>
Defined in: src/primitives/Signature/toDER.js:17 Convert ECDSA signature to DER encoding

Parameters

signature
SignatureType Signature to convert

Returns

Uint8Array<ArrayBufferLike> DER-encoded signature

Throws

If signature is not ECDSA (secp256k1 or p256)

Example


toHex()

toHex(signature, includeV?): string
Defined in: src/primitives/Signature/toHex.js:23 Convert Signature to hex string Formats:
  • ECDSA without v: 128 hex chars (64 bytes: r + s)
  • ECDSA with v: 130 hex chars (65 bytes: r + s + v)
  • Ed25519: 128 hex chars (64 bytes)

Parameters

signature
SignatureType Signature to convert
includeV?
boolean = true Include v byte for secp256k1 (if present)

Returns

string Hex string with 0x prefix

Example


toRpc()

toRpc(signature): object
Defined in: src/primitives/Signature/toRpc.js:20 Convert Signature to RPC format (r, s, yParity as hex strings)

Parameters

signature
SignatureType Signature to convert

Returns

object RPC format signature
r
r: string
s
s: string
v?
optional v: string
yParity
yParity: string

Throws

If signature is not secp256k1

Example


toTuple()

toTuple(signature): [number, Uint8Array<ArrayBufferLike>, Uint8Array<ArrayBufferLike>]
Defined in: src/primitives/Signature/toTuple.js:19 Convert Signature to tuple format [yParity, r, s] for transaction envelopes

Parameters

signature
SignatureType Signature to convert

Returns

[number, Uint8Array<ArrayBufferLike>, Uint8Array<ArrayBufferLike>] Tuple [yParity, r, s]

Throws

If signature is not secp256k1 or has no v value

Example


verify()

verify(signature, _message, _publicKey): boolean
Defined in: src/primitives/Signature/verify.js:20 Verify signature against message and public key Note: This is a placeholder. Actual verification requires crypto implementations. Use this in conjunction with crypto library functions.

Parameters

signature
SignatureType Signature to verify
_message
Uint8Array<ArrayBufferLike> Message that was signed
_publicKey
Uint8Array<ArrayBufferLike> Public key to verify against

Returns

boolean True if signature is valid

Throws

If algorithm-specific verification is not available

Example

References

default

Renames and re-exports Signature