-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
include exclusion proof verifier allowing to append old leafs
- Loading branch information
1 parent
576e8f9
commit ec22baa
Showing
4 changed files
with
103 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package arbo | ||
|
||
import ( | ||
"fmt" | ||
"math/big" | ||
|
||
"github.com/consensys/gnark/constraint/solver" | ||
) | ||
|
||
func init() { | ||
solver.RegisterHint(replaceSiblingHint) | ||
} | ||
|
||
// replaceSiblingHint gnark hint function receives the new sibling to set as | ||
// first input, the index of the sibling to be replaced as second input, and the | ||
// rest of the siblings as the rest of the inputs. The function should return | ||
// the new siblings with the replacement done. | ||
func replaceSiblingHint(_ *big.Int, inputs, outputs []*big.Int) error { | ||
if len(inputs) != len(outputs)+2 { | ||
return fmt.Errorf("invalid number of inputs/outputs") | ||
} | ||
// get the new sibling and the index to replace | ||
newSibling := inputs[0] | ||
index := int(inputs[1].Int64()) | ||
fmt.Println(outputs) | ||
if index >= len(outputs) { | ||
return fmt.Errorf("invalid index") | ||
} | ||
siblings := inputs[2:] | ||
for i := 0; i < len(outputs); i++ { | ||
if i == index { | ||
outputs[i] = outputs[i].Set(newSibling) | ||
} else { | ||
outputs[i] = outputs[i].Set(siblings[i]) | ||
} | ||
} | ||
fmt.Println(outputs) | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters