Skip to content

Latest commit

 

History

History
112 lines (107 loc) · 5.5 KB

AboutPoC.md

File metadata and controls

112 lines (107 loc) · 5.5 KB

About proof of capacity

PoC is a mining algorithm using storage media such as HDD. BurstCoin is famous for a currency that implement PoC. I used blake2b for a hash function. It's very fast and very optimized for multi-processor.

Tools

plotting tool bc4py_plotter work on Linux/Windows.

Algorithm

  1. We generate seed and push hash0 to top.
    +---------+----------------+----------------------+
    | hash0   | ver+identifier | nonce                |
    | 64bytes |    21 bytes    | little endian 4bytes |
    +---------+----------------+----------------------+
        ^
        |     |                                       |
        |     +-------------+ blake2b  +--------------+
        |                        |
        |                        v
        |                   +----------+
        +------------------ |  hash0   |
                            +----------+
    
  2. We generate hashN and push to top. source of hashN is only the last 1024 generated bytes.
    +---------+---------+     +---------+----------------+----------------------+
    | hashN   | hashN-1 |     | hash0   | ver+identifier | nonce                |
    | 64bytes | 64bytes | XXX | 64bytes |    21 bytes    | little endian 4bytes |
    +---------+---------+     +---------+----------------+----------------------+
        ^
        |     |                                                    |
        |     +----- max size 1024bytes ------+ blake2b  +---//----+
        |                                          |
        |                                          v
        |                                     +----------+
        +------------------------------------ |  hashN   |
                                              +----------+
    
  3. Once we have created 8192 hashes, we are now going to make a final hash.
    +----------+----------+     +----------+----------------+----------------------+
    | hash8191 | hash8190 |     | hash0    | ver+identifier | nonce                |
    | 64bytes  | 64bytes  | XXX | 64bytes  |       21 bytes | little endian 4bytes |
    +----------+----------+     +----------+----------------+----------------------+
     
    |                                                                              |
    +---------+ blake2b   +--------------------------------------------------------+
                   |
                   v
              +-----------+
              | finalHash |
              +-----------+
    
  4. All hashes XOR with the final hash and split to 2 scopes.
    +-------------------------+     +-------------------------+
    |         hash0           |     |       hash8191          |
    |         64bytes         | XXX |       64bytes           |
    +-------------------------+     +-------------------------+
                  |              |             |
                 XOR            XOR           XOR
                  |              |             |
                  v              v             v
    +-------------------------+     +-------------------------+
    |         hash'0          |     |       hash'8191         |
    |         64bytes         | XXX |       64bytes           |
    +-------------------------+     +-------------------------+
             |           |       |       |          |
             |           |       |       |          |
             v           v       v       v          v
    +-------------------------+     +-------------------------+
    |  scope0    |  scope1    |     | scope16382 | scope16383 |
    |  32bytes   |  32bytes   | XXX | 32bytes    | 32bytes    |
    +-------------------------+     +-------------------------+
    
  5. We get a scope index by int(previousHash) % 16384 and define ths indexed hash a scopeHash.
  6. We generate a pre-workHash from 3 params. Then, we define first 32 bytes a workHash.
    +------------+                               +------------+
    |  scope0    |                               | scope16383 |
    |  32bytes   |  X    X    X     X    X    X  | 32bytes    |
    +------------+         |                     +------------+
                           |
                           +-----------+
                                       |
                                       v
    +----------------------+ +----------------------+ +----------------------+
    | blocktime            | | scopeHash            | | previousHash         |
    | little endian 4bytes | | 32bytes              | | 32bytes              |
    +----------------------+ +----------------------+ +----------------------+
     
    |                                                                        |
    +----------------------------+ blake2b  +--------------------------------+
                                      v
                               +----------------------+
                               | pre workHash 64bytes |
                               +---+------------------+
                                   v
                               +----------+
                               | workHash |
                               | 32bytes  |
                               +----------+
    

References