INTRODUCTION
Nano is a low-latency payment platform that requires minimal resources, relying on a peer-to-peer network to distribute "blocks", which are cryptographically signed transactions. This package provides bindings for interacting with the Nano network from
Tcl.
Nano uses Ed25519 with Blake2b as the cryptographic hashing primitive for digital signatures, rather than the common construction of Ed25519 with the SHA2-512 cryptographic hashing function.
Nano implements a "blockchain", which is a cryptographic linked-list, by identifying every "block" by its cryptographic hash and providing a pointer from every block to its predecessor in the "chain" as part of the hashed data.
This predecessors is referred to here as the "previous" block. In Nano, each account has its own blockchain and they reference each other using a data structure referred to as "block lattice", where the individual chains contain blocks that reference blocks in other chains to tie them together. The field within blocks that reference other blocks on a different blockchain is referred to as either the "link" field or "source block hash".
Each Nano block also encapsulates the full state of the account, containing, at a minimum, a tuple of (
account,
balance,
representative,
previous).
Since Nano blocks are signed by independent actors, who may, for their own gain, generate multiple valid blocks referring to the same predecessor (
previous) block, an arbitration mechanism is employed by the Nano network to decide which blocks are valid within a given chain. This arbitration mechanism operates on the principles of consensus. Each account holder has a stake in the network operating nominally, otherwise the balance represented by an account is not useful for a transfer of value. In Nano the stake an account has in the network is equal to the account's balance. The larger the stake an account has the more incentivized the account-holder is to ensure the network is operating nominally and not accepting multiple blocks that reference the same predecessor.
Nano utilizes a mechanism called
voting to determine which blocks are valid and which blocks are not valid. Each stakeholder votes their stake upon seeing a new subordinate block (
i.e., a block with a unique
previous value). Since voting is an active and on-going process that occurs on the Nano peer-to-peer network, participants must be online to vote their stake. As this is often inconvenient or impossible, stakeholders may select another stakeholder to vote their share of the network. This delegate is referred to as a
representative.
Representatives should be chosen carefully by stakeholders since malicious representatives may attempt to gather voting power and destabilize the Nano network by altering decisions made by consensus previously.
Nano accounts are referred to by address. A Nano address starts with the prefix "
nano_" or "
xrb_". A Nano address is actually the public portion of a private/public keypair, plus the prefix, and a checksum to ensure that no digits are mistyped by users when communicating them. Nano public keys are 256-bit keys in the Ed25519 algorithm.
A user may have many accounts. To simplify the process of maintaining the private/public keypairs for all the accounts, Nano supports the concept of a
wallet. A
wallet is a conceptual entity that is used to refer to a
seed, which is a random 256-bit number that can be used to derive multiple private/public keypairs from.
Balances in Nano are stored in a 128-bit integer value. There are various units for representing the balance, the smallest and base unit is called "
raw". The most common unit for users to use is called "
Nano", one of which is equal to 1e30 raw.
Addresses
Nano addresses are composed of a prefix (either "
nano_" or "
xrb_") and 300 bits of base32 encoded data. The 300-bits of base32 encoded data produce a string that is 6 characters long using the base32 alphabet
13456789abcdefghijkmnopqrstuwxyz. The format of these 300 bits are
struct {
uint4_t padding = 0000b;
uint256_t publicKey;
uint40_t checksum;
}
The checksum is computed as a 5 byte (40 bit) Blake2b hash of the 256-bit public key (in binary format), followed by reversing the bytes.
For example the public key
DC1512154EB72112B8CC230D7B8C7DD467DA78E4763182D6CAFAADB14855A5E8 which has a 5-byte Blake2b hash of
{0x18, 0x74, 0xA3, 0x46, 0x9C} would be encoded as
0000.DC1512154EB72112B8CC230D7B8C7DD467DA78E4763182D6CAFAADB14855A5E8.9C46A37418 which when encoded in base32 and the prefix added produces the address
nano_3q1o4acnxfs34cwerarfhg89uo59ubwgaxjjiddeoyofp767dbhamj5c8x1r.
Network
The Nano network consists of two different peer-to-peer networks. One for real-time block updates over UDP, and another for bulk ledger updates over TCP (
bootstrapping). The real-time network is a broadcast style network where every message sent over it are relayed to all other nodes.
The customary and default port for the real-time/UDP network is 7075/udp, while the default port for the bootstrapping/TCP network is 7075/tcp.
The format of the messages on both networks is the same, however not every type of message may be used on either network. The
keepalive message type is invalid on the TCP (bootstrapping) network and the
bulk_pull message type is invalid on the UDP (real-time) network. The format of message are an 8 byte header consisting of:
struct {
uint8_t magicProtocol = 0x52;
uint8_t magicNetwork = 0x41/0x42/0x43;
uint8_t versionMax;
uint8_t version;
uint8_t versionMin;
uint8_t messageType;
uint16_t extensions;
};
Where the
magicProtocol field must be the value
0x52 (which is ASCII 'R') and the
magicNetwork field must be one of
0x41,
0x42, or
0x43 corresponding to one of the three Nano networks. A value of
0x41 (ASCII 'A') represents the Test network; A value of
0x42 (ASCII 'B') represents the Beta network; A value of
0x43 (ASCII 'C') represents the Main network.
The various version fields control the relaying of the message to nodes running various versions of the Nano network protocol (distinct from the Nano reference implementation version). The
versionMax and
versionMin fields indicate the inclusive range of acceptable versions to relay or broadcast this message to. The
version field indicates what version of the Nano protocol this node is using.
The messageType field indicates what type of message is being relayed, and must conform to the following enumeration
messageType |
Name |
On Bootstrap |
On Realtime |
0x00 |
Invalid |
Yes |
Yes |
0x01 |
Not_A_Type |
? |
? |
0x02 |
Keepalive |
No |
Yes |
0x03 |
Publish |
No |
Yes |
0x04 |
Confirm_Req |
No |
Yes |
0x05 |
Confirm_Ack |
No |
Yes |
0x06 |
Bulk_Pull |
Yes |
No |
0x07 |
Bulk_Push |
Yes |
No |
0x08 |
Frontier_Req |
Yes |
No |
0x09 |
Bulk_Pull_Blocks |
Yes |
No |
TODO: Extensions
Following the message header comes the payload for the particular message type.
-
Invalid
-
TODOC
-
Not_A_Type
-
TODOC
-
Keepalive
-
The Keepalive message requires exactly 8 IPv6 address and port number tuples to be sent as its payload. The IPv6 addresses are each 128-bits (16-bytes) long and the port numbers are 16-bit integers sent in network byte order. The payload for the Keepalive message type is 144 bytes in size.
-
Publish
-
TODOC
-
Confirm_Req
-
TODOC
-
Confirm_Ack
-
TODOC
-
Bulk_Pull
-
TODOC
-
Bulk_Push
-
TODOC
-
Frontier_Req
-
TODOC
-
Bulk_Pull_Blocks
-
TODOC