Namespace: util

verificatum.util

Utility classes and functions.
Source:

Methods

(static) asciiToByteArray(ascii)

Converts an ASCII string to a byte array.
Parameters:
Name Type Description
ascii ASCII string.
Source:
Returns:
Corresponding byte array.

(static) byteArrayToAscii(bytes)

Converts byte array to ASCII string.
Parameters:
Name Type Description
bytes Input bytes.
Source:
Returns:
ASCII string corresponding to the input.

(static) byteArrayToHex(array)

Converts a byte array to its hexadecimal encoding.
Parameters:
Name Type Description
array Input byte array.
Source:
Returns:
Hexadecimal representation of this array.

(static) change_wordsize(words, orig_wordsize, new_wordsize)

Changes the wordsize of an array of words.
Parameters:
Name Type Description
words Array of words.
orig_wordsize Original bitsize of words (at most 32).
new_wordsize Bitsize of output words (at most 32).
Source:
Returns:
Representation of the input array of bits with new wordsize.

(static) equalsArray(x, y)

Returns true or false depending on if the two input arrays hold identical elements or not.
Parameters:
Name Type Description
x Array of elements.
y Array of elements.
Source:
Returns:
Value of boolean equality predicate for arrays.

(static) full(value, width)

Creates a list filled with the same value or the value itself if a single repetition is requested.
Parameters:
Name Type Description
value Value to be repeated.
width Number of repetitions.
Source:
Returns:
List containing the value or the value itself if width == 1.

(static) full(value, width)

Creates a list filled with the same value.
Parameters:
Name Type Description
value Value to be repeated.
width Number of repetitions.
Source:
Returns:
List containing the value.

(static) hexToByteArray(hex)

Converts a hexadecimal encoding of a byte array to the byte array.
Parameters:
Name Type Description
hex Hexadecimal encoding of byte array.
Source:
Returns:
Byte array corresponding to the input.

(static) ofType(obj, type)

Tests if an object is of a given type.

ASSUMPTIONS: type is a string literal and not an instance of String.

Parameters:
Name Type Description
obj Object to determine type of. (Here we can use either a string literal or a String instance if obj is a string to patch the intellectually challenged way JavaScript handles these.)
type Type of object.
Source:
Returns:
True or false depending on if the object is of the given type or not.

(static) randomArray(len, wordsize, randomSource)

Generates random array of the given length and wordsize.
Parameters:
Name Type Description
len Number of nominal bits in random output.
wordsize Number of bits in each word.
randomSource Source of randomness.
Source:
Returns:
Array of randomly generated words.

(static) readUint16FromByteArray(bytes, index)

Reads a 16-bit integer in little-endian byte order from the given byte array.
Parameters:
Name Type Description
bytes Source of bytes.
index Offset for reading.
Source:

(static) readUint32FromByteArray(bytes, index)

Reads a 32-bit integer in little-endian byte order from the given byte array.
Parameters:
Name Type Description
bytes Source of bytes.
index Offset for reading.
Source:

(static) setUint16ToByteArray(destination, value, index)

Writes a 16-bit integer in little-endian byte order.
Parameters:
Name Type Description
destination Destination of result.
value Value to write.
index Offset for writing.
Source:

(static) setUint32ToByteArray(destination, value, index)

Writes a 32-bit integer in little-endian byte order.
Parameters:
Name Type Description
destination Destination of result.
value Value to write.
index Offset for writing.
Source:

(static) time()

Returns the epoch in seconds.
Source:
Returns:
Epoch in seconds.

(static) time_ms()

Returns the epoch in milliseconds.
Source:
Returns:
Epoch in milliseconds.