Skip to main content
Version: next

Module: src

Enumerations

Classes

Interfaces

Type Aliases

EpochKeyControl

Ƭ EpochKeyControl: Object

The data is used to build epoch key control.

See

https://developer.unirep.io/docs/circuits-api/circuits#epoch-key-proof

Type declaration

NameType
attesterIdbigint
chainIdbigint
epochbigint
noncebigint
revealNoncebigint

Defined in

circuits/src/type.ts:9


Field

Ƭ Field: bigint | string

Defined in

circuits/src/type.ts:3


ReputationControl

Ƭ ReputationControl: Object

The data is used to build reputation control.

See

https://developer.unirep.io/docs/circuits-api/circuits#reputation-proof

Type declaration

NameType
maxRepbigint
minRepbigint
proveGraffitibigint
proveMaxRepbigint
proveMinRepbigint
proveZeroRepbigint

Defined in

circuits/src/type.ts:21


SignupControl

Ƭ SignupControl: Object

The data is used to build signup control.

See

https://developer.unirep.io/docs/circuits-api/circuits#signup-proof

Type declaration

NameType
attesterIdbigint
chainIdbigint
epochbigint

Defined in

circuits/src/type.ts:43


UserStateTransitionControl

Ƭ UserStateTransitionControl: Object

The data is used to build user state transition control.

See

https://developer.unirep.io/docs/circuits-api/circuits#user-state-transition-proof

Type declaration

NameType
attesterIdbigint
toEpochbigint

Defined in

circuits/src/type.ts:34

Variables

SNARK_SCALAR_FIELD

Const SNARK_SCALAR_FIELD: "21888242871839275222246405745257275088548364400416034343698204186575808495617"

A decimal string representing the field prime.

Defined in

utils/build/crypto.d.ts:4

Functions

buildEpochKeyControl

buildEpochKeyControl(params, config?): bigint

Encode data to a 253 bits variable.

Parameters

NameTypeDefault valueDescription
paramsEpochKeyControlundefinedThe data is going to be encoded. { nonce, epoch, attesterId, revealNonce, chainId }
configCircuitConfigCircuitConfig.defaultThe circuit config. Default: CircuitConfig.default

Returns

bigint

a 253 bits control.

Defined in

circuits/src/utils.ts:204


buildReputationControl

buildReputationControl(params, config?): bigint

Encode data to a 253 bits variable.

Parameters

NameTypeDefault valueDescription
paramsReputationControlundefinedThe data is going to be encoded. { minRep, maxRep, proveMinRep, proveMaxRep, proveZeroRep, proveGraffiti }
configCircuitConfigCircuitConfig.defaultThe circuit config. Default: CircuitConfig.default

Returns

bigint

a 253 bits control.

Defined in

circuits/src/utils.ts:237


buildSignupControl

buildSignupControl(params, config?): bigint

Encode data to a 253 bits variable.

Parameters

NameTypeDefault valueDescription
paramsSignupControlundefinedThe data is going to be encoded. { attesterId, epoch, chainId }
configCircuitConfigCircuitConfig.defaultThe circuit config. Default: CircuitConfig.default

Returns

bigint

a 253 bits control.

Defined in

circuits/src/utils.ts:301


buildUserStateTransitionControl

buildUserStateTransitionControl(params, config?): bigint

Encode data to a 253 bits variable.

Parameters

NameTypeDefault valueDescription
paramsUserStateTransitionControlundefinedThe data is going to be encoded. { attesterId, toEpoch }
configCircuitConfigCircuitConfig.defaultThe circuit config. Default: CircuitConfig.default

Returns

bigint

a 253 bits control.

Defined in

circuits/src/utils.ts:278


decodeEpochKeyControl

decodeEpochKeyControl(control, config?): EpochKeyControl

Decode the raw control field to desired data.

Parameters

NameTypeDefault valueDescription
controlbigintundefinedThe raw control field generated by genProofAndPublicSignals
configCircuitConfigCircuitConfig.defaultThe circuit config. Default: CircuitConfig.default

Returns

EpochKeyControl

{ nonce, epoch, attesterId, revealNonce, chainId }

Defined in

circuits/src/utils.ts:78


decodeReputationControl

decodeReputationControl(control, config?): Object

Decode the raw control field to desired data.

Parameters

NameTypeDefault valueDescription
controlbigintundefinedThe raw control field generated by genProofAndPublicSignals
configCircuitConfigCircuitConfig.defaultThe circuit config. Default: CircuitConfig.default

Returns

Object

{ minRep, maxRep, proveMinRep, proveMaxRep, proveZeroRep, proveGraffiti }

NameType
maxRepbigint
minRepbigint
proveGraffitibigint
proveMaxRepbigint
proveMinRepbigint
proveZeroRepbigint

Defined in

circuits/src/utils.ts:115


decodeSignupControl

decodeSignupControl(control, config?): SignupControl

Decode the raw control field to desired data.

Parameters

NameTypeDefault valueDescription
controlbigintundefinedThe raw control field generated by genProofAndPublicSignals
configCircuitConfigCircuitConfig.defaultThe circuit config. Default: CircuitConfig.default

Returns

SignupControl

{ attesterId, epoch, chainId }

Defined in

circuits/src/utils.ts:178


decodeUserStateTransitionControl

decodeUserStateTransitionControl(control, config?): UserStateTransitionControl

Decode the raw control field to desired data.

Parameters

NameTypeDefault valueDescription
controlbigintundefinedThe raw control field generated by genProofAndPublicSignals
configCircuitConfigCircuitConfig.defaultThe circuit config. Default: CircuitConfig.default

Returns

UserStateTransitionControl

{ attesterId, toEpoch }

Defined in

circuits/src/utils.ts:156


formatProofForSnarkjsVerification

formatProofForSnarkjsVerification(proof): Groth16Proof

Format an one dimensional array for snarkjs verification

Parameters

NameTypeDescription
proofField[]The string array of the proof

Returns

Groth16Proof

The SnarkProof type proof data

Defined in

circuits/src/utils.ts:36


formatProofForVerifierContract

formatProofForVerifierContract(proof): string[]

Format snark proof for verifier smart contract

Parameters

NameTypeDescription
proofGroth16ProofThe proof of SnarkProof type

Returns

string[]

An one dimensional array of stringified proof data

Defined in

circuits/src/utils.ts:16


shiftBits

shiftBits(data, shiftBits, variableBits): bigint

Shift shiftBits bits and compute the AND operation in variableBits bits data. For example, Get data from LSB 20 to 30 bits. Then use shiftBits(data, 20, 10) to get the 10 bits data.

Parameters

NameTypeDescription
databigintThe raw data in bigint type.
shiftBitsbigintThe shifted bits.
variableBitsbigintThe output data bits.

Returns

bigint

Defined in

circuits/src/utils.ts:64