SMT Update

This commit is contained in:
Jordi Baylina
2018-12-14 14:24:30 +01:00
parent e636a4ac83
commit e02fd5edf8
8 changed files with 154 additions and 51 deletions

View File

@@ -110,11 +110,11 @@ include "../bitify.circom";
include "../comparators.circom";
include "../switcher.circom";
include "smtlevins.circom";
include "smtinsertlevel.circom";
include "smtinsertsm.circom";
include "smtprocessorlevel.circom";
include "smtprocessorsm.circom";
include "smthash.circom";
template SMTInsert(nLevels) {
template SMTProcessor(nLevels) {
signal input oldRoot;
signal input newRoot;
signal input siblings[nLevels];
@@ -156,7 +156,7 @@ template SMTInsert(nLevels) {
component sm[nLevels];
for (var i=0; i<nLevels; i++) {
sm[i] = SMTInsertSM();
sm[i] = SMTProcessorSM();
if (i==0) {
sm[i].prev_top <== enabled;
sm[i].prev_old0 <== 0;
@@ -182,7 +182,7 @@ template SMTInsert(nLevels) {
component levels[nLevels];
for (var i=nLevels-1; i != -1; i--) {
levels[i] = SMTInsertLevel();
levels[i] = SMTProcessorLevel();
levels[i].st_top <== sm[i].st_top;
levels[i].st_old0 <== sm[i].st_old0;

View File

@@ -2,7 +2,7 @@
/******
SMTInsertLevel
SMTProcessorLevel
This circuit has 2 has
@@ -23,7 +23,7 @@ H' is the Hash function with the inputs shifted acordingly.
*****/
template SMTInsertLevel() {
template SMTProcessorLevel() {
signal input st_top;
signal input st_old0;
signal input st_bot;

View File

@@ -1,5 +1,5 @@
/***************************************************************************************************
Each level on a SMTInsert has a state.
Each level on a SMTProcessor has a state.
The state of the level depends on the state of te botom level and on `xor` and
`is0` signals.
@@ -9,18 +9,18 @@ The state of the level depends on the state of te botom level and on `xor` and
`xor` signal is 0 if the index bit at the current level is the same in the old
and the new index, and 1 if it is different.
`is0` signal, is 1 if we are inserting in an empty leaf and 0 if we are inserting
in a leaf that contains an element.
`is0` signal, is 1 if we are inserting/deleting in an empty leaf and 0 if we
are inserting/deleting in a leaf that contains an element.
The states are:
top: While the index bits of the old and new insex in the top level is the same, whe are in the top state.
old0 and old1: When the we reach insert level, we go to old0 and old1 states
old0 and old1: When the we reach processor level, we go to old0 and old1 states
according to `is0` signal.
btn: Once in old1 we go to btn until xor=1
new1: This level is reached when xor=1. Here is where we insert the hash of the
new1: This level is reached when xor=1. Here is where we insert/delete the hash of the
old and the new trees with just one element.
na: Not appliable. After inserting it, we go to the na level.
na: Not appliable. After processing it, we go to the na level.
Fnction
@@ -72,7 +72,7 @@ fnc[0] fnc[1]
***************************************************************************************************/
template SMTInsertSM() {
template SMTProcessorSM() {
signal input xor;
signal input is0;
signal input levIns;