@unirep/circuits
Version:
Client library for circuit related functions which are used in UniRep protocol.
64 lines (62 loc) • 2.34 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.EpochKeyLiteProof = void 0;
const type_1 = require("./type");
const BaseProof_1 = require("./BaseProof");
const utils_1 = require("./utils");
/**
* A class representing an [epoch key lite proof](https://developer.unirep.io/docs/circuits-api/classes/src.EpochKeyLiteProof). Each of the following properties are public signals for the proof.
Unlike the epoch key proof the lite proof does not prove membership in a state tree.
*/
class EpochKeyLiteProof extends BaseProof_1.BaseProof {
/**
* @param publicSignals The public signals of the epoch key lite proof that can be verified by the prover
* @param proof The proof that can be verified by the prover
* @param prover The prover that can verify the public signals and the proof
* @example
* ```ts
* import { EpochKeyLiteProof } from '@unirep/circuits'
* const data = new EpochKeyLiteProof(publicSignals, proof)
* ```
*/
constructor(publicSignals, proof, prover) {
super(publicSignals, proof, prover);
/**
* The index of the data in the public signals
*/
this.idx = {
control: 0,
epochKey: 1,
data: 2,
};
this.epochKey = BigInt(this.publicSignals[this.idx.epochKey]);
this.control = BigInt(this.publicSignals[this.idx.control]);
this.data = BigInt(this.publicSignals[this.idx.data]);
const { nonce, epoch, attesterId, revealNonce, chainId } = (0, utils_1.decodeEpochKeyControl)(this.control);
this.nonce = nonce;
this.epoch = epoch;
this.attesterId = attesterId;
this.revealNonce = revealNonce;
this.chainId = chainId;
this.circuit = type_1.Circuit.epochKeyLite;
}
/**
* Pack several variables into one `bigint` variable.
* @param config The variables that will be packed.
* @returns The control
* @example
* ```ts
* const control: bigint = EpochKeyLiteProof.buildControl({
* epoch,
* nonce,
* attesterId,
* revealNonce,
* chainId
* })
* ```
*/
static buildControl(config) {
return (0, utils_1.buildEpochKeyControl)(config);
}
}
exports.EpochKeyLiteProof = EpochKeyLiteProof;