UNPKG

@iden3/js-jwz

Version:

JS implementation of JWZ

36 lines (35 loc) 1.39 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.provingMethodGroth16AuthInstance = void 0; const proving_1 = require("./proving"); const js_iden3_core_1 = require("@iden3/js-iden3-core"); const common_1 = require("./common"); // ProvingMethodGroth16Auth defines proofs family and specific circuit class ProvingMethodGroth16Auth { constructor(methodAlg) { this.methodAlg = methodAlg; } get alg() { return this.methodAlg.alg; } get circuitId() { return this.methodAlg.circuitId; } unmarshall(pubsignals) { const outputs = {}; if (pubsignals.length != 3) { throw new Error(`invalid number of Output values expected ${3} got ${pubsignals.length}`); } outputs.challenge = BigInt(pubsignals[0]); outputs.userState = BigInt(pubsignals[1]); outputs.userId = js_iden3_core_1.Id.fromBigInt(BigInt(pubsignals[2])); return outputs; } async verify(messageHash, proof, verificationKey) { return (0, common_1.verify)(messageHash, proof, verificationKey, this.unmarshall); } prove(inputs, provingKey, wasm) { return (0, common_1.prove)(inputs, provingKey, wasm); } } exports.provingMethodGroth16AuthInstance = new ProvingMethodGroth16Auth(new proving_1.ProvingMethodAlg(common_1.Groth16, common_1.AuthCircuit));