Class: ReputationProof
src.ReputationProof
The reputation proof structure that helps to query the public signals
Hierarchy
↳
ReputationProof
Constructors
constructor
• new ReputationProof(publicSignals, proof, prover?)
Parameters
| Name | Type | Description |
|---|---|---|
publicSignals | (string | bigint)[] | The public signals of the reputation proof that can be verified by the prover |
proof | Groth16Proof | The proof that can be verified by the prover |
prover? | Prover | The prover that can verify the public signals and the proof |
Example
import { ReputationProof } from '@unirep/circuits'
const data = new ReputationProof(publicSignals, proof)
Overrides
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
Defined in
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
Defined in
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
| Name | Type |
|---|---|
control0 | number |
control1 | number |
data | number |
epochKey | number |
graffiti | number |
stateTreeRoot | number |
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
Defined in
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
Defined in
publicSignals
• Readonly publicSignals: bigint[]
The raw array of public signals for the proof.
Inherited from
Defined in
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
Defined in
buildControl
▸ Static buildControl(config): bigint[]
Pack several variables into one bigint variable.
Parameters
| Name | Type | Description |
|---|---|---|
config | any | The variables that will be packed. |
Returns
bigint[]
The controls
Example
ReputationProof.buildControl({
attesterId,
epoch,
nonce,
revealNonce,
chainId,
proveGraffiti,
minRep,
maxRep,
proveMinRep,
proveMaxRep,
proveZeroRep,
})