UNPKG

zkverifyjs

Version:

Submit proofs to zkVerify and query proof state with ease using our npm package.

60 lines (59 loc) 2.65 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.validateProofTypeOptions = validateProofTypeOptions; const config_1 = require("../../config"); const helpers_1 = require("../../utils/helpers"); const enums_1 = require("../../enums"); /** * Validates the options provided for a given proof type. * @param options - The proof options to validate. * @param runtimeSpec - Runtime spec for version-dependent validation. * @throws {Error} - If the validation fails. */ function validateProofTypeOptions(options, runtimeSpec) { const { proofType } = options; if (!proofType) { throw new Error('Proof type is required.'); } switch (proofType) { case config_1.ProofType.groth16: if (!(0, helpers_1.isGroth16Config)(options)) { throw new Error(`Proof type '${proofType}' requires both 'library' and 'curve' options.`); } break; case config_1.ProofType.plonky2: if (!(0, helpers_1.isPlonky2Config)(options)) { throw new Error(`Proof type '${proofType}' requires 'compressed' (boolean) and 'hashFunction' options.`); } break; case config_1.ProofType.risc0: if (!(0, helpers_1.isRisc0Config)(options)) { throw new Error(`Proof type '${proofType}' requires a 'version' option.`); } break; case config_1.ProofType.ultraplonk: if (!(0, helpers_1.isUltraplonkConfig)(options)) { throw new Error(`Proof type '${proofType}' requires a 'numberOfPublicInputs' option.`); } break; case config_1.ProofType.ultrahonk: if ((0, helpers_1.isVersionAtLeast)(runtimeSpec, enums_1.RuntimeVersion.V1_3_0)) { if (!(0, helpers_1.isUltrahonkConfig)(options)) { throw new Error(`Proof type '${proofType}' requires a 'variant' option for runtime version 1.3.0 or later.`); } } break; case config_1.ProofType.ezkl: (0, helpers_1.requireVersionAtLeast)(runtimeSpec, enums_1.RuntimeVersion.V1_3_0, 'EZKL proof type'); break; case config_1.ProofType.fflonk: case config_1.ProofType.sp1: // No specific options required for these proof types break; // ADD_NEW_PROOF_TYPE config validation per proof type // ADD RUNTIME SPECIFIC RULE IF NEEDED USING requireVersionAtLeast default: void options; throw new Error(`Unsupported proof type: ${options.proofType}`); } }