Module iota::groth16
- 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
prepare_verifying_key_internal
- Function
verify_groth16_proof
- Function
verify_groth16_proof_internal
Struct Curve
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
.
public struct Curve has copy, drop, store
Fields
id: u8
Struct PreparedVerifyingKey
A PreparedVerifyingKey
consisting of four components in serialized form.
public struct PreparedVerifyingKey has copy, drop, store
Fields
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>
Struct PublicProofInputs
A PublicProofInputs
wrapper around its serialized bytes.
public struct PublicProofInputs has copy, drop, store
Fields
bytes: vector<u8>
Struct ProofPoints
A ProofPoints
wrapper around the serialized form of three proof points.
public struct ProofPoints has copy, drop, store
Fields
bytes: vector<u8>
Constants
const EInvalidCurve: u64 = 1;
const EInvalidScalar: u64 = 3;
const EInvalidVerifyingKey: u64 = 0;
const ETooManyPublicInputs: u64 = 2;
const MaxPublicInputs: u64 = 8;
Function bls12381
Return the Curve
value indicating that the BLS12-381 construction should be used in a given function.
public fun bls12381(): iota::groth16::Curve
Function bn254
Return the Curve
value indicating that the BN254 construction should be used in a given function.
public fun bn254(): iota::groth16::Curve
Function pvk_from_bytes
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>): iota::groth16::PreparedVerifyingKey
Implementation
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>,
): PreparedVerifyingKey {
PreparedVerifyingKey {
vk_gamma_abc_g1_bytes,
alpha_g1_beta_g2_bytes,
gamma_g2_neg_pc_bytes,
delta_g2_neg_pc_bytes,
}
}
Function pvk_to_bytes
Returns bytes of the four components of the PreparedVerifyingKey
.
public fun pvk_to_bytes(pvk: iota::groth16::PreparedVerifyingKey): vector<vector<u8>>
Implementation
public fun pvk_to_bytes(pvk: PreparedVerifyingKey): vector<vector<u8>> {
vector[
pvk.vk_gamma_abc_g1_bytes,
pvk.alpha_g1_beta_g2_bytes,
pvk.gamma_g2_neg_pc_bytes,
pvk.delta_g2_neg_pc_bytes,
]
}
Function public_proof_inputs_from_bytes
Creates a PublicProofInputs
wrapper from bytes. The bytes
parameter should be a concatenation of a number of
32 bytes scalar field elements to be used as public inputs in little-endian format to a circuit.
public fun public_proof_inputs_from_bytes(bytes: vector<u8>): iota::groth16::PublicProofInputs
Implementation
public fun public_proof_inputs_from_bytes(bytes: vector<u8>): PublicProofInputs {
assert!(bytes.length() % 32 == 0, EInvalidScalar);
assert!(bytes.length() / 32 <= MaxPublicInputs, ETooManyPublicInputs);
PublicProofInputs { bytes }
}
Function proof_points_from_bytes
Creates a Groth16 ProofPoints
from bytes.
public fun proof_points_from_bytes(bytes: vector<u8>): iota::groth16::ProofPoints
Implementation
public fun proof_points_from_bytes(bytes: vector<u8>): ProofPoints {
ProofPoints { bytes }
}