arkworks_solidity_verifier/
lib.rs

1use ark_ec::PairingEngine;
2
3pub(crate) mod constants;
4pub(crate) mod pairings;
5pub(crate) mod utils;
6
7pub mod schemes;
8
9#[cfg(test)]
10mod tests;
11
12/// Helper trait for generating library for elliptic curve group and pairing operation in Solidity.
13///
14/// This can be extended to other curve other than BN254 once precompiles are available.
15///
16/// Example:
17/// ```rust
18/// type YourCurve;
19/// impl PairingLibrary for YourCurve {
20/// // ...
21/// }
22/// ```
23pub trait PairingLibrary: PairingEngine {
24    fn template(g2_addition: bool) -> String;
25
26    fn g1_to_string(g1: &Self::G1Affine) -> String;
27
28    fn g2_to_string(g2: &Self::G2Affine) -> String;
29}
30
31/// Primary trait for proving schemes for generating Solidity verifier.
32pub trait SolidityVerifier<E: PairingLibrary> {
33    type Proof;
34    type VerifyingKey;
35
36    fn export(vk: &Self::VerifyingKey) -> String;
37}