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
Afficher le fichier Open project: Nethereum/Nethereum

Méthodes publiques

Свойство Type Description
EMPTY_BYTE_ARRAY byte[]
ZERO_BYTE_ARRAY byte[]

Méthodes publiques

Méthode 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

Méthode Description
CalculateLength ( int lengthOfLength, byte msgData, int pos ) : int

Method Details

ByteArrayToInt() public static méthode

public static ByteArrayToInt ( byte bytes ) : int
bytes byte
Résultat int

Decode() public static méthode

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

Decode() public static méthode

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
Résultat void

DecodeFirstElement() public static méthode

public static DecodeFirstElement ( byte msgData, int startPos ) : IRLPElement
msgData byte
startPos int
Résultat IRLPElement

EncodeByte() public static méthode

public static EncodeByte ( byte singleByte ) : byte[]
singleByte byte
Résultat byte[]

EncodeElement() public static méthode

public static EncodeElement ( byte srcData ) : byte[]
srcData byte
Résultat byte[]

EncodeList() public static méthode

public static EncodeList ( ) : byte[]
Résultat byte[]

IsNullOrZeroArray() public static méthode

public static IsNullOrZeroArray ( byte array ) : bool
array byte
Résultat bool

IsSingleZero() public static méthode

public static IsSingleZero ( byte array ) : bool
array byte
Résultat bool

Property Details

EMPTY_BYTE_ARRAY public_oe static_oe property

public static byte[] EMPTY_BYTE_ARRAY
Résultat byte[]

ZERO_BYTE_ARRAY public_oe static_oe property

public static byte[] ZERO_BYTE_ARRAY
Résultat byte[]