Unirep procotol package
Client library for protocol related functions which are used in UniRep protocol.
💡 About Unirep
UniRep is a private and non-repudiable data system. Users can receive attestations from attesters, and voluntarily prove facts about their data without revealing the data itself. Moreover, users cannot refuse to receive attestations from an attester.
📘 Documentation
Read the medium article to know more about the concept of Unirep protocol.
For more information, refer to the documentation
🛠 Install
npm or yarn
Install the @unirep/core
package with npm:
npm i @unirep/core
or yarn:
yarn add @unirep/core
📔 Usage
Synchronizer ⏲
Construct a synchronizer
import { Synchronizer } from '@unirep/core'
const address = '0x....'
const provider = 'YOUR/ETH/PROVIDER'
const synchronizer = new Synchronizer({
unirepAddress: address,
provider,
})
await synchronizer.start()
await synchronizer.waitForSync()
synchronizer.stop()
Example: use the synchronizer to generate unirep state
const epoch = 0
const attesterId = 'ATTESTER/ADDRESS'
const stateTree = await synchronizer.genStateTree(epoch, attesterId)
UserState 👤
Construct a user state
import { Identity } from '@semaphore-protocol/identity'
import { UserState } from '@unirep/core'
import { defaultProver } from '@unirep/circuits/provers/defaultProver'
const identity = new Identity()
const userState = new UserState({
unirepAddress: address,
provider,
prover: defaultProver,
id: identity
})
await userState.start()
await userState.waitForSync()
userState.stop()
Example: use the user state to generate proofs
const { publicSignals, proof } = await userState.genUserSignUpProof({ attesterId: attester.address })
const tx = await unirepContract
.connect(attester)
.userSignUp(publicSignals, proof)
await tx.wait()
- Discord server:
- Twitter account:
- Telegram group:
Privacy & Scaling Explorations
This project is supported by Privacy & Scaling Explorations in Ethereum Foundation.
See more projects on: https://appliedzkp.org/.