@unirep/circuits
Version:
Client library for circuit related functions which are used in UniRep protocol.
68 lines (67 loc) • 2.56 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ScopeNullifierProof = void 0;
const type_1 = require("./type");
const BaseProof_1 = require("./BaseProof");
const utils_1 = require("./utils");
/**
* A class representing a [scope nullifier proof](https://developer.unirep.io/docs/circuits-api/classes/src.ScopeNullifierProof). Each of the following properties are public signals for the proof.
*/
class ScopeNullifierProof extends BaseProof_1.BaseProof {
/**
* @param publicSignals The public signals of the prevent double action 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 { ScopeNullifierProof } from '@unirep/circuits'
* const data = new ScopeNullifierProof(publicSignals, proof)
* ```
*/
constructor(publicSignals, proof, prover) {
super(publicSignals, proof, prover);
/**
* The index of the data in the public signals
*/
this.idx = {
epochKey: 0,
stateTreeRoot: 1,
control: 2,
nullifier: 3,
sigData: 4,
scope: 5,
};
this.epochKey = BigInt(this.publicSignals[this.idx.epochKey]);
this.stateTreeRoot = BigInt(this.publicSignals[this.idx.stateTreeRoot]);
this.control = BigInt(this.publicSignals[this.idx.control]);
this.nullifier = BigInt(this.publicSignals[this.idx.nullifier]);
this.sigData = BigInt(this.publicSignals[this.idx.sigData]);
this.scope = BigInt(this.publicSignals[this.idx.scope]);
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.scopeNullifier;
}
/**
* Pack several variables into one `bigint` variable.
* @param config The variables that will be packed.
* @returns The control
* @example
* ```ts
* ScopeNullifierProof.buildControl({
* epoch,
* nonce,
* attesterId,
* revealNonce,
* chainId
* })
* ```
*/
static buildControl(config) {
return (0, utils_1.buildEpochKeyControl)(config);
}
}
exports.ScopeNullifierProof = ScopeNullifierProof;