C# Class Nethereum.ABI.Util.RLP.RLP

Recursive Length Prefix (RLP) encoding.

The purpose of RLP is to encode arbitrarily nested arrays of binary data, and RLP is the main encoding method used to serialize objects in Ethereum. The only purpose of RLP is to encode structure; encoding specific atomic data types (eg. strings, integers, floats) is left up to higher-order protocols; in Ethereum the standard is that integers are represented in big endian binary form. If one wishes to use RLP to encode a dictionary, the two suggested canonical forms are to either use [[k1,v1],[k2,v2]...] with keys in lexicographic order or to use the higher-level Patricia Tree encoding as Ethereum does.

The RLP encoding function takes in an item. An item is defined as follows:

- A string (ie. byte array) is an item - A list of items is an item

For example, an empty string is an item, as is the string containing the word "cat", a list containing any number of strings, as well as more complex data structures like ["cat",["puppy","cow"],"horse",[[]],"pig",[""],"sheep"]. Note that in the context of the rest of this article, "string" will be used as a synonym for "a certain number of bytes of binary data"; no special encodings are used and no knowledge about the content of the strings is implied.

See:

https://github.com/ethereum/wiki/wiki/RLP
Datei anzeigen Open project: Nethereum/Nethereum

Public Properties

Property Type Description
EMPTY_BYTE_ARRAY byte[]
ZERO_BYTE_ARRAY byte[]

Public Methods

Method Description
ByteArrayToInt ( byte bytes ) : int
Decode ( byte msgData ) : RLPCollection

Parses byte[] message into RLP items

Decode ( byte msgData, int level, int startPosition, int endPosition, int levelToIndex, RLPCollection rlpCollection ) : void

Decodes a message from a starting point to an end point

DecodeFirstElement ( byte msgData, int startPos ) : IRLPElement
EncodeByte ( byte singleByte ) : byte[]
EncodeElement ( byte srcData ) : byte[]
EncodeList ( ) : byte[]
IsNullOrZeroArray ( byte array ) : bool
IsSingleZero ( byte array ) : bool

Private Methods

Method Description
CalculateLength ( int lengthOfLength, byte msgData, int pos ) : int

Method Details

ByteArrayToInt() public static method

public static ByteArrayToInt ( byte bytes ) : int
bytes byte
return int

Decode() public static method

Parses byte[] message into RLP items
public static Decode ( byte msgData ) : RLPCollection
msgData byte raw RLP data
return RLPCollection

Decode() public static method

Decodes a message from a starting point to an end point
public static Decode ( byte msgData, int level, int startPosition, int endPosition, int levelToIndex, RLPCollection rlpCollection ) : void
msgData byte
level int
startPosition int
endPosition int
levelToIndex int
rlpCollection RLPCollection
return void

DecodeFirstElement() public static method

public static DecodeFirstElement ( byte msgData, int startPos ) : IRLPElement
msgData byte
startPos int
return IRLPElement

EncodeByte() public static method

public static EncodeByte ( byte singleByte ) : byte[]
singleByte byte
return byte[]

EncodeElement() public static method

public static EncodeElement ( byte srcData ) : byte[]
srcData byte
return byte[]

EncodeList() public static method

public static EncodeList ( ) : byte[]
return byte[]

IsNullOrZeroArray() public static method

public static IsNullOrZeroArray ( byte array ) : bool
array byte
return bool

IsSingleZero() public static method

public static IsSingleZero ( byte array ) : bool
array byte
return bool

Property Details

EMPTY_BYTE_ARRAY public_oe static_oe property

public static byte[] EMPTY_BYTE_ARRAY
return byte[]

ZERO_BYTE_ARRAY public_oe static_oe property

public static byte[] ZERO_BYTE_ARRAY
return byte[]