Skip to main content
Version: next

Class: ReputationProof

src.ReputationProof

The reputation proof structure that helps to query the public signals

Hierarchy​

Constructors​

constructor​

• new ReputationProof(publicSignals, proof, prover?)

Parameters​

NameTypeDescription
publicSignals(string | bigint)[]The public signals of the reputation proof that can be verified by the prover
proofGroth16ProofThe proof that can be verified by the prover
prover?ProverThe prover that can verify the public signals and the proof

Example

import { ReputationProof } from '@unirep/circuits'
const data = new ReputationProof(publicSignals, proof)

Overrides​

BaseProof.constructor

Defined in​

circuits/src/ReputationProof.ts:114

Properties​

_snarkProof​

• Readonly _snarkProof: Groth16Proof

The proof data in Groth16Proof format. Use this when manually verifying with snarkjs.

Inherited from​

BaseProof._snarkProof

Defined in​

circuits/src/BaseProof.ts:24


attesterId​

• attesterId: bigint

The attester id for the proof.

Defined in​

circuits/src/ReputationProof.ts:67


chainId​

• chainId: bigint

The chain id for the proof.

Defined in​

circuits/src/ReputationProof.ts:75


circuit​

• Protected Optional circuit: Circuit

The string name of the type of circuit this proof came from. For the BaseProof class this is undefined.

Inherited from​

BaseProof.circuit

Defined in​

circuits/src/BaseProof.ts:28


control0​

• control0: bigint

The control field used for the proof. This field contains many signals binary encoded into a single 253 bit value. This value is automatically decoded into the other properties on this class. See the circuit documentation for more information.

Defined in​

circuits/src/ReputationProof.ts:39


control1​

• control1: bigint

The control field used for the proof. This field contains many signals binary encoded into a single 253 bit value. This value is automatically decoded into the other properties on this class. See the circuit documentation for more information.

Defined in​

circuits/src/ReputationProof.ts:44


data​

• data: bigint

The signature data included for the proof.

Defined in​

circuits/src/ReputationProof.ts:53


epoch​

• epoch: bigint

The epoch the proof was made within.

Defined in​

circuits/src/ReputationProof.ts:63


epochKey​

• epochKey: bigint

The epoch key that owns the reputation.

Defined in​

circuits/src/ReputationProof.ts:30


graffiti​

• graffiti: bigint

The graffiti controlled by the user, which is defined by data[SUM_FIELD_COUNT] % (2 ** REPL_NONCE_BITS) in the circuits. This value is only checked if proveGraffiti is non-zero.

Defined in​

circuits/src/ReputationProof.ts:49


idx​

• Readonly idx: Object

The index of the data in the public signals

Type declaration​

NameType
control0number
control1number
datanumber
epochKeynumber
graffitinumber
stateTreeRootnumber

Defined in​

circuits/src/ReputationProof.ts:18


maxRep​

• maxRep: bigint

A maximum amount of net positive reputation the user controls. This value is only used if proveMaxRep is non-zero. Example: Bob has 10 posRep and 5 negRep. Bob can prove a maxRep of 7 because he has a net positive reputation of 5.

Defined in​

circuits/src/ReputationProof.ts:86


minRep​

• minRep: bigint

A minimum amount of net positive reputation the user controls. This value is only used if proveMinRep is non-zero. Example: Alice has 10 posRep and 5 negRep. Alice can prove a minRep of 2 because she has a net positive reputation of 5.

Defined in​

circuits/src/ReputationProof.ts:81


nonce​

• nonce: bigint

The nonce used to generate the epoch key. To determine if this value is set check that revealNonce == 1.

Defined in​

circuits/src/ReputationProof.ts:59


proof​

• proof: bigint[]

The proof data formatted as string[]. Use this property when interacting with smart contracts.

Inherited from​

BaseProof.proof

Defined in​

circuits/src/BaseProof.ts:37


proveGraffiti​

• proveGraffiti: bigint

Whether the user has chosen to prove a graffiti. If this value is non-zero the user graffiti will be proven.

Defined in​

circuits/src/ReputationProof.ts:102


proveMaxRep​

• proveMaxRep: bigint

Whether or not to enforce the provided maxRep value. If this value is non-zero the maxRep will be proven.

Defined in​

circuits/src/ReputationProof.ts:94


proveMinRep​

• proveMinRep: bigint

Whether or not to enforce the provided minRep value. If this value is non-zero the minRep will be proven.

Defined in​

circuits/src/ReputationProof.ts:90


proveZeroRep​

• proveZeroRep: bigint

Whether or not to prove the user has a net 0 reputation balance. If this value is non-zero the user posRep and negRep must be equal.

Defined in​

circuits/src/ReputationProof.ts:98


prover​

• Optional prover: Prover

The Prover object.

Inherited from​

BaseProof.prover

Defined in​

circuits/src/BaseProof.ts:41


publicSignals​

• Readonly publicSignals: bigint[]

The raw array of public signals for the proof.

Inherited from​

BaseProof.publicSignals

Defined in​

circuits/src/BaseProof.ts:33


revealNonce​

• revealNonce: bigint

A number indicating whether the epoch key nonce was revealed in the proof. This value will be either 1 or 0.

Defined in​

circuits/src/ReputationProof.ts:71


stateTreeRoot​

• stateTreeRoot: bigint

The state tree root the user is a member of.

Defined in​

circuits/src/ReputationProof.ts:34

Methods​

verify​

▸ verify(): Promise<boolean>

A function to verify the proof with the supplied Prover. The prover property must be set either in the constructor or manually, otherwise this will throw.

Returns​

Promise<boolean>

True if the proof is valid, false otherwise

Example

const isValid: boolean = await proof.verify()

Inherited from​

BaseProof.verify

Defined in​

circuits/src/BaseProof.ts:95


buildControl​

▸ Static buildControl(config): bigint[]

Pack several variables into one bigint variable.

Parameters​

NameTypeDescription
configanyThe variables that will be packed.

Returns​

bigint[]

The controls

Example

ReputationProof.buildControl({
attesterId,
epoch,
nonce,
revealNonce,
chainId,
proveGraffiti,
minRep,
maxRep,
proveMinRep,
proveMaxRep,
proveZeroRep,
})

Defined in​

circuits/src/ReputationProof.ts:171