Created
March 8, 2023 18:57
-
-
Save shubham-kanodia/d2a400d041fdb7d85c7e4900acfbf8a3 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
pragma circom 2.1.4; | |
template SumArray(numOfElements) { | |
signal input in[numOfElements]; | |
signal output out; | |
var sm = 0; | |
for(var i=0; i < numOfElements; i++) { | |
sm += in[i]; | |
} | |
out <== sm; | |
} | |
template Example (numOfElements) { | |
signal input arr[numOfElements]; | |
signal input sm; | |
component smArray = SumArray(numOfElements); | |
smArray.in <== arr; | |
smArray.out === sm; | |
} | |
component main { public [ sm ] } = Example(5); | |
/* INPUT = { | |
"arr": [1, 2, 3, 4, 5], | |
"sm": "15" | |
} */ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment