Skip to content

Use Buffer.from for NodeJS fromHexString #283

@dapplion

Description

@dapplion

@nflaig noted that SSZ uses a browser compatible but slow implementation for fromHexString

for (let i = 0; i < byteLen; i++) {
const byte = parseInt(hex.slice(i * 2, (i + 1) * 2), 16);
bytes[i] = byte;
}

We may use platform specific exports to get around it or have some logic to pick between implementations depending on platform.

Important to note that many consumers of SSZ assume everything is a Uint8Array. Buffer.slice() has different behaviour than Uint8Array.slice, so we must audit all downstream code to prevent surprises.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions