nada 0.1.0

Compression-focused encoding for zero-heavy solidity calldata and bytecode
Documentation
  • Coverage
  • 0%
    0 out of 5 items documented0 out of 3 items with examples
  • Size
  • Source code size: 18.82 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 393.51 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 6s Average build duration of successful builds.
  • all releases: 9s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • bestinslot-xyz/nada-rs
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • alpergundogdu github:bestinslot-xyz:team

nada

nada

Compression-focused encoding for zero-heavy Solidity calldata and bytecode.

nada provides an efficient way to encode and decode byte arrays where runs of 0x00 are replaced with a compact marker (0xFF) followed by the length of the run. This is particularly useful for reducing the size of calldata and bytecode in environments like Ethereum.

How it Works

  • 0xFF 0x00 encodes a literal 0xFF
  • 0xFF N (1 ≤ N ≤ 255) encodes N zero bytes
  • All other bytes are passed through unchanged

This encoding helps reduce the size of sequences with a high proportion of zero bytes, which are common in Solidity calldata and bytecode.

Example

Input Encoded
[0x01, 0x00, 0x00, 0xFF] [0x01, 0xFF, 0x02, 0xFF, 0x00]

Installation

To add nada to your project, use

> cargo add nada

Usage

Here is a simple example of how to use the encode and decode functions:

use nada;

let data = vec![0x01, 0x00, 0x00, 0xFF];
let encoded = nada::encode(&data);
let decoded = nada::decode(&encoded);

assert_eq!(decoded, Ok(data));

decode returns a DecodeError if the input ends unexpectedly, such as when a 0xFF marker is found without a following run length byte, indicating incomplete or malformed encoded data.

License

Apache License, Version 2.0