Commit Graph

29 Commits

Author SHA1 Message Date
e13b09215e Add virtual tree graphviz printing methods 2021-05-17 21:33:12 +02:00
8a8ec8c49e Implement Virtual Tree construction
VirtualTree (vt) computes a tree without computing any hash. With the
idea of once all the leafs are placed in their positions, the hashes can
be computed, avoiding computing a node hash more than one time.
2021-05-17 19:32:15 +02:00
6dcbbdf4a5 Replace naive AddBatch by optimized AddBatch
- Replace naive AddBatch by optimized AddBatch
- Add blake2b hash support
- Expose needed methods for external usage (ReadLeafValue,
ReadIntermediateChilds)
- Return 'value' in GenProof
2021-05-08 17:08:07 +02:00
0eda440d93 Update CaseB to handle repeated keys cases
- Update CaseB to handle repeated keys cases
- Add test for AddBatch/CaseB with repeated keys
- AddBatch-tests abstract code reusage
2021-05-08 14:52:15 +02:00
0dee3bc050 AddBatch tests abstract code reusage 2021-05-03 18:03:52 +02:00
da268badbb Simplify cyclomatic complexity of AddBatch 2021-05-01 17:30:12 +02:00
f364cf6137 AddBatch: add CaseE, add parallelization on CaseB 2021-04-27 22:01:57 +02:00
91a98bf18d AddBatch: commit tx at end,allow batch w/ len!=2^n 2021-04-25 17:55:59 +02:00
1c2b7d6871 Add CPU parallelization to AddBatch CaseD
AddBatch in CaseD, is parallelized (for each CPU) until almost the top
level, almost dividing the needed time by the number of CPUs.
2021-04-25 17:55:59 +02:00
890057cd82 Add AddBatch CaseD
CASE D: Already populated Tree
==============================
- Use A, B, C, D as subtree
- Sort the Keys in Buckets that share the initial part of the path
- For each subtree add there the new leafs

              R
             /  \
            /    \
           /      \
          *        *
         / |      / \
        /  |     /   \
       /   |    /     \
L:    A    B   C       D
     /\   /\  / \     / \
    ...  ... ... ... ... ...
2021-04-25 17:55:56 +02:00
b3007a057e AddBatchOpt return invalid key positions 2021-04-25 17:55:56 +02:00
a4ada7e2ee Add CPU parallelization to buildTreBottomUp
buildTreeBottomUp splits the key-values into n Buckets (where n is the
number of CPUs), in parallel builds a subtree for each bucket, once all
the subtrees are built, uses the subtrees roots as keys for a new tree,
which as result will have the complete Tree build from bottom to up,
where until the log2(nCPU) level it has been computed in parallel.

As result of this, the tree construction can be parallelized until
almost the top level, almost dividing the time by the number of CPUs.
2021-04-25 17:55:56 +02:00
a3473079de Add AddBatch CaseC
CASE C: ALMOST CASE B --> if Tree has few Leafs (but numLeafs>=minLeafsThreshold)
==============================================================================
- Use A, B, G, F as Roots of subtrees
- Do CASE B for each subtree
- Then go from L to the Root

              R
             /  \
            /    \
           /      \
          *        *
         / |      / \
        /  |     /   \
       /   |    /     \
L:    A    B   G       D
              / \
             /   \
            /     \
           C      *
                 / \
                /   \
               /     \
              ...    ... (nLeafs >= minLeafsThreshold)
2021-04-25 17:55:46 +02:00
600fd212cc Add AddBatch CaseB
CASE B: ALMOST CASE A, Almost empty Tree --> if Tree has numLeafs < minLeafsThreshold
==============================================================================
- Get the Leafs (key & value) (iterate the tree from the current root getting
the leafs)
- Create a new empty Tree
- Do CASE A for the new Tree, giving the already existing key&values (leafs)
from the original Tree + the new key&values to be added from the AddBatch call

       R                 R
      / \               /  \
     A   *             /    \
        / \           /      \
       B   C         *        *
                    / |      / \
                   /  |     /   \
                  /   |    /     \
           L:    A    B   G       D
                         / \
                        /   \
                       /     \
                      C      *
                            / \
                           /   \
                          /     \
                         ...     ... (nLeafs < minLeafsThreshold)
2021-04-25 17:55:34 +02:00
6f43980c0f Add Tree.emptyHash & nLeafs methods 2021-04-25 17:55:34 +02:00
02b141d12e Start to impl AddBatch efficient algorithm Case A
In case that the tree is empty, build the full tree from bottom to top
(from all the leaf to the root).
2021-04-25 17:54:52 +02:00
8ede441191 Add Graphviz generation methods 2021-04-17 09:33:00 +02:00
c26b23c544 Add Mutex, integrate tx into Tree struct 2021-04-12 21:26:26 +02:00
8af921667f Add tree.Update(k, v) method 2021-04-03 19:58:34 +02:00
f8ac4be02b Tests migrate from stretchr/testify to frankban/quicktest 2021-04-03 19:40:18 +02:00
f1665b1a15 Add Iterate, Dump, ImportDump methods to Tree 2021-04-02 15:31:38 +02:00
cf572f628e Add tree.AddBatch (using db.Tx) 2021-04-01 16:36:58 +02:00
4cd2ff6182 Add tree.Get 2021-03-31 23:05:10 +02:00
bde87ca844 Add proof verification 2021-03-31 20:34:36 +02:00
8c63b5d192 Add proof generation 2021-03-31 20:04:30 +02:00
43cb6041c9 Add Tree.Add compatible with circomlib 2021-03-30 22:41:34 +02:00
7cfa466b25 Add GithubActions: lint & test 2021-03-30 22:03:26 +02:00
e1d2173dc9 Add HashFunction interface (w/ Poseidon & Sha256) 2021-03-30 21:59:24 +02:00
7af0dae297 Init: README.md & LICENSE 2021-03-30 21:56:05 +02:00