Skip to content

Add bytes to Base64 encoding in VM #6744

@ernestognw

Description

@ernestognw

Component

Forge

Describe the feature you would like

Motivation

Base64 encoding has become relevant in Solidity development for reasons like on-chain metadata (NFTs), and seems there's an upcoming demand for Base64-URL encoding driven by passkey-based authentication (relying on WebAuthn).

As of OZ Contracts, we're working on a Base64URL implementation and we'd love to fuzz the implementation. It'd be great if the Vm.sol had a set of functions for Base64 encoding.

Proposal

Consider adding the following function signatures to Vm.sol:

// crates/cheatcodes/spec/src/vm.rs
// ======== Utilities ========

...

// -------- Base64 --------
#[cheatcode(group = Base64)]
function toBase64(bytes calldata data) external pure returns (string memory);
#[cheatcode(group = Base64)]
function toBase64(string calldata data) external pure returns (string memory);
#[cheatcode(group = Base64)]
function toBase64URL(bytes calldata data) external pure returns (string memory);
#[cheatcode(group = Base64)]
function toBase64URL(string calldata data) external pure returns (string memory);

Such functions can be implemented using this Base64 create, which would provide a reference implementation to fuzz the Solidity version against.

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    D-easyDifficulty: easyT-featureType: featurefirst issueA good way to start contributing

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions