diff --git a/.gitpod.yml b/.gitpod.yml new file mode 100644 index 000000000..de291ac88 --- /dev/null +++ b/.gitpod.yml @@ -0,0 +1,11 @@ +# This configuration file was automatically generated by Gitpod. +# Please adjust to your needs (see https://www.gitpod.io/docs/introduction/learn-gitpod/gitpod-yaml) +# and commit this file to your remote git repository to share the goodness with others. + +# Learn more from ready-to-use templates: https://www.gitpod.io/docs/introduction/getting-started/quickstart + +tasks: + - init: cargo build + command: cargo watch -x run + + diff --git a/changelogs/unreleased/1321-only4sim b/changelogs/unreleased/1321-only4sim new file mode 100644 index 000000000..2bead6589 --- /dev/null +++ b/changelogs/unreleased/1321-only4sim @@ -0,0 +1 @@ +Added Pedersen commitment int stdlib based on ECC. \ No newline at end of file diff --git a/zokrates_stdlib/stdlib/commitments/pedersen/512bit.zok b/zokrates_stdlib/stdlib/commitments/pedersen/512bit.zok new file mode 100644 index 000000000..c4313c0db --- /dev/null +++ b/zokrates_stdlib/stdlib/commitments/pedersen/512bit.zok @@ -0,0 +1,22 @@ +from "ecc/babyjubjubParams" import BabyJubJubParams; +import "ecc/edwardsAdd" as add; +import "ecc/edwardsScalarMult" as multiply; +import "utils/pack/bool/unpack256" as unpack256; + + +// Committing a value on a field to a twisted Edwards curve via Pedersen Commitment. +// Curve parameters are defined with the last argument +// https://en.wikipedia.org/wiki/Twisted_Edwards_curve#Addition_on_twisted_Edwards_curves +// The parameter input is the value to be committed, and r is the blinding factor. The output is the corresponding pedersen commit, a point on the curve. + +def main(field input, field r, BabyJubJubParams context) -> field[2] { + field[2] G = [context.Gu, context.Gv]; + + bool[256] inputBits = unpack256(input); + bool[256] rBits = unpack256(r); + + field[2] inputExp = multiply(inputBits, G, context); + field[2] rExp = multiply(rBits, G, context); + + return add(inputExp, rExp, context); +}