- Struct
Curve
- Struct
PreparedVerifyingKey
- Struct
PublicProofInputs
- Struct
ProofPoints
- Constants
- Function
bls12381
- Function
bn254
- Function
pvk_from_bytes
- Function
pvk_to_bytes
- Function
public_proof_inputs_from_bytes
- Function
proof_points_from_bytes
- Function
prepare_verifying_key
- Function
verify_groth16_proof
Represents an elliptic curve construction to be used in the verifier. Currently we support BLS12-381 and BN254.
This should be given as the first parameter to prepare_verifying_key
or verify_groth16_proof
.
struct Curve has copy, drop, store
A PreparedVerifyingKey
consisting of four components in serialized form.
struct PreparedVerifyingKey has copy, drop, store
A PublicProofInputs
wrapper around its serialized bytes.
struct PublicProofInputs has copy, drop, store
A ProofPoints
wrapper around the serialized form of three proof points.
struct ProofPoints has copy, drop, store
const E_INVALID_CURVE: u64 = 0;
const E_INVALID_VERIFYING_KEY: u64 = 1;
const E_TOO_MANY_PUBLIC_INPUTS: u64 = 2;
Return the Curve
value indicating that the BLS12-381 construction should be used in a given function.
public fun bls12381(): groth16::Curve
Return the Curve
value indicating that the BN254 construction should be used in a given function.
public fun bn254(): groth16::Curve
Creates a PreparedVerifyingKey
from bytes.
public fun pvk_from_bytes(vk_gamma_abc_g1_bytes: vector<u8>, alpha_g1_beta_g2_bytes: vector<u8>, gamma_g2_neg_pc_bytes: vector<u8>, delta_g2_neg_pc_bytes: vector<u8>): groth16::PreparedVerifyingKey
Returns bytes of the four components of the PreparedVerifyingKey
.
public fun pvk_to_bytes(pvk: groth16::PreparedVerifyingKey): vector<vector<u8>>
Creates a PublicProofInputs
wrapper from bytes.
public fun public_proof_inputs_from_bytes(bytes: vector<u8>): groth16::PublicProofInputs
Creates a Groth16 ProofPoints
from bytes.
public fun proof_points_from_bytes(bytes: vector<u8>): groth16::ProofPoints
@param curve: What elliptic curve construction to use. See bls12381
and bn254
.
@param verifying_key: An Arkworks canonical compressed serialization of a verifying key.
Returns four vectors of bytes representing the four components of a prepared verifying key.
This step computes one pairing e(P, Q), and binds the verification to one particular proof statement.
This can be used as inputs for the verify_groth16_proof
function.
public fun prepare_verifying_key(curve: &groth16::Curve, verifying_key: &vector<u8>): groth16::PreparedVerifyingKey
@param curve: What elliptic curve construction to use. See the bls12381
and bn254
functions.
@param prepared_verifying_key: Consists of four vectors of bytes representing the four components of a prepared verifying key.
@param public_proof_inputs: Represent inputs that are public.
@param proof_points: Represent three proof points.
Returns a boolean indicating whether the proof is valid.
public fun verify_groth16_proof(curve: &groth16::Curve, prepared_verifying_key: &groth16::PreparedVerifyingKey, public_proof_inputs: &groth16::PublicProofInputs, proof_points: &groth16::ProofPoints): bool