Security News
Introducing the Socket Python SDK
The initial version of the Socket Python SDK is now on PyPI, enabling developers to more easily interact with the Socket REST API in Python projects.
@unirep/core
Advanced tools
Client library for protocol related functions which are used in UniRep protocol.
Client library for protocol related functions which are used in UniRep protocol.
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.
Read the medium article to know more about the concept of Unirep protocol. For more information, refer to the documentation
Install the @unirep/core
package with npm:
npm i @unirep/core
or yarn:
yarn add @unirep/core
Check current deployment: 🤝 Testnet Deployment
Construct a synchronizer
import { Synchronizer } from '@unirep/core'
const address = '0x....'
const provider = 'YOUR/ETH/PROVIDER'
// 1. initialize a synchronizer
const synchronizer = new Synchronizer({
unirepAddress: address,
provider: provider,
})
// 2. start listening to unriep contract events
await synchronizer.start()
// 3. wait until the latest block is processed
await synchronizer.waitForSync()
// 4. stop the synchronizer deamon
synchronizer.stop()
Example: use the synchronizer to generate unirep state
const epoch = 0
const attesterId = 'ATTESTER/ADDRESS' // the msg.sender signs up through `attesterSignUp()`
// e.g.
// const attester = new ethers.Wallet(key, provider)
// const epochLength = 300
// const tx = await unirepContract.connect(attester).attesterSignUp(epochLength)
// await tx.wait()
const stateTree = await synchronizer.genStateTree(epoch, attesterId)
Construct a user state
import { Identity } from '@semaphore-protocol/identity'
import { UserState } from '@unirep/core'
import { defaultProver } from '@unirep/circuits/provers/defaultProver'
// random generate a user identity
const identity = new Identity()
const provider = 'YOUR/ETH/PROVIDER'
const attesterId = 'ATTESTER/ADDRESS' // the msg.sender signs up through `attesterSignUp()`
// 1. initialize a user state object
const userState = new UserState({
unirepAddress: address,
provider: provider,
prover: defaultProver,
id: identity,
attesterId: attesterId,
})
// or through a synchronicr
// const userState = new UserState({synchronizer, id: identity})
// 2. start listening to unriep contract events
await userState.start()
// 3. wait until the latest block is processed
await userState.waitForSync()
// 4. stop the synchronizer deamon
userState.stop()
Generate a database with the schema
import { schema } from '@unirep/core'
import { SQLiteConnector } from 'anondb/node'
import { IndexedDBConnector } from 'anondb/web'
// in nodejs
const db_mem = await SQLiteConnector.create(schema, ':memory:')
const db_storage = await SQLiteConnector.create(schema, 'db.sqlite')
// in browser
const db_browser = await IndexedDBConnector.create(schema)
Use the database in a synchronizer
const synchronizer = new Synchronizer({
unirepAddress: address,
provider: provider,
db: db_storage
})
Example: use the user state to generate proofs
// 1. generate a signup proof of the user
const { publicSignals, proof } = await userState.genUserSignUpProof({ attesterId: attester.address })
// 2. submit the signup proof through the attester
const tx = await unirepContract
.connect(attester)
.userSignUp(publicSignals, proof)
await tx.wait()
This project is supported by Privacy & Scaling Explorations and the Ethereum Foundation. See more projects on: https://pse.dev/.
FAQs
Client library for protocol related functions which are used in UniRep protocol.
The npm package @unirep/core receives a total of 335 weekly downloads. As such, @unirep/core popularity was classified as not popular.
We found that @unirep/core demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
The initial version of the Socket Python SDK is now on PyPI, enabling developers to more easily interact with the Socket REST API in Python projects.
Security News
Floating dependency ranges in npm can introduce instability and security risks into your project by allowing unverified or incompatible versions to be installed automatically, leading to unpredictable behavior and potential conflicts.
Security News
A new Rust RFC proposes "Trusted Publishing" for Crates.io, introducing short-lived access tokens via OIDC to improve security and reduce risks associated with long-lived API tokens.