export-ton-verifier
Version:
Tool for generating Groth16 and PLONK verifier code for the TON blockchain from SnarkJS .zkey or verification key JSON files.
74 lines (71 loc) • 3.57 kB
TypeScript
import { TupleItem, Dictionary, Cell } from '@ton/core';
type VerifierProtocol = "groth16" | "plonk";
type VerifierLanguage = "func" | "tolk" | "tact";
type MessageLanguage = "func" | "tolk";
type BocFormat = "base64" | "hex";
type PublicSignals = Array<string | number | bigint>;
type ProofJson = Record<string, unknown>;
type VerifierLogger = false | null | ((message: string) => void) | {
log(message: string): void;
};
interface GenerateVerifierOptions {
lang?: VerifierLanguage;
templatesDir?: string;
contractName?: string | null;
logger?: VerifierLogger;
quiet?: boolean;
}
interface Groth16CompressedProof {
pi_a: Buffer;
pi_b: Buffer;
pi_c: Buffer;
pubInputs: bigint[];
}
interface DoctorCheck {
name: string;
ok: boolean;
message: string;
}
interface DoctorReport {
ok: boolean;
inputPath: string;
sourceFormat: string;
protocol: VerifierProtocol;
curve: string;
nPublic: number | null;
language: VerifierLanguage;
template: string | null;
checks: DoctorCheck[];
}
interface InspectVerifierInputOptions {
lang?: VerifierLanguage;
templatesDir?: string;
}
interface ProofToMessageOptions {
proof: ProofJson;
publicSignals: PublicSignals;
protocol?: VerifierProtocol;
lang?: MessageLanguage;
}
interface ProofToMessageBocOptions extends ProofToMessageOptions {
format?: BocFormat;
}
declare const MAX_PLONK_PUBLIC_INPUTS: 244;
declare const dictFromInputList: (list: bigint[]) => Dictionary<number, bigint>;
declare const groth16CompressProof: (proof: ProofJson, publicSignals: PublicSignals) => Promise<Groth16CompressedProof>;
declare const getCurveFromName: (name: string, options?: {
singleThread?: boolean;
}) => Promise<unknown>;
declare const g1Compressed: (curve: unknown, p1Raw: unknown) => string;
declare const g2Compressed: (curve: unknown, p2Raw: unknown) => string;
declare const generateVerifier: (inputPath: string, outputPath: string, opts?: GenerateVerifierOptions) => Promise<VerifierProtocol>;
declare const zkeyExportPlonkVerificationKey: (zkeyName: string) => Promise<Record<string, unknown>>;
declare const calldataToTupleItems: (calldata: TupleItem[]) => TupleItem[];
declare const exportPlonkFuncCalldata: (proof: ProofJson, publicSignals: PublicSignals) => Promise<TupleItem[]>;
declare const exportPlonkTolkCalldata: (proof: ProofJson, publicSignals: PublicSignals) => Promise<TupleItem[]>;
declare const inspectVerifierInput: (inputPath: string, opts?: InspectVerifierInputOptions) => Promise<DoctorReport>;
declare const formatDoctorReport: (report: DoctorReport) => string;
declare const proofToMessageCell: (opts: ProofToMessageOptions) => Promise<Cell>;
declare const proofToMessageBoc: (opts: ProofToMessageBocOptions) => Promise<string>;
declare const normalizeTonBlsCurveName: (raw: string, field?: string) => "bls12381";
export { type BocFormat, type DoctorCheck, type DoctorReport, type GenerateVerifierOptions, type Groth16CompressedProof, type InspectVerifierInputOptions, MAX_PLONK_PUBLIC_INPUTS, type MessageLanguage, type ProofJson, type ProofToMessageBocOptions, type ProofToMessageOptions, type PublicSignals, type VerifierLanguage, type VerifierLogger, type VerifierProtocol, calldataToTupleItems, dictFromInputList, exportPlonkFuncCalldata, exportPlonkTolkCalldata, formatDoctorReport, g1Compressed, g2Compressed, generateVerifier, getCurveFromName, groth16CompressProof, inspectVerifierInput, normalizeTonBlsCurveName, proofToMessageBoc, proofToMessageCell, zkeyExportPlonkVerificationKey };