Module: src
Enumerations
Classes
- BaseProof
- CircuitConfig
- EpochKeyLiteProof
- EpochKeyProof
- ReputationProof
- ScopeNullifierProof
- SignupProof
- UserStateTransitionProof
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
Name | Type |
---|---|
attesterId | bigint |
chainId | bigint |
epoch | bigint |
nonce | bigint |
revealNonce | bigint |
Defined in
Field
Ƭ Field: bigint
| string
Defined in
ReputationControl
Ƭ ReputationControl: Object
The data is used to build reputation control.
See
https://developer.unirep.io/docs/circuits-api/circuits#reputation-proof
Type declaration
Name | Type |
---|---|
maxRep | bigint |
minRep | bigint |
proveGraffiti | bigint |
proveMaxRep | bigint |
proveMinRep | bigint |
proveZeroRep | bigint |
Defined in
SignupControl
Ƭ SignupControl: Object
The data is used to build signup control.
See
https://developer.unirep.io/docs/circuits-api/circuits#signup-proof
Type declaration
Name | Type |
---|---|
attesterId | bigint |
chainId | bigint |
epoch | bigint |
Defined in
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
Name | Type |
---|---|
attesterId | bigint |
toEpoch | bigint |
Defined in
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
Name | Type | Default value | Description |
---|---|---|---|
params | EpochKeyControl | undefined | The data is going to be encoded. { nonce , epoch , attesterId , revealNonce , chainId } |
config | CircuitConfig | CircuitConfig.default | The circuit config. Default: CircuitConfig.default |
Returns
bigint
a 253 bits control.
Defined in
buildReputationControl
▸ buildReputationControl(params
, config?
): bigint
Encode data to a 253 bits variable.
Parameters
Name | Type | Default value | Description |
---|---|---|---|
params | ReputationControl | undefined | The data is going to be encoded. { minRep , maxRep , proveMinRep , proveMaxRep , proveZeroRep , proveGraffiti } |
config | CircuitConfig | CircuitConfig.default | The circuit config. Default: CircuitConfig.default |
Returns
bigint
a 253 bits control.
Defined in
buildSignupControl
▸ buildSignupControl(params
, config?
): bigint
Encode data to a 253 bits variable.
Parameters
Name | Type | Default value | Description |
---|---|---|---|
params | SignupControl | undefined | The data is going to be encoded. { attesterId , epoch , chainId } |
config | CircuitConfig | CircuitConfig.default | The circuit config. Default: CircuitConfig.default |
Returns
bigint
a 253 bits control.
Defined in
buildUserStateTransitionControl
▸ buildUserStateTransitionControl(params
, config?
): bigint
Encode data to a 253 bits variable.
Parameters
Name | Type | Default value | Description |
---|---|---|---|
params | UserStateTransitionControl | undefined | The data is going to be encoded. { attesterId , toEpoch } |
config | CircuitConfig | CircuitConfig.default | The circuit config. Default: CircuitConfig.default |
Returns
bigint
a 253 bits control.
Defined in
decodeEpochKeyControl
▸ decodeEpochKeyControl(control
, config?
): EpochKeyControl
Decode the raw control field to desired data.
Parameters
Name | Type | Default value | Description |
---|---|---|---|
control | bigint | undefined | The raw control field generated by genProofAndPublicSignals |
config | CircuitConfig | CircuitConfig.default | The circuit config. Default: CircuitConfig.default |
Returns
{ nonce
, epoch
, attesterId
, revealNonce
, chainId
}
Defined in
decodeReputationControl
▸ decodeReputationControl(control
, config?
): Object
Decode the raw control field to desired data.
Parameters
Name | Type | Default value | Description |
---|---|---|---|
control | bigint | undefined | The raw control field generated by genProofAndPublicSignals |
config | CircuitConfig | CircuitConfig.default | The circuit config. Default: CircuitConfig.default |
Returns
Object
{ minRep
, maxRep
, proveMinRep
, proveMaxRep
, proveZeroRep
, proveGraffiti
}
Name | Type |
---|---|
maxRep | bigint |
minRep | bigint |
proveGraffiti | bigint |
proveMaxRep | bigint |
proveMinRep | bigint |
proveZeroRep | bigint |
Defined in
decodeSignupControl
▸ decodeSignupControl(control
, config?
): SignupControl
Decode the raw control field to desired data.
Parameters
Name | Type | Default value | Description |
---|---|---|---|
control | bigint | undefined | The raw control field generated by genProofAndPublicSignals |
config | CircuitConfig | CircuitConfig.default | The circuit config. Default: CircuitConfig.default |
Returns
{ attesterId
, epoch
, chainId
}
Defined in
decodeUserStateTransitionControl
▸ decodeUserStateTransitionControl(control
, config?
): UserStateTransitionControl
Decode the raw control field to desired data.
Parameters
Name | Type | Default value | Description |
---|---|---|---|
control | bigint | undefined | The raw control field generated by genProofAndPublicSignals |
config | CircuitConfig | CircuitConfig.default | The circuit config. Default: CircuitConfig.default |
Returns
{ attesterId
, toEpoch
}
Defined in
formatProofForSnarkjsVerification
▸ formatProofForSnarkjsVerification(proof
): Groth16Proof
Format an one dimensional array for snarkjs
verification
Parameters
Name | Type | Description |
---|---|---|
proof | Field [] | The string array of the proof |
Returns
Groth16Proof
The SnarkProof
type proof data
Defined in
formatProofForVerifierContract
▸ formatProofForVerifierContract(proof
): string
[]
Format snark proof for verifier smart contract
Parameters
Name | Type | Description |
---|---|---|
proof | Groth16Proof | The proof of SnarkProof type |
Returns
string
[]
An one dimensional array of stringified proof data
Defined in
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
Name | Type | Description |
---|---|---|
data | bigint | The raw data in bigint type. |
shiftBits | bigint | The shifted bits. |
variableBits | bigint | The output data bits. |
Returns
bigint