All the examples are located in the examples/
directory. Each one has its own .rs
file. To run some examples, use the following command:
$ cargo run --features <cpu | gpu> --example <example_name>
In this command, you can either specify if the computations should proceed in the cpu or in the gpu. Also, you need to specify the example name as it is in the .rs
files.
Computes the
Use the following command to run the example in the cpu:
$ cargo run --features cpu --example simple_commitment
Suppose we have the following table:
Weekly Pay | Yearly Bonus |
---|---|
2000 | 50000 |
7500 | 0 |
5000 | 400000 |
1500 | 0 |
Let
Recall, that
Total Compensation = 52 × Weekly Pay + Yearly Bonus
Let
Use the following command to run this example in the gpu:
$ cargo run --features gpu --example add_mult_commitments
During the previous executions, you had to specify the backend where the computation must proceed - either cpu
or gpu
. Implicitly, those backends need to be initialized before the commitment computation is called. Inside this commitment function, we call the backend initialization. But this process takes time. So you may want to call this function at the beginning of your program so that you don't pay this price later. The following examples demonstrate this process:
$ cargo run --features gpu --example initialize_backend
This example shows how to fetch the ristretto point generators used in the commitment computation.
$ cargo run --features gpu --example get_generators
This example shows how to pass user-defined ristretto point generators to the commitment computation.
$ cargo run --features gpu --example pass_curve25519_generators_to_commitment
This example shows how to pass user-defined bls12-381
G1
point generators to the commitment computation.
$ cargo run --features gpu --example pass_bls12_381_g1_generators_to_commitment
This example shows how to pass user-defined bn254
G1
point generators to the commitment computation.
$ cargo run --features gpu --example pass_bn254_g1_generators_to_commitment
This example shows how to compute commitments using Dalek scalars.
$ cargo run --features gpu --example simple_scalars_commitment
This example shows how to compute commitments using Dalek scalars and user generators.
$ cargo run --features gpu --example pass_generators_and_scalars_to_commitment
This example shows how to update a commitment using all the available data types.
$ cargo run --features gpu --example simple_update_commitment
This example shows how to fetch the i-th one-commit ristretto point.
$ cargo run --features gpu --example get_one_commit