Skip to main content
Version: 2.0.0-beta-4

schema

UniRep needs to persist data in order to construct state and make proofs. To do this we use a generic database wrapper called anondb. This wrapper has support for desktop environment databases like SQLite, as well as the IndexedDB browser database.

@unirep/core ships a schema that should be used with the database. This schema can be extended by adding additional collections for application specific data storage.

import { schema } from '@unirep/core'
import { SQLiteConnector } from 'anondb/node'
import { IndexedDBConnector } from 'anondb/web'

{
// in nodejs
const db = new SQLiteConnector(schema, ':memory:')
}
{
// in browser
const db = new IndexedDBConnector(schema, 1)
}

SynchronizerState

Used to store information about what blocks/transactions/events have been processed.

{
attesterId: string,
latestProcessedBlock: number
latestProcessedTransactionIndex: number
latestProcessedEventIndex: number
latestCompleteBlock: number
}

Attestation

An attestation given to an epoch key.

{
epoch: number
epochKey: string // base 10
index: string
attesterId: string
fieldIndex: number
change: string
blockNumber: number
}

StateTreeLeaf

A leaf from a state tree.

{
epoch: number
hash: string
index: number
attesterId: string
blockNumber: number
}

EpochTreeLeaf

A leaf from an epoch tree.

{
id: string
epoch: number
hash: string
index: string
attesterId: string
blockNumber: number
}

HistoryTreeLeaf

A leaf from an attester history tree.

{
id: string
index: number
attesterId: string
leaf: string
}

Epoch

An epoch entry.

{
number: number
attesterId: string
sealed: boolean
}

Nullifier

{
epoch: number
attesterId: string
nullifier: string
transactionHash: string
blockNumber: number
}

UserSignUp

An object created when a user joins an attester.

{
commitment: string
epoch: number
attesterId: string
blockNumber: number
}

Attester

An object created when an attester registers with the UniRep instance.

{
_id: string // the attester address
startTimestamp: number
epochLength: number
}