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.1"

The version of the Rlp module shard.

Class Method Summary

Class Method Detail

def self.decode(rlp : Bytes) #

decodes arbitrary data from a recursive length prefix blob. note, that the returned data only restores the data structure. it's up to the protocol to determine the meaning of the data as defined in ethereum's design rationale.


[View source]
def self.decode(hex : String) #

decodes rlp data from hex-encoded strings


[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]