module Rlp

Overview

The Rlp module implementing Ethereum's Recursive Length Prefix for arbitrary data encoding and decoding.

Defined in:

rlp.cr
util.cr
version.cr

Constant Summary

EMPTY_ARRAY = Bytes[OFFSET_ARRAY]

An empty array is defined as 0xC0.

EMPTY_STRING = Bytes[OFFSET_STRING]

An empty string is defined as 0x80.

LIMIT_LONG = (BigInt.new(256)) ** (BigInt.new(8))

The size limit of large data objects to be encoded is 256 ** 8.

LIMIT_SHORT = 56

The size limit of small data objects to be encoded is 56.

OFFSET_ARRAY = 192

The offset for array list encoding is 192.

OFFSET_STRING = 128

The offset for string literal encoding is 128.

VERSION = "0.1.0"

The version of the Rlp module shard.

Class Method Summary

Class Method Detail

def self.decode(blob) #

decodes arbitrary data from a recursive length prefix blob


[View source]
def self.encode(b : Bytes) #

rlp-encodes binary data


[View source]
def self.encode(l : Array) #

rlp-encodes lists data


[View source]
def self.encode(s : String) #

rlp-encodes string data


[View source]
def self.encode(i : Int) #

rlp-encodes scalar data


[View source]
def self.encode(c : Char) #

rlp-encodes characters


[View source]
def self.encode(o : Bool) #

rlp-encodes boolean data


[View source]
def self.get_length(data : Bytes) #

gets the length of the input data using the first byte


[View source]