User state transition
There are three steps in user state transition (see user state transition proof), and they should be performed in order.
Start user state transition
/**
* @dev User submit a start user state transition proof
* publicSignals[0] = [ blindedUserState ]
* publicSignals[1] = [ blindedHashChain ]
* publicSignals[2] = [ globalStateTree ]
* @param publicSignals The public signals of the start user state transition proof
* @param proof The The proof of the start user state transition proof
*/
function startUserStateTransition(
uint256[] memory publicSignals,
uint256[8] memory proof
) external After start user state transition proof event is emitted, the proof will be assign a proof index, which will be attached to updateUserStateRoot function.
The proof index can be queried by proof hash. And the proof hash can be computed by
Generate proof hash from ethers
import ethers from 'ethers'
const proofHash = ethers.utils.solidityKeccak256(
['uint256[]', 'uint256[8]'],
[publicSignals, proof]
)Generate proof hash from @unirep/contracts
import { StartTransitionProof } from '@unirep/contracts'
const proof = new StartTransitionProof(
publicSignals,
proof
)
const proofHash = proof.hash(()Then call the UniRep smart contract to query the proof index
Process attestations
After process attestations proof event is emitted, the proof will be assign a proof index, which will be attached to updateUserStateRoot function.
The proof index can be queried by proof hash. And the proof hash can be computed by
Generate proof hash from ethers
Generate proof hash from @unirep/contracts
Then call the UniRep smart contract to query the proof index
User State Transition
The proofIndexRecords is the proof indexes of all startTransitionProof and processAttestationsProof that are submitted sequentially. See Start user state transition and Process attestations.
Last updated
Was this helpful?