Skip to main content

Try it Live

Run Signature examples in the interactive playground

Utilities

Helper functions for signature operations.

Component Extraction

getAlgorithm

Get signature algorithm.

Signature

Parameters

  • signature - BrandedSignature

Returns

SignatureAlgorithm ("secp256k1" | "p256" | "ed25519")

Example

getR

Extract r component from ECDSA signature.

Signature

Parameters

  • signature - ECDSA BrandedSignature

Returns

Uint8Array (32 bytes) - r component

Throws

  • Error if signature is Ed25519 (no r component)

Example

getS

Extract s component from ECDSA signature.

Signature

Parameters

  • signature - ECDSA BrandedSignature

Returns

Uint8Array (32 bytes) - s component

Throws

  • Error if signature is Ed25519 (no s component)

Example

getV

Get recovery ID from secp256k1 signature.

Signature

Parameters

  • signature - BrandedSignature

Returns

  • number (27 or 28) - Recovery ID if present
  • undefined - If not secp256k1 or v not set

Example

Use Cases

Comparison

equals

Compare signatures for equality.

Signature

Parameters

  • a - First signature
  • b - Second signature

Returns

true if signatures are equal (algorithm, bytes, and v match)

Example

Implementation

Checks:
  1. Algorithm match
  2. Byte-by-byte comparison
  3. Recovery ID match (if present)

is

Type guard for BrandedSignature.

Signature

Parameters

  • value - Value to check

Returns

true if value is BrandedSignature

Example

Checks

  1. Is object
  2. Is Uint8Array instance
  3. Has [brand] === "Signature"
  4. Has algorithm property

Verification (Placeholder)

verify

Verify signature against message and public key.

Signature

Parameters

  • signature - Signature to verify
  • message - Message that was signed
  • publicKey - Public key to verify against

Returns

true if signature is valid

Throws

  • InvalidAlgorithmError - Always (placeholder implementation)

Example

Note

This is a placeholder. Actual verification requires crypto module integration:

Helper Functions

Component Comparison

Algorithm Detection

Component Extraction Helpers

Display Helpers

Validation Helpers

Performance Considerations

Component Access

Equality Comparison

Type Checking

Common Patterns

Decompose Signature

Clone Signature

Signature Info

See Also