Optional
encoders: Map<string, EncodeFunc>Optional
defaultEncoder: EncodeFuncEncode a message with given name and value. Will throw an error if no appropriate encoder found.
If set to false and no appropriate encoder is found but the value is a bytearray, it will encode it using the built-in mechanism
Encode a message with given name and value. Will throw an error if no appropriate encoder found.
If set to false and no appropriate encoder is found but the value is a bytearray, it will encode it using the built-in mechanism
Encode messages given as JS object. It flattens the object into a sorted list and encodes each value as per the known encoding functions. Returns 2 arrays, 1st with message names and 2nd with encoded values.
If set to false and no appropriate encoder is found but the value is a bytearray, it will encode it using the built-in mechanism
Encode messages given as JS object. It flattens the object into a sorted list and encodes each value as per the known encoding functions. Returns a Map with names as keys and encoded messages as values.
If set to false and no appropriate encoder is found but the value is a bytearray, it will encode it using the built-in mechanism
Encode messages given as JS object. It flattens the object into a sorted list and encodes each value as per the known encoding functions. Returns a Map with names as keys and encoded messages as values.
If set to false and no appropriate encoder is found but the value is a bytearray, it will encode it using the built-in mechanism
Encode messages given as JS object. It flattens the object into a sorted list and encodes each value as per the known encoding functions. Returns an object with names as keys and encoded messages as values.
If set to false and no appropriate encoder is found but the value is a bytearray, it will encode it using the built-in mechanism
Encode messages given as JS object. It flattens the object into a sorted list and encodes each value as per the known encoding functions. Returns an object with names as keys and encoded messages as values.
If set to false and no appropriate encoder is found but the value is a bytearray, it will encode it using the built-in mechanism
Encode messages given as JS object. It flattens the object into a sorted list and encodes each value as per the known encoding functions. Returns 2 arrays, 1st with message names and 2nd with encoded values.
If set to false and no appropriate encoder is found but the value is a bytearray, it will encode it using the built-in mechanism
Static
booleanReturns an encoding function to be used on a message that is a boolean, encoded as positive int (0 or 1)
Static
dateReturns an encoding function to be used on a message that is a date
Static
decimalReturns an encoding function to be used on a message that can be a positive, negative or decimal number, eg. -2.35
The minimum negative value that the message can take
The maximum decimal places
Static
decimalReturns a function that can convert any number to a positive integer when its minimum negative value and maximum decimal places are known. Does that by adding an offset of abs(minimum) and then multiplying it by 10^max_decimal_places
Static
defaultReturns an encoding function to convert utf-8 string message. It might fail if the encoding target cannot be made a string
Static
defaultReturns an encoding function to convert utf-8 string message. It might fail if the encoding target cannot be made a string
Static
integerReturns an encoding function to be used on a message that can be a positive or negative integer.
The minimum negative value that the message can take
Static
integerReturns a function that can convert any input integer to a positive integer when its minimum negative value is known. Does that by adding an offset of abs(minimum) to the input
Static
positiveReturns an encoding function to be used on a message that can be a positive decimal number, eg. 2.7
The maximum decimal places
Static
positiveReturns a function that can convert any positive number to a positive integer when its maximum decimal places are known. Does that by multiplying it by 10^max_decimal_places, eg. 23.452 -> 23452
Static
positiveReturns an encoding function to be used on a message that is a positive integer.
Static
reversibleReturns a reversible encoding function to be used on a string message. The output can of the EncodeFunc
can be
reversed.
Encodes the input to a field element for signing. Used when working with messages that are specified as JS objects. This encoder object will contain the mapping from message name (key in JS object) to an encoding function.
TODO: Support identity encoder for values that are already field elements.