Nyzo techRelease notesNyzo 524: additional Nyzo strings

Nyzo 524: additional Nyzo strings

Nyzo version 524 (commit on GitHub) adds Nyzo string objects for private seeds, public identifiers, and Nyzo Micropay transactions.

This version does not meaningfully affect the behavior of the verifier, sentinel, or client. It only provides basic functionality that will be used by later versions of Nyzo.

Nyzo strings are typed, error-protected encodings of data used by Nyzo. All Nyzo strings use the same basic format: a 3-byte type, a 1-byte length specifier, a data array (the actual object), and a 4- to 6-byte checksum. The encoding stores 6 bits per character, so each set of 3 bytes is encoded by 4 characters. The checksum is of variable length to ensure that the number of bytes encoded is always divisible by 3.

In FieldByteSize, a constant has been added for the maximum byte length of transaction sender data. This improves the readability of some code in the NyzoStringMicropay class.

RN_524 code 0

In Verifier, an unnecessary null check was removed. This does not change the behavior of the code, as Files.readAllLines() never returns null.

RN_524 code 1

Each time the verifier starts, the private seed is loaded. A new file, verifier_info, is now written with Nyzo strings for the private seed ("key" prefix) and public identifier ("id" prefix). This file is written every time the verifier is started to ensure that it remains consistent with the contents of the verifier_private_seed file.

RN_524 code 2

A new package, co.nyzo.verifier.nyzoString, has been added to contain the Nyzo string code. A new interface, NyzoString, is implemented by all objects that encode to Nyzo strings.

RN_524 code 3

The NyzoStringEncoder class provides encoding and decoding of Nyzo strings. Objects that implement the NyzoString interface provide the bytes for the prefix and the data. The encoder assembles an array of the prefix bytes, a length byte to indicate the length of the data array, and the actual data array. It then computes and attaches a checksum to the end of the array. The final Nyzo string is a 3-byte-to-4-character encoding of the assembled byte array. The character table, which encodes 6 bits per character, uses the Arabic numerals, most letters of the English alphabet in both uppercase and lowercase, and a few symbols to bring the table size to 64 characters.

RN_524 code 4

The NyzoStringMicropay class bundles a receiver identifier, sender data, and transaction amount into a single Nyzo string. It also includes a receiver IP address to tell a client where to forward the signed transaction. This string type will be used in an upcoming Nyzo micropayments system.

RN_524 code 5

The NyzoStringPrivateSeed class stores a seed for a private key. This type of string will replace private-key image files moving forward, and a tool will be provided for converting Nyzo image files to Nyzo strings.

RN_524 code 6

The NyzoStringPublicIdentifier class stores a public identifier. This type of string will replace public-identifier image files moving forward.

RN_524 code 7

The NyzoStringType enumeration provides structure to the prefixes that denote types for Nyzo strings. The character prefix of each string is actually the encoded representation of a 3-byte prefix, and all characters used in a prefix must be in the character-lookup table of the Nyzo string encoder. For improved readability, the encoded (human-readable) prefix is written into the code, and it is decoded and used for building strings of that type.

RN_524 code 8

A test class was added for generating 100,000 of each type of NyzoString, encoding those objects, decoding those objects, and comparing them to the generated objects.

RN_524 code 9

To run this test, run the following command from the nyzoVerifier directory:

java -jar build/libs/nyzoVerifier-1.0.jar co.nyzo.verifier.tests.NyzoStringTest

The tests also allow ANSI console colors. To activate console colors, place the line enable_console_color=1 in /var/lib/nyzo/production/preferences.

The NyzoTest interface provides a method for running tests. The return value indicates success or failure. In the event of failure of a test, the getFailureCause() method provides an explanation of the failure.

RN_524 code 10

The TestUtil class provides some methods to format test output, and it also runs all available tests.

RN_524 code 11

To run all tests, run the following command from the nyzoVerifier directory:

java -jar build/libs/nyzoVerifier-1.0.jar co.nyzo.verifier.tests.TestUtil