Skip to main content

Try it Live

Run Bytes examples in the interactive playground
Extended Size Type - Bytes64 provides type-safe handling of 512-bit values, commonly used for concatenated hashes and extended data structures.

Overview

Bytes64 is a branded Uint8Array type representing exactly 64 bytes (512 bits). It provides strict size validation and type safety for large fixed-size byte values.

Use Cases

Concatenated Hashes (2x32 bytes)
Extended Hashes
Public Key Material
Signature Components

Type Safety

Bytes64 uses Symbol branding for compile-time safety:
This prevents mixing different byte types:

Hex Variants

Bytes64 also supports hex string variants with case flags:
For generic byte concepts, see Bytes.

Constructors

from

Create Bytes64 from hex string or bytes:

fromHex

Create from hex string with strict validation:

fromBytes

Create from Uint8Array with size check:

zero

Create zero-filled Bytes64:

Conversions

toHex

Convert to hex string:

toUint8Array

Convert to raw bytes:

Operations

equals

Check equality:

compare

Compare two values:

clone

Create independent copy:

isZero

Check if all zeros:

size

Get size (always 64):

Constants

SIZE

Bytes64 size in bytes:

ZERO

Zero-filled constant:

Error Handling

Bytes64 validates size strictly:

Working with Hash Pairs

Common pattern: concatenate two 32-byte hashes:

Extended Hash Functions

Some hash functions output 64 bytes:
  • Bytes32 - 256-bit fixed-size bytes (most common)
  • Bytes16 - 128-bit fixed-size bytes
  • Keccak256 - 256-bit cryptographic hashes
  • Hex - Variable-length hex strings