Graft (GRFT) Algorithm

Graft algorithm is our newest subject to talk about today. We did not want to give you the Wikipedia informations. In this article you will see all technical details about Graft algorithm and how it works. If you want to enter in this area we warn you. Do not start to spend money before be a master of Graft job, so you should read very much really. Then let’s wrap it up and take a look below how this technology works:

Needed informations about the Graft algorithm:

Graft’s CryptoNight is a proof-of-work algorithm. It is designed to be suitable for ordinary PC CPUs, but currently no special purpose devices for mining are available. Therefore, CryptoNight can only be CPU-mined for the time being. CryptoNight was originally implemented in the CryptoNote codebase.

CryptoNight relies on random access to the slow memory and emphasizes latency dependence. Each new block depends on all the previous blocks (unlike, for example, scrypt). The algorithm requires about 2 Mb per instance:

  1. It fits in the L3 cache (per core) of modern processors.
  2. A megabyte of internal memory is almost unacceptable for the modern ASICs.
  3. GPUs may run hundreds of concurrent instances, but they are limited in other ways. GDDR5 memory is slower than the CPU L3 cache and remarkable for its bandwidth, not random access speed.
  4. Significant expansion of the scratchpad would require an increase in iterations, which in turn implies an overall time increase. “Heavy” calls in a trustless p2p network may lead to serious vulnerabilities, because nodes are obliged to check every new block’s proof-of-work. If a node spends a considerable amount of time on each hash evaluation, it can be easily DDoSed by a flood of fake objects with arbitrary work data (nonce values).

Well then, what Graft org says for us, let’s check it out together below:

Graft (GRFT) is a new cryptocurrency which is based on CryptoNote code and is not a Bitcoin fork in any way.

Main Graft features that were inherited from CryptoNote are Ring Signatures and unlinkable transactions.

Usually Graft software consists of two binaries: graftnoded & simplewallet.

In the sections below you will be able to find binaries for a majority of operating systems, but please take a note that 32bit version of Windows is not supported.

Another thing worth mentioning is Graft blockchain.

On the first install you would probably want to shorten the time of wait and download Graft blockchain directly from the website and not from the network.

Please keep in mind that Linux & Windows blockchains are not compatible.

Click this for the download the program links: https://www.graft.network

Graft Mining Pool: Graft Pool

How Graft Algorithm Works?

We present you about technical details of CryptoNight Hash Function based CryptoNote technology. You can clearly see the all details of Graft algorithm, CryptoNight.

CryptoNight Hash Function  Abstract    This document is part of the CryptoNote Standards describing a peer-   to-peer anonymous payment system. It defines the CryptoNote’s default   proof-of-work hash function, CryptoNight.  Copyright and License Notice    Copyright (c) 2013 CryptoNote. This document is available under the   Creative Commons Attribution 3.0 License (international). To view a   copy of the license visit http://creativecommons.org/licenses/by/3.0/  Table of Contents    1. Introduction  . . . . . . . . . . . . . . . . . . . . . . . . .  2   2. Definitions . . . . . . . . . . . . . . . . . . . . . . . . . .  2   3. Scratchpad Initialization . . . . . . . . . . . . . . . . . . .  2   4. Memory-Hard Loop  . . . . . . . . . . . . . . . . . . . . . . .  4   5. Result Calculation  . . . . . . . . . . . . . . . . . . . . . .  6   6. References  . . . . . . . . . . . . . . . . . . . . . . . . . .  8                           CryptoNight Hash Function                [Page 1] CRYPTONOTE STANDARD 008                                        1. Introduction    CryptoNight is a memory-hard hash function. It is designed to be   inefficiently computable on GPU, FPGA and ASIC architectures. The   CryptoNight algorithm’s first step is initializing large scratchpad   with pseudo-random data. The next step is numerous read/write   operations at pseudo-random addresses contained in the scratchpad.   The final step is hashing the entire scratchpad to produce the   resulting value.  2. Definitions    hash function: an efficiently computable function which maps data of   arbitrary size to data of fixed size and behaves similarly to a   random function    scratchpad: a large area of memory used to store intermediate values   during the evaluation of a memory-hard function  3. Scratchpad Initialization    First, the input is hashed using Keccak [KECCAK] with parameters b =   1600 and c = 512. The bytes 0..31 of the Keccak final state are   interpreted as an AES-256 key [AES] and expanded to 10 round keys. A   scratchpad of 2097152 bytes (2 MiB) is allocated. The bytes 64..191   are extracted from the Keccak final state and split into 8 blocks of   16 bytes each. Each block is encrypted using the following procedure:       for i = 0..9 do:          block = aes_round(block, round_keys[i])    Where aes_round function performs a round of AES encryption, which   means that SubBytes, ShiftRows and MixColumns steps are performed on   the block, and the result is XORed with the round key. Note that   unlike in the AES encryption algorithm, the first and the last rounds   are not special. The resulting blocks are written into the first 128   bytes of the scratchpad. Then, these blocks are encrypted again in   the same way, and the result is written into the second 128 bytes of   the scratchpad. Each time 128 bytes are written, they represent the   result of the encryption of the previously written 128 bytes. The   process is repeated until the scratchpad is fully initialized.    This diagram illustrates scratchpad initialization:

 

CryptoNight Hash Function                [Page 2] CRYPTONOTE STANDARD 008                                                                        +—–+                               |Input|                               +—–+                                  |                                  V                             +——–+                             | Keccak |                             +——–+                                  |                                  V   +————————————————————-+   |                         Final state                         |   +————-+————–+—————+—————-+   | Bytes 0..31 | Bytes 32..63 | Bytes 64..191 | Bytes 192..199 |   +————-+————–+—————+—————-+          |                             |          V                             |   +————-+                      V   | Round key 0 |————+—+->+—–+   +————-+            |   |  |     |   |      .      |            |   |  |     |   |      .      |            |   |  | AES |   |      .      |            |   |  |     |   +————-+            |   |  |     |   | Round key 9 |———-+-|-+-|->+—–+                 +—+   +————-+          | | | |     |                    |   |                            | | | |     +——————->|   |                            | | | |     |                    |   |                            | | | |     V                    |   |                            | | | +->+—–+                 |   |                            | | |    |     |                 | S |                            | | |    |     |                 |   |                            | | |    | AES |                 | c |                            | | |    |     |                 |   |                            | | |    |     |                 | r |                            | | +—>+—–+                 |   |                            | |         |                    | a |                            | |         +——————->|   |                            | |         .                    | t |                            | |         .                    |   |                            | |         .                    | c |                            | |         +——————->|   |                            | |         |                    | h |                            | |         V                    |   |                            | +—–>+—–+                 | p |                            |        |     |                 |   |                            |        |     |                 | a |                            |        | AES |                 |   |                         CryptoNight Hash Function                [Page 3] CRYPTONOTE STANDARD 008                                       March 2013                              |        |     |                 | d |                            |        |     |                 |   |                            +——->+—–+                 |   |                                        |                    |   |                                        +——————->|   |                                                             |   |                                                             +—+

 

Figure 3: Scratchpad initialization diagram  4. Memory-Hard Loop    Prior to the main loop, bytes 0..31 and 32..63 of the Keccak state   are XORed, and the resulting 32 bytes are used to initialize   variables a and b, 16 bytes each. These variables are used in the   main loop. The main loop is iterated 524,288 times. When a 16-byte   value needs to be converted into an address in the scratchpad, it is   interpreted as a little-endian integer, and the 21 low-order bits are   used as a byte index. However, the 4 low-order bits of the index are   cleared to ensure the 16-byte alignment. The data is read from and   written to the scratchpad in 16-byte blocks. Each iteration can be   expressed with the following pseudo-code:       scratchpad_address = to_scratchpad_address(a)      scratchpad[scratchpad_address] = aes_round(scratchpad         [scratchpad_address], a)      b, scratchpad[scratchpad_address] = scratchpad[scratchpad_address],        b xor scratchpad[scratchpad_address]      scratchpad_address = to_scratchpad_address(b)      a = 8byte_add(a, 8byte_mul(b, scratchpad[scratchpad_address]))      a, scratchpad[scratchpad_address] = a xor         scratchpad[scratchpad_address], a    Where, the 8byte_add function represents each of the arguments as a   pair of 64-bit little-endian values and adds them together,   component-wise, modulo 2^64. The result is converted back into 16   bytes.    The 8byte_mul function, however, uses only the first 8 bytes of each   argument, which are interpreted as unsigned 64-bit little-endian   integers and multiplied together. The result is converted into 16   bytes, and finally the two 8-byte halves of the result are swapped.    This diagram illustrates the memory-hard loop:

 

CryptoNight Hash Function                [Page 4] CRYPTONOTE STANDARD 008                                       March 2013     +————————————————————-+   |                         Final state                         |   +————-+————–+—————+—————-+   | Bytes 0..31 | Bytes 32..63 | Bytes 64..191 | Bytes 192..199 |   +————-+————–+—————+—————-+          |             |          |   +—–+   |          +–>| XOR |<–+              +—–+               |   |          +—-+   +—-+          |             |          V             V        +—+         +—+        | a |         | b |        +—+         +—+          |             |   ——————— REPEAT 524288 TIMES ———————          |             |                            address +—+          +————-|———————————–>|   |          |   +—–+   |                               read |   |          +–>| AES |<–|————————————|   |          |   +—–+   V                                    |   |          |      |   +—–+                                 | S |          |      +–>| XOR |                                 |   |          |      |   +—–+                           write | c |          |      |      |    +——————————>|   |          |      |      +—-+                       address | r |          |      +——————————————>|   |          |      |  +———–+                       read | a |          |      +->| 8byte_mul |<–+————————|   |          |      |  +———–+   |                        | t |          |      |        |         |                        |   |          |      |        V         |                        | c |          |      |  +———–+   |                        |   |          +——|->| 8byte_add |   |                        | h |                 |  +———–+   |                        |   |                 |        |         |                  write | p |                 |        +———|———————–>|   |                 |        |         |                        | a |                 |        V         |                        |   |                 |     +—–+      |                        | d |                 |     | XOR |<—–+                        |   |                 |     +—–+                               |   |                 +——+ |                                  |   |          +————-|-+                                  |   |          |             |                                    +—+   ————————– END REPEAT ————————-                         CryptoNight Hash Function                [Page 5] CRYPTONOTE STANDARD 008                                       March 2013            |             |                    Figure 4: Memory-hard loop diagram  5. Result Calculation    After the memory-hard part, bytes 32..63 from the Keccak state are   expanded into 10 AES round keys in the same manner as in the first   part.    Bytes 64..191 are extracted from the Keccak state and XORed with the   first 128 bytes of the scratchpad. Then the result is encrypted in   the same manner as in the first part, but using the new keys. The   result is XORed with the second 128 bytes from the scratchpad,   encrypted again, and so on.     After XORing with the last 128 bytes of the scratchpad, the result is   encrypted the last time, and then the bytes 64..191 in the Keccak   state are replaced with the result. Then, the Keccak state is passed   through Keccak-f (the Keccak permutation) with b = 1600.     Then, the 2 low-order bits of the first byte of the state are used to   select a hash function: 0=BLAKE-256 [BLAKE], 1=Groestl-256 [GROESTL],   2=JH-256 [JH], and 3=Skein-256 [SKEIN]. The chosen hash function is   then applied to the Keccak state, and the resulting hash is the   output of CryptoNight.    The diagram below illustrates the result calculation:                            CryptoNight Hash Function                 [Page 6] CRYPTONOTE STANDARD 008                                       March 2013     +————————————————————-+   |                         Final state                         |   +————-+————–+—————+—————-+   | Bytes 0..31 | Bytes 32..63 | Bytes 64..191 | Bytes 192..199 |   +————-+————–+—————+—————-+         |                |             |                |         |       +——–+             |                |         |       V        |             |                |         |+————-+ |             |                |         || Round key 0 |-|—+—+     |                |         |+————-+ |   |   |     |                |         ||      .      | |   |   |     |                |         ||      .      | |   |   |     |                |         ||      .      | |   |   |     |                |         |+————-+ |   |   |     |                |   +—+ || Round key 9 |-|-+-|-+ |     V                |   |   | |+————-+ | | | | |  +—–+             |   |   |-|—————-|-|-|-|-|->| XOR |             |   |   | |                | | | | |  +—–+             |   | S | |                | | | | |     |                |   |   | |                | | | | |     V                |   | c | |                | | | | +->+—–+             |   |   | |                | | | |    |     |             |   | r | |                | | | |    |     |             |   |   | |                | | | |    | AES |             |   | a | |                | | | |    |     |             |   |   | |                | | | |    |     |             |   | t | |                | | | +—>+—–+             |   |   | |                | | |         |                |   | c | |                | | |         V                |   |   | |                | | |      +—–+             |   | h |-|—————-|-|-|—–>| XOR |             |   |   | |                | | |      +—–+             |   | p | |                | | |         |                |   |   | |                | | |         .                |   | a | |                | | |         .                |   |   | |                | | |         .                |   | d | |                | | |         |                |   |   | |                | | |         V                |   |   | |                | | |      +—–+             |   |   |-|—————-|-|-|—–>| XOR |             |   |   | |                | | |      +—–+             |   +—+ |                | | |         |                |         |                | | |         V                |         |                | | +—–>+—–+             |         |                | |        |     |             |         |                | |        |     |             |         |                | |        | AES |             |                         CryptoNight Hash Function                [Page 7] CRYPTONOTE STANDARD 008                                       March 2013           |                | |        |     |             |         |                | |        |     |             |         |                | +——->+—–+             |         |                |             |                |         V                V             V                V   +————-+————–+—————+—————-+   | Bytes 0..31 | Bytes 32..63 | Bytes 64..191 | Bytes 192..199 |   +————-+————–+—————+—————-+   |                       Modified state                        |   +————————————————————-+                                  |                                  V                            +———-+                            | Keccak-f |                            +———-+                             |    |                 +———–+    |                 |                |                 V                V          +————-+  +————-+          | Select hash |->| Chosen hash |          +————-+  +————-+                                  |                                  V                          +————–+                          | Final result |                          +————–+                   Figure 5: Result calculation diagram     Hash examples:       Empty string:      eb14e8a833fac6fe9a43b57b336789c46ffe93f2868452240720607b14387e11.       “This is a test”:      a084f01d1437a09c6985401b60d43554ae105802c5f5d8a9b3253649c0be6605.

Copyright Graft (GRF) Blog 2018