module Rlp
Overview
The Rlp
module implementing Ethereum's Recursive Length Prefix
for arbitrary data encoding and decoding.
Defined in:
rlp.crutil.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
-
.decode(rlp : Bytes)
decodes arbitrary data from a recursive length prefix blob.
-
.decode(hex : String)
decodes rlp data from hex-encoded strings
-
.encode(b : Bytes)
rlp-encodes binary data
-
.encode(l : Array)
rlp-encodes lists data
-
.encode(s : String)
rlp-encodes string data
-
.encode(i : Int)
rlp-encodes scalar data
-
.encode(c : Char)
rlp-encodes characters
-
.encode(o : Bool)
rlp-encodes boolean data
Class Method Detail
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.