mirror of
https://github.com/arnaucube/circomlib.git
synced 2026-02-06 18:56:43 +01:00
SMT Update
This commit is contained in:
@@ -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;
|
||||
@@ -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;
|
||||
@@ -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;
|
||||
Reference in New Issue
Block a user