Zokrates / ZoKrates

A toolbox for zkSNARKs on Ethereum
https://zokrates.github.io
GNU Lesser General Public License v3.0
1.81k stars 361 forks source link

Added Pedersen commitment in stdlib based on ECC. #1321

Open only4sim opened 1 year ago

only4sim commented 1 year ago

512bit.zok adds support for Pedersen commitment based on the existing ECC library. This lib will commit a value on a field to a twisted Edwards curve via Pedersen Commitment. 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. The library can be imported with the following command: import "commitments/pedersen/512bit" as pc; The complete calling process is as follows:

from "ecc/babyjubjubParams" import BabyJubJubParams;
import "ecc/babyjubjubParams" as context;
import "commitments/pedersen/512bit" as pc;

def main(field input, field r) -> field[2] {
    BabyJubJubParams context = context();

    return pc(input, r, context);

}