Skip to content
iammrjudePublic

About

Minimal Recursive Length Prefix (RLP) encoding/decoding library

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

rlp-rs

A minimal, dependency-free implementation of Recursive-Length Prefix (RLP) encoding and decoding in Rust.

✨ Features

  • ✅ Encode:

    • Empty string ("")
    • Boolean false (encoded as empty)
    • Empty list ([])
    • Single byte (0x00–0x7f)
    • Short strings (≤ 55 bytes)
    • Long strings (≥ 56 bytes)
  • ✅ Decode:

    • Single byte
    • Short strings
    • Long strings
  • 🚫 List decoding (not implemented by design)

📦 Installation

Clone the repository:

git clone https://github.com/iammrjude/rlp-rs.git
cd rlp-rs

🚀 Usage

use rlp_rs::{Rlp, encode, decode};

fn main() {
    let data = Rlp::Bytes(b"dog".to_vec());

    let encoded = encode(&data);
    assert_eq!(encoded, vec![0x83, b'd', b'o', b'g']);

    let (decoded, _) = decode(&encoded).unwrap();
    assert_eq!(decoded, data);
}

🧠 What is RLP?

Recursive Length Prefix (RLP) is a serialization method used in systems like Ethereum to encode arbitrarily nested arrays of binary data.

🧪 Running Tests

cargo test

⚠️ Limitations

  • List decoding is not implemented
  • No support for integers or higher-level types
  • Focused on correctness and minimalism

📁 Project Structure

rlp-rs/
├── Cargo.toml
├── src/
│   └── lib.rs
└── tests/
    └── tests.rs

🛠 Future Improvements

  • List decoding
  • Zero-copy decoding
  • no_std support
  • Ethereum compatibility

About

Minimal Recursive Length Prefix (RLP) encoding/decoding library

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages