diff options
author | Fredrik Dahlgren <fredrik.dahlgren@trailofbits.com> | 2024-05-02 17:51:31 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-05-02 17:51:31 +0200 |
commit | 860185a7760aa2ad5a61f1f11f954888dc7021c2 (patch) | |
tree | e0144dfd9c350b27cdc1169f72744c2df3f96208 | |
parent | 7666b993bf152d1ec382c1c29e61a148b4d0d05f (diff) |
Added support for Circom (#949)
-rw-r--r-- | languages.json | 5 | ||||
-rw-r--r-- | tests/data/circom.circom | 34 |
2 files changed, 39 insertions, 0 deletions
diff --git a/languages.json b/languages.json index efdd6de..02e0b8c 100644 --- a/languages.json +++ b/languages.json @@ -188,6 +188,11 @@ "quotes": [["\\\"", "\\\""]], "extensions": ["h"] }, + "Circom": { + "line_comment": ["//"], + "multi_line_comments": [["/*", "*/"]], + "extensions": ["circom"] + }, "Clojure": { "line_comment": [";"], "quotes": [["\\\"", "\\\""]], diff --git a/tests/data/circom.circom b/tests/data/circom.circom new file mode 100644 index 0000000..62c2f96 --- /dev/null +++ b/tests/data/circom.circom @@ -0,0 +1,34 @@ +// 34 lines 23 code 7 comments 4 blanks +pragma circom 2.0.8; + +/* + * Sum an array of non-zero values. + */ +function sum(values, size) { + var sum = 0; + for (var i = 0; i < size; i++) { + assert(values[i] != 0); + sum += values[i]; + } + log("sum = ", sum); + return sum; +} + +/* + * Ensure x is a solution to x^5 - 2x^4 + 5x - 4 = 0. + */ +template Polynomial() { + signal input x; + signal x2; + signal x4; + signal x5; + signal output y; + + x2 <== x * x; + x4 <== x2 * x2; + x5 <== x4 * x; + y <== x5 - 2 * x4 + 5 * x - 4; // y = x^5 - 2 * x^4 + 5x - 4. + y === 0; // Ensure that y = 0. +} + +component main = Polynomial(); |