chore: update @unirep/core to 2.0.0-beta-6 (#220)

* chore: update @unirep/core to 2.0.0-beta-6

* fix(core): fix social user state
This commit is contained in:
Ya-wen, Jeng
2023-10-28 07:32:18 -05:00
committed by GitHub
parent c82669cb92
commit 60611c7fe6
26 changed files with 450 additions and 540 deletions

View File

@@ -1,6 +1,6 @@
{
"name": "@unirep-social/backend",
"version": "1.1.0",
"version": "1.1.1",
"description": "",
"scripts": {
"start": "ts-node src/app.ts",
@@ -24,8 +24,8 @@
"typescript": "^4.4.0"
},
"dependencies": {
"@unirep-social/core": "^1.1.0",
"@unirep/core": "2.0.0-beta-4",
"@unirep-social/core": "^1.1.1",
"@unirep/core": "2.0.0-beta-6",
"cors": "^2.8.5",
"dotenv": "^10.0.0",
"express": "^4.17.1",

View File

@@ -7,7 +7,7 @@ const { NUM_EPOCH_KEY_NONCE_PER_EPOCH } = CircuitConfig.default
// Provide default values for process.env
Object.assign(process.env, {
UNIREP: '0x4D137bb44553d55AE6B28B5391c6f537b06C9cc3',
UNIREP: '0xD91ca7eAB8ac0e37681362271DEB11a7fc4e0d4f',
UNIREP_SOCIAL: '0x959922bE3CAee4b8Cd9a407cc3ac1C251C2007B1',
DEFAULT_ETH_PROVIDER_URL: 'http://127.0.0.1:8545',
DEPLOYER_PRIV_KEY:

View File

@@ -143,12 +143,9 @@ async function createComment(req, res) {
)
let graffiti
const replNonceBits = await req.unirep.replNonceBits()
const shiftGraffiti =
BigInt(reputationProof.graffiti) >> BigInt(replNonceBits)
if (reputationProof.graffiti.toString() !== '0') {
graffiti = ethers.utils.toUtf8String(
'0x' + BigInt(shiftGraffiti).toString(16)
'0x' + BigInt(reputationProof.graffiti).toString(16)
)
}
@@ -258,11 +255,9 @@ async function createCommentSubsidy(req, res) {
)
let graffiti
const replNonceBits = await req.unirep.replNonceBits()
const shiftGraffiti = BigInt(subsidyProof.graffiti) >> BigInt(replNonceBits)
if (subsidyProof.graffiti.toString() !== '0') {
graffiti = ethers.utils.toUtf8String(
'0x' + BigInt(shiftGraffiti).toString(16)
'0x' + BigInt(subsidyProof.graffiti).toString(16)
)
}
const comment = await req.db.create('Comment', {

View File

@@ -142,12 +142,9 @@ async function createPost(req, res) {
)
let graffiti
const replNonceBits = await req.unirep.replNonceBits()
const shiftGraffiti =
BigInt(reputationProof.graffiti) >> BigInt(replNonceBits)
if (reputationProof.graffiti.toString() !== '0') {
graffiti = ethers.utils.toUtf8String(
'0x' + BigInt(shiftGraffiti).toString(16)
'0x' + BigInt(reputationProof.graffiti).toString(16)
)
}
@@ -243,11 +240,9 @@ async function createPostSubsidy(req, res) {
)
let graffiti
const replNonceBits = await req.unirep.replNonceBits()
const shiftGraffiti = BigInt(subsidyProof.graffiti) >> BigInt(replNonceBits)
if (subsidyProof.graffiti.toString() !== '0') {
graffiti = ethers.utils.toUtf8String(
'0x' + BigInt(shiftGraffiti).toString(16)
'0x' + BigInt(subsidyProof.graffiti).toString(16)
)
}
const post = await req.db.create('Post', {

View File

@@ -92,9 +92,7 @@ async function setUsername(req, res) {
}
// claim username via Unirep Social contract
const replNonceBits = await req.unirep.replNonceBits()
const currentUsername =
BigInt(usernameProof.graffiti) >> BigInt(replNonceBits)
const currentUsername = BigInt(usernameProof.graffiti)
const calldata = req.unirepSocial.interface.encodeFunctionData(
'setUsername',
[epochKey, currentUsername, hexNewUsername]

View File

@@ -79,12 +79,9 @@ async function vote(req, res) {
let graffiti
let overwriteGraffiti = false
const replNonceBits = await req.unirep.replNonceBits()
const shiftGraffiti =
BigInt(reputationProof.graffiti) >> BigInt(replNonceBits)
if (reputationProof.graffiti.toString() !== '0') {
graffiti = ethers.utils.toUtf8String(
'0x' + BigInt(shiftGraffiti).toString(16)
'0x' + BigInt(reputationProof.graffiti).toString(16)
)
overwriteGraffiti = true
}
@@ -224,12 +221,12 @@ async function voteSubsidy(req, res) {
)
let graffiti
const replNonceBits = await req.unirep.replNonceBits()
const shiftGraffiti = BigInt(subsidyProof.graffiti) >> BigInt(replNonceBits)
let overwriteGraffiti = false
if (subsidyProof.graffiti.toString() !== '0') {
graffiti = ethers.utils.toUtf8String(
'0x' + BigInt(shiftGraffiti).toString(16)
'0x' + BigInt(subsidyProof.graffiti).toString(16)
)
overwriteGraffiti = true
}
const newVote = await req.db.create('Vote', {
@@ -240,7 +237,7 @@ async function voteSubsidy(req, res) {
posRep: upvote,
negRep: downvote,
graffiti,
overwriteGraffiti: false,
overwriteGraffiti,
postId: post ? dataId : '',
commentId: comment ? dataId : '',
status: 0,

View File

@@ -27,23 +27,22 @@ export const genUnirepState = async (
export const genUserState = async (
provider: ethers.providers.Provider,
address: string,
unirepAddress: string,
id: Identity,
unirepSocialAddress: string,
db?: DB
) => {
const synchronizer = await genUnirepState(
const state = new SocialUserState({
unirepAddress,
provider,
address,
unirepSocialAddress,
db
)
return new SocialUserState({
synchronizer,
attesterId: BigInt(unirepSocialAddress),
db,
id,
unirepSocialAddress,
prover: defaultProver,
})
await state.start()
await state.waitForSync()
return state
}
export const waitForBackendBlock = async (t, blockNumber) => {
@@ -70,7 +69,7 @@ export const signUp = async (t) => {
const { publicSignals, proof } = await userState.genUserSignUpProof({
epoch,
})
userState.sync.stop()
userState.stop()
const r = await fetch(`${t.context.url}/api/signup`, {
method: 'POST',
@@ -118,7 +117,7 @@ export const airdrop = async (t, iden) => {
})
const isValid = await actionProof.verify()
expect(isValid).to.be.true
userState.sync.stop()
userState.stop()
const r = await fetch(`${t.context.url}/api/airdrop`, {
method: 'POST',
@@ -152,7 +151,7 @@ export const createPost = async (t, iden) => {
const { publicSignals, proof } = await userState.genActionProof({
spentRep: proveAmount,
})
userState.sync.stop()
userState.stop()
const r = await fetch(`${t.context.url}/api/post`, {
method: 'POST',
headers: {
@@ -193,7 +192,7 @@ export const createPostSubsidy = async (t, iden) => {
})
const isValid = await subsidyProof.verify()
expect(isValid).to.be.true
userState.sync.stop()
userState.stop()
const r = await fetch(`${t.context.url}/api/post/subsidy`, {
method: 'POST',
@@ -235,7 +234,7 @@ export const editPost = async (t, iden, title, content) => {
const { publicSignals, proof } = await userState.genEpochKeyLiteProof({
nonce,
})
userState.sync.stop()
userState.stop()
// we need to wait for the backend to process whatever block our provider is on
const blockNumber = await t.context.provider.getBlockNumber()
@@ -280,7 +279,7 @@ export const deletePost = async (t, iden) => {
const { publicSignals, proof } = await userState.genEpochKeyLiteProof({
nonce,
})
userState.sync.stop()
userState.stop()
// we need to wait for the backend to process whatever block our provider is on
const blockNumber = await t.context.provider.getBlockNumber()
@@ -323,7 +322,7 @@ export const editComment = async (t, iden, postId, content) => {
const { publicSignals, proof } = await userState.genEpochKeyLiteProof({
nonce,
})
userState.sync.stop()
userState.stop()
// we need to wait for the backend to process whatever block our provider is on
const blockNumber = await t.context.provider.getBlockNumber()
@@ -368,7 +367,7 @@ export const deleteComment = async (t, iden, postId) => {
const { publicSignals, proof } = await userState.genEpochKeyLiteProof({
nonce,
})
userState.sync.stop()
userState.stop()
// we need to wait for the backend to process whatever block our provider is on
const blockNumber = await t.context.provider.getBlockNumber()
@@ -436,7 +435,7 @@ export const createComment = async (t, iden, postId) => {
const { publicSignals, proof } = await userState.genActionProof({
spentRep: proveAmount,
})
userState.sync.stop()
userState.stop()
const r = await fetch(`${t.context.url}/api/comment`, {
method: 'POST',
@@ -478,7 +477,7 @@ export const createCommentSubsidy = async (t, iden, postId) => {
})
const isValid = await subsidyProof.verify()
expect(isValid).to.be.true
userState.sync.stop()
userState.stop()
const r = await fetch(`${t.context.url}/api/comment/subsidy`, {
method: 'POST',
@@ -524,7 +523,7 @@ export const vote = async (
const { publicSignals, proof } = await userState.genActionProof({
spentRep: proveAmount,
})
userState.sync.stop()
userState.stop()
const r = await fetch(`${t.context.url}/api/vote`, {
method: 'POST',
@@ -577,7 +576,7 @@ export const voteSubsidy = async (
})
const isValid = await subsidyProof.verify()
expect(isValid).to.be.true
userState.sync.stop()
userState.stop()
const { publicSignals, proof } = subsidyProof
const r = await fetch(`${t.context.url}/api/vote/subsidy`, {
@@ -630,7 +629,7 @@ export const userStateTransition = async (t, iden) => {
const toEpoch = latestEpoch + 1
const results = await userState.genUserStateTransitionProof({ toEpoch })
userState.sync.stop()
userState.stop()
const r = await fetch(`${t.context.url}/api/userStateTransition`, {
method: 'POST',
@@ -676,7 +675,7 @@ export const genUsernameProof = async (t, iden, username) => {
if (!isValid) {
throw new Error('usernameProof is not valid')
}
userState.sync.stop()
userState.stop()
// we need to wait for the backend to process whatever block our provider is on
const blockNumber = await t.context.provider.getBlockNumber()

View File

@@ -7,7 +7,7 @@ pragma circom 2.0.0;
3. compute reputation nullifiers
*/
include "../../../node_modules/@unirep/circuits/circuits/proveReputation.circom";
include "../../../node_modules/@unirep/circuits/circuits/reputation.circom";
include "../../../node_modules/@unirep/circuits/circuits/hasher.circom";
@@ -18,7 +18,7 @@ template ActionProof(STATE_TREE_DEPTH, EPOCH_KEY_NONCE_PER_EPOCH, SUM_FIELD_COUN
// Global state tree leaf: Identity & user state root
signal input identity_secret;
// Global state tree
signal input state_tree_indexes[STATE_TREE_DEPTH];
signal input state_tree_indices[STATE_TREE_DEPTH];
signal input state_tree_elements[STATE_TREE_DEPTH];
signal output state_tree_root;
// Attestation by the attester
@@ -31,6 +31,7 @@ template ActionProof(STATE_TREE_DEPTH, EPOCH_KEY_NONCE_PER_EPOCH, SUM_FIELD_COUN
signal input attester_id;
signal input epoch;
signal input nonce;
signal input chain_id;
// Reputation
signal input min_rep;
signal input max_rep;
@@ -46,28 +47,29 @@ template ActionProof(STATE_TREE_DEPTH, EPOCH_KEY_NONCE_PER_EPOCH, SUM_FIELD_COUN
signal input sig_data;
/* 1. Reputation proof */
(epoch_key, state_tree_root, control) <== ProveReputation(
(epoch_key, state_tree_root, control) <== Reputation(
STATE_TREE_DEPTH,
EPOCH_KEY_NONCE_PER_EPOCH,
SUM_FIELD_COUNT,
FIELD_COUNT,
REPL_NONCE_BITS
)(
identity_secret,
state_tree_indexes,
state_tree_elements,
data,
prove_graffiti,
graffiti,
reveal_nonce,
attester_id,
identity_secret,
state_tree_indices,
state_tree_elements,
data,
prove_graffiti,
graffiti,
reveal_nonce,
attester_id,
epoch,
nonce,
min_rep,
max_rep,
prove_min_rep,
prove_max_rep,
prove_zero_rep,
nonce,
chain_id,
min_rep,
max_rep,
prove_min_rep,
prove_max_rep,
prove_zero_rep,
sig_data
);
/* 2. Prove that user does not control a certain epoch key */
@@ -76,7 +78,13 @@ template ActionProof(STATE_TREE_DEPTH, EPOCH_KEY_NONCE_PER_EPOCH, SUM_FIELD_COUN
signal not_equal_check[EPOCH_KEY_NONCE_PER_EPOCH];
for (var i = 0; i < EPOCH_KEY_NONCE_PER_EPOCH; i++) {
epoch_key_hasher[i] <== EpochKeyHasher()(identity_secret, attester_id, epoch, i);
epoch_key_hasher[i] <== EpochKeyHasher()(
identity_secret,
attester_id,
epoch,
i,
chain_id
);
not_equal_check[i] <== IsEqual()([not_epoch_key, epoch_key_hasher[i]]);
not_equal_check[i] === 0;
}

View File

@@ -1,6 +1,6 @@
{
"name": "@unirep-social/circuits",
"version": "0.0.2",
"version": "0.0.3",
"main": "dist/src/index.js",
"types": "dist/src/index.d.ts",
"description": "ZK proofs used for the unirep social attester",
@@ -21,12 +21,10 @@
},
"devDependencies": {
"mocha": "^10.0.0",
"snarkjs": "^0.4.7",
"ts-node": "^10.9.1",
"typescript": "^4.8.2"
},
"dependencies": {
"@unirep/circuits": "2.0.0-beta-4",
"@unirep/core": "2.0.0-beta-4"
"@unirep/core": "2.0.0-beta-6"
}
}

View File

@@ -15,11 +15,13 @@ const {
} = CircuitConfig.default
const circuit = 'actionProof'
const chainId = 1
const genCircuitInput = (config: {
id: Identity
epoch: number
nonce: number
chainId: number
attesterId: number | bigint
sumField?: (bigint | number)[]
replField?: (bigint | number)[]
@@ -40,6 +42,7 @@ const genCircuitInput = (config: {
id,
epoch,
nonce,
chainId,
attesterId,
sumField,
replField,
@@ -69,7 +72,7 @@ const genCircuitInput = (config: {
const startBalance = [
...sumField,
...Array(SUM_FIELD_COUNT - sumField.length).fill(0),
...replField,
...replField.map((n) => BigInt(n) << BigInt(REPL_NONCE_BITS)),
...Array(FIELD_COUNT - SUM_FIELD_COUNT - replField.length).fill(0),
]
// Global state tree
@@ -78,19 +81,21 @@ const genCircuitInput = (config: {
id.secret,
BigInt(attesterId),
epoch,
startBalance as any
startBalance as any,
chainId
)
stateTree.insert(hashedLeaf)
const stateTreeProof = stateTree.createProof(0) // if there is only one GST leaf, the index is 0
const circuitInputs = {
identity_secret: id.secret,
state_tree_indexes: stateTreeProof.pathIndices,
state_tree_indices: stateTreeProof.pathIndices,
state_tree_elements: stateTreeProof.siblings,
data: startBalance,
graffiti,
epoch,
nonce,
chain_id: chainId,
attester_id: attesterId,
prove_graffiti: proveGraffiti ? 1 : 0,
min_rep: minRep,
@@ -136,11 +141,18 @@ describe('Prove action in Unirep Social', function () {
const epoch = 20
const nonce = 2
const attesterId = BigInt(219090124810)
const epochKey = utils.genEpochKey(id.secret, attesterId, epoch, nonce)
const epochKey = utils.genEpochKey(
id.secret,
attesterId,
epoch,
nonce,
chainId
)
const circuitInputs = genCircuitInput({
id,
epoch,
nonce,
chainId,
attesterId,
})
const { isValid, publicSignals, proof } = await genProofAndVerify(
@@ -162,18 +174,26 @@ describe('Prove action in Unirep Social', function () {
const epoch = 20
const nonce = 2
const attesterId = BigInt(219090124810)
const epochKey = utils.genEpochKey(id.secret, attesterId, epoch, nonce)
const epochKey = utils.genEpochKey(
id.secret,
attesterId,
epoch,
nonce,
chainId
)
const id2 = new Identity()
const notEpochKey = utils.genEpochKey(
id2.secret,
attesterId,
epoch,
nonce
nonce,
chainId
)
const circuitInputs = genCircuitInput({
id,
epoch,
nonce,
chainId,
attesterId,
notEpochKey,
})
@@ -202,12 +222,14 @@ describe('Prove action in Unirep Social', function () {
id.secret,
attesterId,
epoch,
nonce
nonce,
chainId
)
const circuitInputs = genCircuitInput({
id,
epoch,
nonce,
chainId,
attesterId,
revealNonce,
})
@@ -236,6 +258,7 @@ describe('Prove action in Unirep Social', function () {
id,
epoch,
nonce,
chainId,
attesterId,
sumField: [20, 9],
proveMinRep,
@@ -263,6 +286,7 @@ describe('Prove action in Unirep Social', function () {
id,
epoch,
nonce,
chainId,
attesterId,
sumField: [9, 20],
proveMinRep,
@@ -286,6 +310,7 @@ describe('Prove action in Unirep Social', function () {
id,
epoch,
nonce,
chainId,
attesterId,
sumField: [9, 20],
proveMaxRep,
@@ -313,6 +338,7 @@ describe('Prove action in Unirep Social', function () {
id,
epoch,
nonce,
chainId,
attesterId,
sumField: [20, 9],
proveMaxRep,
@@ -335,6 +361,7 @@ describe('Prove action in Unirep Social', function () {
id,
epoch,
nonce,
chainId,
attesterId,
proveZeroRep,
})
@@ -359,6 +386,7 @@ describe('Prove action in Unirep Social', function () {
id,
epoch,
nonce,
chainId,
attesterId,
replField: [graffiti],
graffiti,
@@ -387,6 +415,7 @@ describe('Prove action in Unirep Social', function () {
id,
epoch,
nonce,
chainId,
attesterId,
sumField: [9, 20],
replField: [graffiti],
@@ -411,6 +440,7 @@ describe('Prove action in Unirep Social', function () {
id,
epoch,
nonce,
chainId,
attesterId,
sumField: [20, 9],
spentRep,
@@ -448,6 +478,7 @@ describe('Prove action in Unirep Social', function () {
id,
epoch,
nonce,
chainId,
attesterId,
sumField: [20, 9],
spentRep,
@@ -470,6 +501,7 @@ describe('Prove action in Unirep Social', function () {
id,
epoch,
nonce,
chainId,
attesterId,
sumField: [10, 9],
spentRep,
@@ -492,6 +524,7 @@ describe('Prove action in Unirep Social', function () {
id,
epoch,
nonce,
chainId,
attesterId,
sumField: [9, 20],
spentRep,
@@ -515,6 +548,7 @@ describe('Prove action in Unirep Social', function () {
id,
epoch,
nonce,
chainId,
attesterId,
sumField: [9, 20],
maxRep,
@@ -538,12 +572,14 @@ describe('Prove action in Unirep Social', function () {
id.secret,
attesterId,
epoch,
i
i,
chainId
)
const circuitInputs = genCircuitInput({
id,
epoch,
nonce,
chainId,
attesterId,
sumField: [9, 20],
notEpochKey,

File diff suppressed because one or more lines are too long

View File

@@ -119,19 +119,20 @@ contract UnirepSocial {
struct ActionSignals {
uint256 epochKey;
uint256 stateTreeRoot;
uint256 minRep;
uint256 maxRep;
uint256 graffiti;
bool proveGraffiti;
uint256 data;
uint256 notEpochKey;
uint160 attesterId;
uint8 nonce;
uint48 epoch;
uint48 chainId;
uint8 nonce;
bool revealNonce;
bool proveMinRep;
bool proveMaxRep;
bool proveZeroRep;
uint256 minRep;
uint256 maxRep;
uint256 notEpochKey;
uint256 data;
bool proveGraffiti;
uint256[] nullifiers;
}
@@ -252,10 +253,11 @@ contract UnirepSocial {
signals.epochKey = publicSignals[0];
signals.stateTreeRoot = publicSignals[1];
(
signals.revealNonce,
signals.attesterId,
signals.nonce,
signals.epoch,
signals.nonce
signals.attesterId,
signals.revealNonce,
signals.chainId
) = epkHelper.decodeEpochKeyControl(publicSignals[2]);
(
signals.minRep,

View File

@@ -32,10 +32,15 @@ const deployUnirepSocial = async (
maxReputationBudget: maxReputationBudget,
..._settings,
}
const epkHelper = await deployVerifierHelper(deployer, Circuit.epochKeyLite)
const repHelper = await deployVerifierHelper(
const epkHelper = await deployVerifierHelper(
UnirepAddr,
deployer,
Circuit.proveReputation
Circuit.epochKeyLite
)
const repHelper = await deployVerifierHelper(
UnirepAddr,
deployer,
Circuit.reputation
)
console.log('Deploying ActionVerifier')
const _ActionVerifierF = new ethers.ContractFactory(

View File

@@ -1,6 +1,6 @@
{
"name": "@unirep-social/core",
"version": "1.1.0",
"version": "1.1.1",
"description": "",
"main": "build/src/index.js",
"scripts": {
@@ -39,12 +39,10 @@
"typechain": "^8.1.1"
},
"dependencies": {
"@openzeppelin/contracts": "^4.8.1",
"@unirep-social/circuits": "^0.0.2",
"@unirep/core": "2.0.0-beta-4",
"@unirep-social/circuits": "^0.0.3",
"@unirep/core": "2.0.0-beta-6",
"argparse": "^2.0.1",
"dotenv": "^10.0.0",
"ethers": "^5.6.8",
"path-browserify": "^1.0.1",
"typescript": "^4.9.5"
}

View File

@@ -1,6 +1,6 @@
import { ActionProof, REP_BUDGET } from '@unirep-social/circuits'
import { Prover } from '@unirep/circuits'
import { Synchronizer, UserState } from '@unirep/core'
import { UserState } from '@unirep/core'
import { stringifyBigInts } from '@unirep/utils'
import { Identity } from '@semaphore-protocol/identity'
import { poseidon4 } from 'poseidon-lite'
@@ -13,18 +13,18 @@ export class SocialUserState extends UserState {
public maxReputationBudget: number
constructor(config: {
synchronizer?: Synchronizer
db?: DB
attesterId?: bigint | bigint[]
unirepAddress?: string
provider?: ethers.providers.Provider
attesterId: bigint
unirepAddress: string
provider: ethers.providers.Provider
id: Identity
prover: Prover
unirepSocialAddress: string
}) {
super(config)
const unirepSocialAddress =
'0x' + BigInt(config.attesterId)?.toString(16).padStart(40, '0')
this.unirepSocial = new ethers.Contract(
config.unirepSocialAddress,
unirepSocialAddress,
UNIREP_SOCIAL_ABI,
this.sync.provider
)
@@ -32,7 +32,7 @@ export class SocialUserState extends UserState {
}
async start() {
super.sync.start()
await super.start()
this.maxReputationBudget = (
await this.unirepSocial.maxReputationBudget()
).toNumber()
@@ -123,14 +123,13 @@ export class SocialUserState extends UserState {
const circuitInputs = {
identity_secret: this.id.secret,
state_tree_indexes: stateTreeProof.pathIndices,
state_tree_indices: stateTreeProof.pathIndices,
state_tree_elements: stateTreeProof.siblings,
data,
graffiti: graffiti
? BigInt(graffiti) << BigInt(this.sync.settings.replNonceBits)
: 0,
graffiti: graffiti ?? 0,
epoch,
nonce,
chain_id: this.chainId,
attester_id: this.sync.attesterId.toString(),
prove_graffiti: graffiti ? 1 : 0,
min_rep: minRep ?? 0,

View File

@@ -15,6 +15,7 @@ describe('Subsidy Airdrop', function () {
let unirepSocialContract: UnirepSocial
let admin
let attesterId
let chainId
const id = new Identity()
const epkNonce = 0
@@ -24,6 +25,8 @@ describe('Subsidy Airdrop', function () {
before(async () => {
const accounts = await ethers.getSigners()
admin = accounts[0]
const network = await accounts[0].provider.getNetwork()
chainId = network.chainId
unirepContract = await deployUnirep(admin)
unirepSocialContract = await deployUnirepSocial(
@@ -50,7 +53,13 @@ describe('Subsidy Airdrop', function () {
// user 1 epoch key
const epoch = await unirepContract.attesterCurrentEpoch(attesterId)
const nonce = 0
const epochKey = genEpochKey(id.secret, attesterId, epoch, nonce)
const epochKey = genEpochKey(
id.secret,
attesterId,
epoch,
nonce,
chainId
)
// sign up another user and vote
{
@@ -86,7 +95,7 @@ describe('Subsidy Airdrop', function () {
voteProof.proof
)
.then((t) => t.wait())
userState2.sync.stop()
userState2.stop()
}
// epoch transition
@@ -106,7 +115,7 @@ describe('Subsidy Airdrop', function () {
.userStateTransition(publicSignals, proof)
.then((t) => t.wait())
}
userState.sync.stop()
userState.stop()
})
{
@@ -165,7 +174,7 @@ describe('Subsidy Airdrop', function () {
await expect(tx)
.to.emit(unirepContract, 'Attestation')
.withArgs(epoch, epochKey, attesterId, posRepField, downvote)
userState.sync.stop()
userState.stop()
})
it('submit airdrop subsidy without revealing epoch key nonce should fail', async () => {
@@ -184,7 +193,7 @@ describe('Subsidy Airdrop', function () {
await expect(
unirepSocialContract.getSubsidyAirdrop(publicSignals, proof)
).to.be.revertedWith('Unirep Social: epoch key nonce is not valid')
userState.sync.stop()
userState.stop()
})
it('submit airdrop subsidy with wrong epoch key nonce should fail', async () => {
@@ -203,7 +212,7 @@ describe('Subsidy Airdrop', function () {
await expect(
unirepSocialContract.getSubsidyAirdrop(publicSignals, proof)
).to.be.revertedWith('Unirep Social: epoch key nonce is not valid')
userState.sync.stop()
userState.stop()
})
it('submit airdrop subsidy without prove max rep flag should fail', async () => {
@@ -222,7 +231,7 @@ describe('Subsidy Airdrop', function () {
await expect(
unirepSocialContract.getSubsidyAirdrop(publicSignals, proof)
).to.be.revertedWith('Unirep Social: should prove max reputation')
userState.sync.stop()
userState.stop()
})
it('submit airdrop subsidy with the same proof should fail', async () => {
@@ -243,7 +252,7 @@ describe('Subsidy Airdrop', function () {
await expect(
unirepSocialContract.getSubsidyAirdrop(publicSignals, proof)
).to.be.revertedWith('Unirep Social: the proof is submitted before')
userState.sync.stop()
userState.stop()
})
it('submit airdrop subsidy with the invalid proof should fail', async () => {
@@ -262,7 +271,7 @@ describe('Subsidy Airdrop', function () {
await expect(
unirepSocialContract.getSubsidyAirdrop(publicSignals, proof)
).to.be.revertedWith('Unirep Social: proof is invalid')
userState.sync.stop()
userState.stop()
})
it('submit airdrop subsidy with the invalid state tree root should fail', async () => {
@@ -277,11 +286,11 @@ describe('Subsidy Airdrop', function () {
epkNonce,
revealNonce,
})
publicSignals[idx.stateTreeRoot] = '1234'
publicSignals[idx.stateTreeRoot] = BigInt(1234)
await expect(
unirepSocialContract.getSubsidyAirdrop(publicSignals, proof)
).to.be.revertedWith('Unirep Social: GST root does not exist in epoch')
userState.sync.stop()
userState.stop()
})
it('submit airdrop subsidy with the wrong epoch should fail', async () => {
@@ -291,7 +300,7 @@ describe('Subsidy Airdrop', function () {
id,
attesterId
)
const wrongEpoch = 0
const wrongEpoch = BigInt(0)
const proof = await userState.genActionProof({
maxRep: downvote,
epkNonce,
@@ -301,8 +310,9 @@ describe('Subsidy Airdrop', function () {
const wrongEpochControl = EpochKeyProof.buildControl({
attesterId: BigInt(unirepSocialContract.address),
epoch: wrongEpoch,
nonce: epkNonce,
revealNonce,
nonce: BigInt(epkNonce),
revealNonce: BigInt(revealNonce),
chainId: BigInt(chainId),
})
proof.publicSignals[proof.idx.stateTreeRoot] = stateTree.root.toString()
proof.publicSignals[proof.idx.control0] = wrongEpochControl
@@ -312,7 +322,7 @@ describe('Subsidy Airdrop', function () {
proof.proof
)
).to.be.revertedWith('Unirep Social: epoch mismatches')
userState.sync.stop()
userState.stop()
})
it('submit post subsidy with the wrong attester ID should fail', async () => {
@@ -330,8 +340,9 @@ describe('Subsidy Airdrop', function () {
const wrongControl = EpochKeyProof.buildControl({
attesterId: BigInt(1234),
epoch: proof.epoch,
nonce: epkNonce,
revealNonce,
nonce: BigInt(epkNonce),
revealNonce: BigInt(revealNonce),
chainId: BigInt(chainId),
})
proof.publicSignals[proof.idx.control0] = wrongControl
await expect(
@@ -340,7 +351,7 @@ describe('Subsidy Airdrop', function () {
proof.proof
)
).to.be.revertedWith('Unirep Social: attesterId mismatches')
userState.sync.stop()
userState.stop()
})
it('requesting airdrop subsidy twice should fail', async () => {
@@ -376,6 +387,6 @@ describe('Subsidy Airdrop', function () {
unirepSocialContract.getSubsidyAirdrop(publicSignals, proof)
).to.be.revertedWith('Unirep Social: requesting too much subsidy')
}
userState.sync.stop()
userState.stop()
})
})

View File

@@ -15,6 +15,7 @@ describe('Comment', function () {
let unirepSocialContract: UnirepSocial
let admin
let attesterId
let chainId
const id = new Identity()
const content = 'some post text'
const hashedContent = ethers.utils.keccak256(
@@ -29,6 +30,8 @@ describe('Comment', function () {
before(async () => {
const accounts = await ethers.getSigners()
admin = accounts[0]
const network = await accounts[0].provider.getNetwork()
chainId = network.chainId
unirepContract = await deployUnirep(admin)
unirepSocialContract = await deployUnirepSocial(
@@ -59,7 +62,13 @@ describe('Comment', function () {
// user 1 epoch key
const epoch = await unirepContract.attesterCurrentEpoch(attesterId)
const nonce = 0
const epochKey = genEpochKey(id.secret, attesterId, epoch, nonce)
const epochKey = genEpochKey(
id.secret,
attesterId,
epoch,
nonce,
chainId
)
// sign up another user and vote
{
@@ -97,7 +106,7 @@ describe('Comment', function () {
voteProof.proof
)
.then((t) => t.wait())
userState2.sync.stop()
userState2.stop()
}
// epoch transition
@@ -129,7 +138,7 @@ describe('Comment', function () {
.publishPost(hashedContent, publicSignals, proof)
.then((t) => t.wait())
}
userState.sync.stop()
userState.stop()
})
{
@@ -162,7 +171,7 @@ describe('Comment', function () {
await expect(tx)
.to.emit(unirepSocialContract, 'CommentSubmitted')
.withArgs(epoch, postId, epochKey, commentId, hashedContent, 0)
userState.sync.stop()
userState.stop()
})
it('submit comment with min rep should succeed', async () => {
@@ -188,7 +197,7 @@ describe('Comment', function () {
await expect(tx)
.to.emit(unirepSocialContract, 'CommentSubmitted')
.withArgs(epoch, postId, epochKey, commentId, hashedContent, minRep)
userState.sync.stop()
userState.stop()
})
it('submit comment with different amount of nullifiers should fail', async () => {
@@ -211,7 +220,7 @@ describe('Comment', function () {
proof
)
).to.be.revertedWith('Unirep Social: invalid rep nullifier')
userState.sync.stop()
userState.stop()
})
it('submit comment with the same proof should fail', async () => {
@@ -235,7 +244,7 @@ describe('Comment', function () {
proof
)
).to.be.revertedWith('Unirep Social: the proof is submitted before')
userState.sync.stop()
userState.stop()
})
it('submit comment with the invalid proof should fail', async () => {
@@ -257,7 +266,7 @@ describe('Comment', function () {
proof
)
).to.be.revertedWith('Unirep Social: proof is invalid')
userState.sync.stop()
userState.stop()
})
it('submit comment with the invalid state tree root should fail', async () => {
@@ -270,7 +279,7 @@ describe('Comment', function () {
const { publicSignals, proof, idx } = await userState.genActionProof({
spentRep: commentReputation,
})
publicSignals[idx.stateTreeRoot] = '1234'
publicSignals[idx.stateTreeRoot] = BigInt(1234)
await expect(
unirepSocialContract.leaveComment(
postId,
@@ -279,7 +288,7 @@ describe('Comment', function () {
proof
)
).to.be.revertedWith('Unirep Social: GST root does not exist in epoch')
userState.sync.stop()
userState.stop()
})
it('submit comment with the wrong epoch should fail', async () => {
@@ -296,9 +305,10 @@ describe('Comment', function () {
const stateTree = await userState.sync.genStateTree(wrongEpoch)
const wrongEpochControl = EpochKeyProof.buildControl({
attesterId: BigInt(unirepSocialContract.address),
epoch: wrongEpoch,
nonce: 0,
revealNonce: 0,
epoch: BigInt(wrongEpoch),
nonce: BigInt(0),
revealNonce: BigInt(0),
chainId: BigInt(chainId),
})
publicSignals[idx.stateTreeRoot] = stateTree.root.toString()
publicSignals[idx.control0] = wrongEpochControl
@@ -310,7 +320,7 @@ describe('Comment', function () {
proof
)
).to.be.revertedWith('Unirep Social: epoch mismatches')
userState.sync.stop()
userState.stop()
})
it('submit comment with the wrong attester ID should fail', async () => {
@@ -326,8 +336,9 @@ describe('Comment', function () {
const wrongControl = EpochKeyProof.buildControl({
attesterId: BigInt(1234),
epoch: epoch,
nonce: 0,
revealNonce: 0,
nonce: BigInt(0),
revealNonce: BigInt(0),
chainId: BigInt(chainId),
})
publicSignals[idx.control0] = wrongControl
await expect(
@@ -338,7 +349,7 @@ describe('Comment', function () {
proof
)
).to.be.revertedWith('Unirep Social: attesterId mismatches')
userState.sync.stop()
userState.stop()
})
it('submit comment with the wrong post ID should fail', async () => {
@@ -361,7 +372,7 @@ describe('Comment', function () {
proof
)
).to.be.revertedWith('Unirep Social: post ID is invalid')
userState.sync.stop()
userState.stop()
})
it('submit comment subisy should succeed', async () => {
@@ -382,7 +393,7 @@ describe('Comment', function () {
await expect(tx)
.to.emit(unirepSocialContract, 'CommentSubmitted')
.withArgs(epoch, postId, epochKey, commentId, hashedContent, minRep)
userState.sync.stop()
userState.stop()
})
it('submit comment subsidy with min rep should succeed', async () => {
@@ -405,7 +416,7 @@ describe('Comment', function () {
await expect(tx)
.to.emit(unirepSocialContract, 'CommentSubmitted')
.withArgs(epoch, postId, epochKey, commentId, hashedContent, minRep)
userState.sync.stop()
userState.stop()
})
it('submit comment subsidy without revealing epoch key nonce should fail', async () => {
@@ -428,7 +439,7 @@ describe('Comment', function () {
proof
)
).to.be.revertedWith('Unirep Social: epoch key nonce is not valid')
userState.sync.stop()
userState.stop()
})
it('submit comment subsidy with wrong epoch key nonce should fail', async () => {
@@ -451,7 +462,7 @@ describe('Comment', function () {
proof
)
).to.be.revertedWith('Unirep Social: epoch key nonce is not valid')
userState.sync.stop()
userState.stop()
})
it('submit comment subsidy with the same proof should fail', async () => {
@@ -476,7 +487,7 @@ describe('Comment', function () {
proof
)
).to.be.revertedWith('Unirep Social: the proof is submitted before')
userState.sync.stop()
userState.stop()
})
it('submit comment subsidy with the invalid proof should fail', async () => {
@@ -499,7 +510,7 @@ describe('Comment', function () {
proof
)
).to.be.revertedWith('Unirep Social: proof is invalid')
userState.sync.stop()
userState.stop()
})
it('submit comment with the invalid state tree root should fail', async () => {
@@ -512,7 +523,7 @@ describe('Comment', function () {
const { publicSignals, proof, idx } = await userState.genActionProof({
spentRep: commentReputation,
})
publicSignals[idx.stateTreeRoot] = '1234'
publicSignals[idx.stateTreeRoot] = BigInt(1234)
await expect(
unirepSocialContract.leaveComment(
postId,
@@ -521,7 +532,7 @@ describe('Comment', function () {
proof
)
).to.be.revertedWith('Unirep Social: GST root does not exist in epoch')
userState.sync.stop()
userState.stop()
})
it('submit comment subsidy with the wrong epoch should fail', async () => {
@@ -539,9 +550,10 @@ describe('Comment', function () {
const stateTree = await userState.sync.genStateTree(wrongEpoch)
const wrongEpochControl = EpochKeyProof.buildControl({
attesterId: BigInt(unirepSocialContract.address),
epoch: wrongEpoch,
nonce: epkNonce,
revealNonce,
epoch: BigInt(wrongEpoch),
nonce: BigInt(epkNonce),
revealNonce: BigInt(revealNonce),
chainId: BigInt(chainId),
})
publicSignals[idx.stateTreeRoot] = stateTree.root.toString()
publicSignals[idx.control0] = wrongEpochControl
@@ -553,7 +565,7 @@ describe('Comment', function () {
proof
)
).to.be.revertedWith('Unirep Social: epoch mismatches')
userState.sync.stop()
userState.stop()
})
it('submit comment subsidy with the wrong attester ID should fail', async () => {
@@ -569,8 +581,9 @@ describe('Comment', function () {
const wrongControl = EpochKeyProof.buildControl({
attesterId: BigInt(1234),
epoch: epoch,
nonce: epkNonce,
revealNonce,
nonce: BigInt(epkNonce),
revealNonce: BigInt(revealNonce),
chainId: BigInt(chainId),
})
publicSignals[idx.control0] = wrongControl
await expect(
@@ -581,7 +594,7 @@ describe('Comment', function () {
proof
)
).to.be.revertedWith('Unirep Social: attesterId mismatches')
userState.sync.stop()
userState.stop()
})
it('submit comment subsidy with the wrong post ID should fail', async () => {
@@ -605,7 +618,7 @@ describe('Comment', function () {
proof
)
).to.be.revertedWith('Unirep Social: post ID is invalid')
userState.sync.stop()
userState.stop()
})
it('requesting too much subsidy should fail', async () => {
@@ -646,6 +659,6 @@ describe('Comment', function () {
proof
)
).to.be.revertedWith('Unirep Social: requesting too much subsidy')
userState.sync.stop()
userState.stop()
})
})

View File

@@ -13,6 +13,7 @@ describe('Edit', function () {
let unirepContract: Unirep
let unirepSocialContract: UnirepSocial
let attesterId
let chainId
const id = new Identity()
const content = 'some post text'
const newContent = 'new post text'
@@ -27,6 +28,8 @@ describe('Edit', function () {
before(async () => {
const accounts = await ethers.getSigners()
const admin = accounts[0]
const network = await accounts[0].provider.getNetwork()
chainId = network.chainId
unirepContract = await deployUnirep(admin)
unirepSocialContract = await deployUnirepSocial(
@@ -54,7 +57,13 @@ describe('Edit', function () {
// user 1 epoch key
const epoch = await unirepContract.attesterCurrentEpoch(attesterId)
const nonce = 0
const epochKey = genEpochKey(id.secret, attesterId, epoch, nonce)
const epochKey = genEpochKey(
id.secret,
attesterId,
epoch,
nonce,
chainId
)
// sign up another user and vote
{
@@ -92,7 +101,7 @@ describe('Edit', function () {
voteProof.proof
)
.then((t) => t.wait())
userState2.sync.stop()
userState2.stop()
}
// epoch transition
@@ -141,7 +150,7 @@ describe('Edit', function () {
)
}
userState.sync.stop()
userState.stop()
})
{
@@ -168,7 +177,7 @@ describe('Edit', function () {
const isValid = await proof.verify()
expect(isValid).to.be.true
userState.sync.stop()
userState.stop()
})
it('edit a post should succeed', async () => {
@@ -190,7 +199,7 @@ describe('Edit', function () {
await expect(tx)
.to.emit(unirepSocialContract, 'ContentUpdated')
.withArgs(postId, hashedContent, newHashedContent)
userState.sync.stop()
userState.stop()
})
it('edit a post with the same proof should fail', async () => {
@@ -214,7 +223,7 @@ describe('Edit', function () {
proof
)
).to.be.revertedWith('Unirep Social: the proof is submitted before')
userState.sync.stop()
userState.stop()
})
it('edit a post with invalid content id should fail', async () => {
@@ -236,7 +245,7 @@ describe('Edit', function () {
proof
)
).to.be.revertedWith('Unirep Social: content ID is invalid')
userState.sync.stop()
userState.stop()
})
it('edit a post with the wrong epoch key should fail', async () => {
@@ -262,7 +271,7 @@ describe('Edit', function () {
).to.be.revertedWith(
'Unirep Social: Mismatched epoch key proof to the post or the comment id'
)
userState.sync.stop()
userState.stop()
})
it('edit a post with the invalid proof should fail', async () => {
@@ -284,6 +293,6 @@ describe('Edit', function () {
proof
)
).to.be.revertedWithCustomError(unirepContract, 'InvalidProof')
userState.sync.stop()
userState.stop()
})
})

View File

@@ -15,6 +15,7 @@ describe('Post', function () {
let unirepSocialContract: UnirepSocial
let admin
let attesterId
let chainId
const id = new Identity()
const content = 'some post text'
const hashedContent = ethers.utils.keccak256(
@@ -28,6 +29,8 @@ describe('Post', function () {
before(async () => {
const accounts = await ethers.getSigners()
admin = accounts[0]
const network = await accounts[0].provider.getNetwork()
chainId = network.chainId
unirepContract = await deployUnirep(admin)
unirepSocialContract = await deployUnirepSocial(
@@ -57,7 +60,13 @@ describe('Post', function () {
// user 1 epoch key
const epoch = await unirepContract.attesterCurrentEpoch(attesterId)
const nonce = 0
const epochKey = genEpochKey(id.secret, attesterId, epoch, nonce)
const epochKey = genEpochKey(
id.secret,
attesterId,
epoch,
nonce,
chainId
)
// sign up another user and vote
{
@@ -95,7 +104,7 @@ describe('Post', function () {
voteProof.proof
)
.then((t) => t.wait())
userState2.sync.stop()
userState2.stop()
}
// epoch transition
@@ -115,7 +124,7 @@ describe('Post', function () {
.userStateTransition(publicSignals, proof)
.then((t) => t.wait())
}
userState.sync.stop()
userState.stop()
})
{
@@ -170,7 +179,7 @@ describe('Post', function () {
await expect(tx)
.to.emit(unirepSocialContract, 'PostSubmitted')
.withArgs(epoch, postId, epochKey, hashedContent, 0)
userState.sync.stop()
userState.stop()
})
it('submit post with min rep should succeed', async () => {
@@ -192,7 +201,7 @@ describe('Post', function () {
await expect(tx)
.to.emit(unirepSocialContract, 'PostSubmitted')
.withArgs(epoch, postId, epochKey, hashedContent, minRep)
userState.sync.stop()
userState.stop()
})
it('submit post with different amount of nullifiers should fail', async () => {
@@ -214,7 +223,7 @@ describe('Post', function () {
proof
)
).to.be.revertedWith('Unirep Social: invalid rep nullifier')
userState.sync.stop()
userState.stop()
})
it('submit post with the same proof should fail', async () => {
@@ -237,7 +246,7 @@ describe('Post', function () {
proof
)
).to.be.revertedWith('Unirep Social: the proof is submitted before')
userState.sync.stop()
userState.stop()
})
it('submit post with the invalid proof should fail', async () => {
@@ -258,7 +267,7 @@ describe('Post', function () {
proof
)
).to.be.revertedWith('Unirep Social: proof is invalid')
userState.sync.stop()
userState.stop()
})
it('submit post with the invalid state tree root should fail', async () => {
@@ -279,7 +288,7 @@ describe('Post', function () {
proof
)
).to.be.revertedWith('Unirep Social: GST root does not exist in epoch')
userState.sync.stop()
userState.stop()
})
it('submit post with the wrong epoch should fail', async () => {
@@ -296,9 +305,10 @@ describe('Post', function () {
const stateTree = await userState.sync.genStateTree(wrongEpoch)
const wrongEpochControl = EpochKeyProof.buildControl({
attesterId: BigInt(unirepSocialContract.address),
epoch: wrongEpoch,
nonce: 0,
revealNonce: 0,
epoch: BigInt(wrongEpoch),
nonce: BigInt(0),
revealNonce: BigInt(0),
chainId: BigInt(chainId),
})
proof.publicSignals[proof.idx.stateTreeRoot] = stateTree.root.toString()
proof.publicSignals[proof.idx.control0] = wrongEpochControl
@@ -309,7 +319,7 @@ describe('Post', function () {
proof.proof
)
).to.be.revertedWith('Unirep Social: epoch mismatches')
userState.sync.stop()
userState.stop()
})
it('submit post with the wrong attester ID should fail', async () => {
@@ -326,8 +336,9 @@ describe('Post', function () {
const wrongControl = EpochKeyProof.buildControl({
attesterId: BigInt(1234),
epoch: proof.epoch,
nonce: 0,
revealNonce: 0,
nonce: BigInt(0),
revealNonce: BigInt(0),
chainId: BigInt(chainId),
})
proof.publicSignals[proof.idx.control0] = wrongControl
await expect(
@@ -337,7 +348,7 @@ describe('Post', function () {
proof.proof
)
).to.be.revertedWith('Unirep Social: attesterId mismatches')
userState.sync.stop()
userState.stop()
})
it('subsidy proof should be verified valid off-chain and on-chain', async () => {
@@ -380,7 +391,7 @@ describe('Post', function () {
await expect(tx)
.to.emit(unirepSocialContract, 'PostSubmitted')
.withArgs(epoch, postId, epochKey, hashedContent, minRep)
userState.sync.stop()
userState.stop()
})
it('submit post subsidy with min rep should succeed', async () => {
@@ -402,7 +413,7 @@ describe('Post', function () {
await expect(tx)
.to.emit(unirepSocialContract, 'PostSubmitted')
.withArgs(epoch, postId, epochKey, hashedContent, minRep)
userState.sync.stop()
userState.stop()
})
it('submit post subsidy without revealing epoch key nonce should fail', async () => {
@@ -424,7 +435,7 @@ describe('Post', function () {
proof
)
).to.be.revertedWith('Unirep Social: epoch key nonce is not valid')
userState.sync.stop()
userState.stop()
})
it('submit post subsidy with wrong epoch key nonce should fail', async () => {
@@ -446,7 +457,7 @@ describe('Post', function () {
proof
)
).to.be.revertedWith('Unirep Social: epoch key nonce is not valid')
userState.sync.stop()
userState.stop()
})
it('submit post subsidy with the same proof should fail', async () => {
@@ -470,7 +481,7 @@ describe('Post', function () {
proof
)
).to.be.revertedWith('Unirep Social: the proof is submitted before')
userState.sync.stop()
userState.stop()
})
it('submit post subsidy with the invalid proof should fail', async () => {
@@ -492,7 +503,7 @@ describe('Post', function () {
proof
)
).to.be.revertedWith('Unirep Social: proof is invalid')
userState.sync.stop()
userState.stop()
})
it('submit post subsidy with the invalid state tree root should fail', async () => {
@@ -514,7 +525,7 @@ describe('Post', function () {
proof
)
).to.be.revertedWith('Unirep Social: GST root does not exist in epoch')
userState.sync.stop()
userState.stop()
})
it('submit post subsidy with the wrong epoch should fail', async () => {
@@ -532,9 +543,10 @@ describe('Post', function () {
const stateTree = await userState.sync.genStateTree(wrongEpoch)
const wrongEpochControl = EpochKeyProof.buildControl({
attesterId: BigInt(unirepSocialContract.address),
epoch: wrongEpoch,
nonce: epkNonce,
revealNonce,
epoch: BigInt(wrongEpoch),
nonce: BigInt(epkNonce),
revealNonce: BigInt(revealNonce),
chainId: BigInt(chainId),
})
proof.publicSignals[proof.idx.stateTreeRoot] = stateTree.root.toString()
proof.publicSignals[proof.idx.control0] = wrongEpochControl
@@ -545,7 +557,7 @@ describe('Post', function () {
proof.proof
)
).to.be.revertedWith('Unirep Social: epoch mismatches')
userState.sync.stop()
userState.stop()
})
it('submit post subsidy with the wrong attester ID should fail', async () => {
@@ -563,8 +575,9 @@ describe('Post', function () {
const wrongControl = EpochKeyProof.buildControl({
attesterId: BigInt(1234),
epoch: proof.epoch,
nonce: epkNonce,
revealNonce,
nonce: BigInt(epkNonce),
revealNonce: BigInt(revealNonce),
chainId: BigInt(chainId),
})
proof.publicSignals[proof.idx.control0] = wrongControl
await expect(
@@ -574,7 +587,7 @@ describe('Post', function () {
proof.proof
)
).to.be.revertedWith('Unirep Social: attesterId mismatches')
userState.sync.stop()
userState.stop()
})
it('requesting too much subsidy should fail', async () => {
@@ -607,6 +620,6 @@ describe('Post', function () {
proof
)
).to.be.revertedWith('Unirep Social: requesting too much subsidy')
userState.sync.stop()
userState.stop()
})
})

View File

@@ -16,11 +16,14 @@ describe('Username', function () {
let unirepSocialContract: UnirepSocial
let admin
let attesterId
let chainId
const id = new Identity()
before(async () => {
const accounts = await ethers.getSigners()
admin = accounts[0]
const network = await accounts[0].provider.getNetwork()
chainId = network.chainId
unirepContract = await deployUnirep(admin)
unirepSocialContract = await deployUnirepSocial(
@@ -44,7 +47,7 @@ describe('Username', function () {
.connect(admin)
.userSignUp(publicSignals, proof)
.then((t) => t.wait())
userState.sync.stop()
userState.stop()
}
})
@@ -153,7 +156,13 @@ describe('Username', function () {
)
const epoch = 0
const nonce = 0
const epochKey = genEpochKey(id.secret, attesterId, epoch, nonce)
const epochKey = genEpochKey(
id.secret,
attesterId,
epoch,
nonce,
chainId
)
const oldUsername = 0
const username10 = 'username2'
const username16 = ethers.utils.hexlify(
@@ -199,7 +208,7 @@ describe('Username', function () {
voteProof.proof
)
.then((t) => t.wait())
userState2.sync.stop()
userState2.stop()
}
// epoch transition

View File

@@ -14,6 +14,7 @@ describe('Vote', function () {
let unirepSocialContract: UnirepSocial
let admin
let attesterId
let chainId
const id = new Identity()
const receiver = new Identity()
const content = 'some post text'
@@ -29,6 +30,8 @@ describe('Vote', function () {
before(async () => {
const accounts = await ethers.getSigners()
admin = accounts[0]
const network = await accounts[0].provider.getNetwork()
chainId = network.chainId
unirepContract = await deployUnirep(admin)
unirepSocialContract = await deployUnirepSocial(
@@ -56,7 +59,13 @@ describe('Vote', function () {
// user 1 epoch key
const epoch = await unirepContract.attesterCurrentEpoch(attesterId)
const nonce = 0
const epochKey = genEpochKey(id.secret, attesterId, epoch, nonce)
const epochKey = genEpochKey(
id.secret,
attesterId,
epoch,
nonce,
chainId
)
// sign up another user and vote
{
@@ -93,7 +102,7 @@ describe('Vote', function () {
voteProof.proof
)
.then((t) => t.wait())
userState2.sync.stop()
userState2.stop()
}
// epoch transition
@@ -144,7 +153,7 @@ describe('Vote', function () {
.publishPost(hashedContent, publicSignals, proof)
.then((t) => t.wait())
}
userState.sync.stop()
userState.stop()
const currentEpoch = await unirepContract.attesterCurrentEpoch(
attesterId
)
@@ -152,7 +161,8 @@ describe('Vote', function () {
receiver.secret,
attesterId,
currentEpoch,
nonce
nonce,
chainId
)
})
@@ -196,7 +206,7 @@ describe('Vote', function () {
await expect(tx)
.to.emit(unirepSocialContract, 'VoteSubmitted')
.withArgs(epoch, fromEpochKey, toEpochKey, upvoteValue, downvote, 0)
userState.sync.stop()
userState.stop()
})
it('submit upvote with min rep should succeed', async () => {
@@ -236,7 +246,7 @@ describe('Vote', function () {
downvote,
minRep
)
userState.sync.stop()
userState.stop()
})
it('submit upvote with different amount of nullifiers should fail', async () => {
@@ -262,7 +272,7 @@ describe('Vote', function () {
proof
)
).to.be.revertedWith('Unirep Social: invalid rep nullifier')
userState.sync.stop()
userState.stop()
})
it('submit vote with both upvote and downvote value should fail', async () => {
@@ -288,7 +298,7 @@ describe('Vote', function () {
).to.be.revertedWith(
'Unirep Social: should only choose to upvote or to downvote'
)
userState.sync.stop()
userState.stop()
})
it('submit vote with 0 value should fail', async () => {
@@ -314,7 +324,7 @@ describe('Vote', function () {
).to.be.revertedWith(
'Unirep Social: should submit a positive vote value'
)
userState.sync.stop()
userState.stop()
})
it('submit upvote proof twice should fail', async () => {
@@ -341,7 +351,7 @@ describe('Vote', function () {
proof
)
).to.be.revertedWith('Unirep Social: the proof is submitted before')
userState.sync.stop()
userState.stop()
})
it('the receiver should successfully receive pos rep', async () => {
@@ -361,7 +371,7 @@ describe('Vote', function () {
await unirepSocialContract
.vote(upvoteValue, downvote, toEpochKey, publicSignals, proof)
.then((t) => t.wait())
userState.sync.stop()
userState.stop()
}
// epoch transition
@@ -391,7 +401,7 @@ describe('Vote', function () {
expect(repProof.proveMinRep).to.equal('1')
expect(repProof.minRep).to.equal(upvoteValue.toString())
expect(await repProof.verify()).to.be.true
userState2.sync.stop()
userState2.stop()
})
it('submit upvote subsidy should succeed', async () => {
@@ -431,7 +441,7 @@ describe('Vote', function () {
downvote,
minRep
)
userState.sync.stop()
userState.stop()
})
it('submit upvote subsidy with min rep should succeed', async () => {
@@ -472,7 +482,7 @@ describe('Vote', function () {
downvote,
minRep
)
userState.sync.stop()
userState.stop()
})
it('submit upvote subsidy without revealing epoch key nonce should fail', async () => {
@@ -499,7 +509,7 @@ describe('Vote', function () {
proof
)
).to.be.revertedWith('Unirep Social: epoch key nonce is not valid')
userState.sync.stop()
userState.stop()
})
it('submit upvote subsidy wrong epoch key nonce should fail', async () => {
@@ -526,7 +536,7 @@ describe('Vote', function () {
proof
)
).to.be.revertedWith('Unirep Social: epoch key nonce is not valid')
userState.sync.stop()
userState.stop()
})
it('submit vote subsidy with both upvote and downvote value should fail', async () => {
@@ -553,7 +563,7 @@ describe('Vote', function () {
).to.be.revertedWith(
'Unirep Social: should only choose to upvote or to downvote'
)
userState.sync.stop()
userState.stop()
})
it('submit vote subsidy with 0 value should fail', async () => {
@@ -580,7 +590,7 @@ describe('Vote', function () {
).to.be.revertedWith(
'Unirep Social: should submit a positive vote value'
)
userState.sync.stop()
userState.stop()
})
it('submit upvote subsidy proof twice should fail', async () => {
@@ -614,7 +624,7 @@ describe('Vote', function () {
proof
)
).to.be.revertedWith('Unirep Social: the proof is submitted before')
userState.sync.stop()
userState.stop()
})
it('the receiver should successfully receive pos rep with subsidy', async () => {
@@ -641,7 +651,7 @@ describe('Vote', function () {
proof
)
.then((t) => t.wait())
userState.sync.stop()
userState.stop()
}
// epoch transition
@@ -671,7 +681,7 @@ describe('Vote', function () {
expect(repProof.proveMinRep).to.equal('1')
expect(repProof.minRep).to.equal(upvoteValue.toString())
expect(await repProof.verify()).to.be.true
userState2.sync.stop()
userState2.stop()
})
it('requesting too much subsidy should fail', async () => {
@@ -709,7 +719,7 @@ describe('Vote', function () {
proof
)
).to.be.revertedWith('Unirep Social: requesting too much subsidy')
userState.sync.stop()
userState.stop()
})
it('submit downvote should succeed', async () => {
@@ -740,7 +750,7 @@ describe('Vote', function () {
await expect(tx)
.to.emit(unirepSocialContract, 'VoteSubmitted')
.withArgs(epoch, fromEpochKey, toEpochKey, upvote, downvoteValue, 0)
userState.sync.stop()
userState.stop()
})
it('submit downvote with min rep should succeed', async () => {
@@ -782,7 +792,7 @@ describe('Vote', function () {
downvoteValue,
minRep
)
userState.sync.stop()
userState.stop()
})
it('submit downvote with different amount of nullifiers should fail', async () => {
@@ -808,7 +818,7 @@ describe('Vote', function () {
proof
)
).to.be.revertedWith('Unirep Social: invalid rep nullifier')
userState.sync.stop()
userState.stop()
})
it('submit downvote proof twice should fail', async () => {
@@ -835,7 +845,7 @@ describe('Vote', function () {
proof
)
).to.be.revertedWith('Unirep Social: the proof is submitted before')
userState.sync.stop()
userState.stop()
})
it('the receiver should successfully receive neg rep', async () => {
@@ -855,7 +865,7 @@ describe('Vote', function () {
await unirepSocialContract
.vote(upvote, downvoteValue, toEpochKey, publicSignals, proof)
.then((t) => t.wait())
userState.sync.stop()
userState.stop()
}
// epoch transition
@@ -885,7 +895,7 @@ describe('Vote', function () {
expect(repProof.proveMaxRep).to.equal('1')
expect(repProof.maxRep).to.equal(downvoteValue.toString())
expect(await repProof.verify()).to.be.true
userState2.sync.stop()
userState2.stop()
})
it('submit downvote subsidy should succeed', async () => {
@@ -925,7 +935,7 @@ describe('Vote', function () {
downvoteValue,
minRep
)
userState.sync.stop()
userState.stop()
})
it('submit downvote subsidy with min rep should succeed', async () => {
@@ -966,7 +976,7 @@ describe('Vote', function () {
downvoteValue,
minRep
)
userState.sync.stop()
userState.stop()
})
it('the receiver should successfully receive neg rep with subsidy', async () => {
@@ -993,7 +1003,7 @@ describe('Vote', function () {
proof
)
.then((t) => t.wait())
userState.sync.stop()
userState.stop()
}
// epoch transition
@@ -1023,6 +1033,6 @@ describe('Vote', function () {
expect(repProof.proveMaxRep).to.equal('1')
expect(repProof.maxRep).to.equal(downvoteValue.toString())
expect(await repProof.verify()).to.be.true
userState2.sync.stop()
userState2.stop()
})
})

View File

@@ -25,16 +25,20 @@ export const genUnirepState = async (
export const genUserState = async (
provider: ethers.providers.Provider,
address: string,
unirepAddress: string,
id: Identity,
attesterId: string,
unirepSocialAddress: string,
db?: DB
) => {
const synchronizer = await genUnirepState(provider, address, attesterId, db)
return new SocialUserState({
synchronizer,
const state = new SocialUserState({
unirepAddress,
provider,
attesterId: BigInt(unirepSocialAddress),
db,
id,
prover: defaultProver,
unirepSocialAddress: attesterId,
})
await state.start()
await state.waitForSync()
return state
}

View File

@@ -1,6 +1,6 @@
{
"name": "@unirep-social/frontend",
"version": "1.1.0",
"version": "1.1.1",
"private": true,
"scripts": {
"start": "webpack-dev-server",
@@ -24,14 +24,13 @@
"dependencies": {
"@babel/preset-env": "^7.18.6",
"@types/aes-js": "^3.1.1",
"@unirep-social/core": "^1.1.0",
"@unirep/core": "2.0.0-beta-4",
"@unirep-social/core": "^1.1.1",
"@unirep/core": "2.0.0-beta-6",
"aes-js": "^3.1.2",
"babel-preset-env": "^1.7.0",
"bootstrap": "^5.0.2",
"cypress-real-events": "^1.7.1",
"dateformat": "^4.5.1",
"ethers": "^5.6.8",
"events": "^3.3.0",
"identity-obj-proxy": "^3.0.0",
"jest-environment-jsdom": "^28.1.2",

View File

@@ -7,8 +7,7 @@ import { ethers } from 'ethers'
import { genEpochKey, stringifyBigInts } from '@unirep/utils'
import { Identity } from '@semaphore-protocol/identity'
import { makeURL } from '../utils'
// TODO: update @unirep/core schema
import { schema } from './schema'
import { schema } from '@unirep/core'
import { Prover } from '@unirep/circuits'
import { SocialUserState } from '@unirep-social/core'
import prover from './prover'
@@ -29,6 +28,7 @@ export class User {
loadingPromise
userState?: SocialUserState
username = {} as Username
chainId = 0
syncStartBlock: any
latestProcessedBlock: any
@@ -206,7 +206,8 @@ export class User {
this.id.secret,
this.unirepConfig.unirepSocialAddress,
BigInt(this.currentEpoch),
i
i,
this.chainId
).toString()
})
}
@@ -271,11 +272,11 @@ export class User {
unirepAddress: this.unirepConfig.unirepAddress,
attesterId: this.unirepConfig.unirepSocialAddress,
id: this.id,
unirepSocialAddress: this.unirepConfig.unirepSocialAddress,
prover: prover as Prover,
})
await this.userState.start()
await this.userState.waitForSync()
this.chainId = this.userState.chainId
const [EpochEnded] = this.unirepConfig.unirep.filters.EpochEnded()
.topics as string[]
this.userState.sync.on(EpochEnded, this.epochEnded.bind(this))
@@ -302,7 +303,8 @@ export class User {
secret,
this.unirepConfig.unirepSocialAddress,
epoch,
i
i,
this.chainId
).toString()
epks.push(tmp)
}
@@ -326,7 +328,8 @@ export class User {
this.id.secret,
this.unirepConfig.unirepSocialAddress,
epoch,
0
0,
this.chainId
)
const spentSubsidy = await this.unirepConfig.unirepSocial.subsidies(
epoch,
@@ -492,7 +495,7 @@ export class User {
async logout() {
if (this.userState) {
this.userState.sync.stop()
this.userState.stop()
await this.userState.sync.db.close()
await this.userState.sync.db.closeAndWipe()
this.userState = undefined

View File

@@ -1,134 +0,0 @@
import { TableData } from 'anondb'
import { nanoid } from 'nanoid'
const _schema = [
{
name: 'SynchronizerState',
indexes: [{ keys: ['latestCompleteBlock'] }],
rows: [
['attesterId', 'String', { unique: true }],
{
name: 'latestProcessedBlock',
type: 'Int',
default: 0,
},
{
name: 'latestProcessedTransactionIndex',
type: 'Int',
default: 0,
},
{
name: 'latestProcessedEventIndex',
type: 'Int',
default: 0,
},
{
name: 'latestCompleteBlock',
type: 'Int',
default: 0,
},
],
},
{
name: 'Attestation',
indexes: [{ keys: ['index'] }],
rows: [
['epoch', 'Int'],
['epochKey', 'String'],
['index', 'String', { unique: true }], // event index, tx index, block index
['attesterId', 'String'],
['fieldIndex', 'Int'],
['change', 'String'],
['blockNumber', 'Int'],
],
},
{
name: 'StateTreeLeaf',
indexes: [{ keys: ['index'] }],
rows: [
['epoch', 'Int'],
['hash', 'String'],
['index', 'Int'],
['attesterId', 'String'],
['blockNumber', 'Int'],
],
},
{
name: 'EpochTreeLeaf',
indexes: [{ keys: ['index'] }],
rows: [
['id', 'String'],
['epoch', 'Int'],
['hash', 'String'],
['index', 'String'],
['attesterId', 'String'],
['blockNumber', 'Int'],
],
},
{
name: 'HistoryTreeLeaf',
indexes: [{ keys: ['index'] }],
rows: [
['id', 'String'],
['index', 'Int'],
['attesterId', 'String'],
['leaf', 'String', { unique: true }],
],
},
{
name: 'Epoch',
indexes: [{ keys: ['number'] }],
rows: [
['number', 'Int'],
['attesterId', 'String'],
['sealed', 'Bool'],
],
},
{
name: 'Nullifier',
indexes: [{ keys: ['epoch'] }],
rows: [
['epoch', 'Int'],
['attesterId', 'String'],
['nullifier', 'String', { unique: true }],
['transactionHash', 'String', { optional: true }],
['blockNumber', 'Int'],
],
},
{
name: 'UserSignUp',
indexes: [
{ keys: ['commitment', 'attesterId'] },
{ keys: ['commitment', 'attesterId', 'epoch'] },
],
rows: [
['commitment', 'String'],
['epoch', 'Int'],
['attesterId', 'String'],
['blockNumber', 'Int'],
],
},
{
name: 'Attester',
rows: [
['startTimestamp', 'Int'],
['epochLength', 'Int'],
],
},
]
/**
* The schema of the database that is used in storing Unirep data
*/
export const schema = _schema.map((obj) => ({
primaryKey: '_id',
...obj,
rows: [
...obj.rows,
{
name: '_id',
type: 'String',
default: () => nanoid(),
},
],
})) as TableData[]

239
yarn.lock
View File

@@ -2637,10 +2637,10 @@
resolved "https://registry.yarnpkg.com/@open-draft/until/-/until-1.0.3.tgz#db9cc719191a62e7d9200f6e7bab21c5b848adca"
integrity sha512-Aq58f5HiWdyDlFffbbSjAlv596h/cOnt2DO1w3DOC7OJ5EHs0hd/nycJfiu9RJbT6Yk6F1knnRRXNSpxoIVZ9Q==
"@openzeppelin/contracts@^4.8.1":
version "4.8.2"
resolved "https://registry.yarnpkg.com/@openzeppelin/contracts/-/contracts-4.8.2.tgz#d815ade0027b50beb9bcca67143c6bcc3e3923d6"
integrity sha512-kEUOgPQszC0fSYWpbh2kT94ltOJwj1qfT2DWo+zVttmGmf97JZ99LspePNaeeaLhCImaHVeBbjaQFZQn7+Zc5g==
"@openzeppelin/contracts@^4.9.3":
version "4.9.3"
resolved "https://registry.yarnpkg.com/@openzeppelin/contracts/-/contracts-4.9.3.tgz#00d7a8cf35a475b160b3f0293a6403c511099364"
integrity sha512-He3LieZ1pP2TNt5JbkPA4PNT9WC3gOTOlDcFGJW4Le4QKqwmiNJCRt44APfxMxvq7OugU/cqYuPcSBzOw38DAg==
"@parcel/watcher@2.0.4":
version "2.0.4"
@@ -2684,10 +2684,10 @@
"@noble/hashes" "~1.2.0"
"@scure/base" "~1.1.0"
"@semaphore-protocol/identity@^3.5.0":
version "3.10.1"
resolved "https://registry.yarnpkg.com/@semaphore-protocol/identity/-/identity-3.10.1.tgz#d3bd0245ffdfe9f70169309a8b1213cd69b3b3d8"
integrity sha512-H2GUHdox393YCcA4f389za2o5tnSIaGmtlPN8LCyI/UgCG/LJxQY5dLrSNM24j+kNRaq5LXaFzJIrM+zWvqBQQ==
"@semaphore-protocol/identity@^3.10.1":
version "3.15.0"
resolved "https://registry.yarnpkg.com/@semaphore-protocol/identity/-/identity-3.15.0.tgz#cd930e71e3782d7f70c7e48b805eb0bc8171107c"
integrity sha512-X3EdkMZ/riGKAuapQaUvLeWKk5CYbvipriBXYOpnVcT6XbWMKMBPdFB5cRvW9cNyORl5nEQ6+43ejWYZYSZkYQ==
dependencies:
"@ethersproject/bignumber" "^5.5.0"
"@ethersproject/keccak256" "^5.7.0"
@@ -3475,45 +3475,51 @@
dependencies:
"@types/node" "*"
"@unirep/circuits@2.0.0-beta-4":
version "2.0.0-beta-4"
resolved "https://registry.yarnpkg.com/@unirep/circuits/-/circuits-2.0.0-beta-4.tgz#7ae6d680969744a0b323b93d4f45487966e4fefb"
integrity sha512-wQAaW0H2XNIgdFI74gZ+hiAPd4Yy6ITRSCwp9xLGZz2k72BP5mM2y2OsXSGi4qx+PTHwrFkuFUijAfc3WfwkZg==
dependencies:
"@unirep/utils" "2.0.0-beta-4"
snarkjs "^0.5.0"
"@ungap/structured-clone@^1.2.0":
version "1.2.0"
resolved "https://registry.yarnpkg.com/@ungap/structured-clone/-/structured-clone-1.2.0.tgz#756641adb587851b5ccb3e095daf27ae581c8406"
integrity sha512-zuVdFrMJiuCDQUMCzQaD6KL28MjnqqN8XnAqiEq9PNm/hCPTSGfrXCOfwj1ow4LFb/tNymJPwsNbVePc1xFqrQ==
"@unirep/contracts@2.0.0-beta-4":
version "2.0.0-beta-4"
resolved "https://registry.yarnpkg.com/@unirep/contracts/-/contracts-2.0.0-beta-4.tgz#21a2f508b7041bd90601a56879865c7595ec899b"
integrity sha512-Gt2T7L0XOs2grgn9OR/HyRwY+k8ir1hLYXjvnVxdutNJVI5FkiJqXEQlv26W1oKmT6s462DKTp5M4JvrPQhYFQ==
"@unirep/circuits@2.0.0-beta-5":
version "2.0.0-beta-5"
resolved "https://registry.yarnpkg.com/@unirep/circuits/-/circuits-2.0.0-beta-5.tgz#8266aa8bf17cb77cd7668dda27d2b2410093ec7b"
integrity sha512-NWevXjN8DuP/jeUZTDrrPxD8LLiXqJXyuzdh3MZJNAFXYft6awyovvO9UMkelJ27sovwrqRLUGlFHoCW3Pr9OQ==
dependencies:
"@unirep/circuits" "2.0.0-beta-4"
"@unirep/utils" "2.0.0-beta-4"
"@zk-kit/incremental-merkle-tree.sol" "^1.4.0"
ethers "^5.6.8"
global-factory "^0.0.0"
"@unirep/utils" "2.0.0-beta-5"
snarkjs "^0.7.0"
"@unirep/contracts@2.0.0-beta-5":
version "2.0.0-beta-5"
resolved "https://registry.yarnpkg.com/@unirep/contracts/-/contracts-2.0.0-beta-5.tgz#f84aff6728a6a62ada3b502c6a0c8bed866642a1"
integrity sha512-ZUvy5irPjwudnLPBX5XrIweLe/cqvo0rTuTIDJ3qhLcfVk7HGm/rTnucPoSKwTS/mqx6+hAXRD7tq+KWrvqO+Q==
dependencies:
"@openzeppelin/contracts" "^4.9.3"
"@unirep/circuits" "2.0.0-beta-5"
"@unirep/utils" "2.0.0-beta-5"
"@zk-kit/incremental-merkle-tree.sol" "^1.7.0"
ethers "^5.7.2"
global-factory "^0.0.2"
poseidon-solidity "^0.0.5"
solc "^0.8.16"
solc "^0.8.21"
"@unirep/core@2.0.0-beta-4":
version "2.0.0-beta-4"
resolved "https://registry.yarnpkg.com/@unirep/core/-/core-2.0.0-beta-4.tgz#8b655861b4911c0ae9888c2a1f5b5c4d9a38164e"
integrity sha512-gWwusC6dLH990aH8uFb4KkE4owAeMgj7iQXQx/W++GhZRxvQPh7ucOa7qJgW0vwdSJC/LYaRtSkm5puNAwdZ0g==
"@unirep/core@2.0.0-beta-6":
version "2.0.0-beta-6"
resolved "https://registry.yarnpkg.com/@unirep/core/-/core-2.0.0-beta-6.tgz#0b54439990473827069aaf942c637dbaf1d2f958"
integrity sha512-WG7ZGLZm470QBLuXUQC54MC67LPP8pAE1xtQgSOmC7fuas+XPj0QJHiHfT7l3y55bvhGVF1ljrqfWu4qNnph9A==
dependencies:
"@semaphore-protocol/identity" "^3.5.0"
"@unirep/circuits" "2.0.0-beta-4"
"@unirep/contracts" "2.0.0-beta-4"
"@unirep/utils" "2.0.0-beta-4"
anondb "^0.0.16"
"@semaphore-protocol/identity" "^3.10.1"
"@unirep/circuits" "2.0.0-beta-5"
"@unirep/contracts" "2.0.0-beta-5"
"@unirep/utils" "2.0.0-beta-5"
anondb "^0.0.21"
async-lock "^1.4.0"
ethers "^5.6.8"
nanoid "3"
ethers "^5.7.2"
nanoid "^3.3.6"
"@unirep/utils@2.0.0-beta-4":
version "2.0.0-beta-4"
resolved "https://registry.yarnpkg.com/@unirep/utils/-/utils-2.0.0-beta-4.tgz#cb627c4f208331f919884f0f4e063b70506cf4a0"
integrity sha512-ldv5ObkYWbcuGqokzJjHJtrx/5/2H3r6opEwa6T41e8ualbn+bvylLXFr6L0L5oJlZFXPdFiAktxN3iy7eNoxQ==
"@unirep/utils@2.0.0-beta-5":
version "2.0.0-beta-5"
resolved "https://registry.yarnpkg.com/@unirep/utils/-/utils-2.0.0-beta-5.tgz#0d3c6bfe432f0d3d9620422328612fd03118802e"
integrity sha512-Wt3cv/kJrdaT+N0RHqGRJRVU18xMxs+87hDsV2ubzKmwtziPc6HevSzsTaRUB8A0wPGAA/nT95iQZlNsGPGXxw==
dependencies:
"@zk-kit/incremental-merkle-tree" "^1.1.0"
poseidon-lite "^0.2.0"
@@ -3685,7 +3691,7 @@
js-yaml "^3.10.0"
tslib "^2.4.0"
"@zk-kit/incremental-merkle-tree.sol@^1.4.0":
"@zk-kit/incremental-merkle-tree.sol@^1.7.0":
version "1.7.0"
resolved "https://registry.yarnpkg.com/@zk-kit/incremental-merkle-tree.sol/-/incremental-merkle-tree.sol-1.7.0.tgz#9d6166c2d84b8bb4fae709c7d729aae6c8c6474f"
integrity sha512-1HF5HEQ2GVKYBAKeNlhiQ7Fb7g2x6iBQ/bBovxBQYx8xuJlD8jPJU/fn2foMVI42+BQtz2V/V4tVtn+0uNL1Rg==
@@ -3881,11 +3887,12 @@ ajv@^8.0.0, ajv@^8.8.0:
require-from-string "^2.0.2"
uri-js "^4.2.2"
anondb@^0.0.16:
version "0.0.16"
resolved "https://registry.yarnpkg.com/anondb/-/anondb-0.0.16.tgz#057bcc5d58676f3cc0983f99656f03641df3367b"
integrity sha512-F5vu1HzXcEHARhIe6bJhaIss40aqz4Ht4PnQx/4T2r0ZRmne7YbzGLjMimgV+MtA4QHk9jhe4pM8MdUmt0zYag==
anondb@^0.0.21:
version "0.0.21"
resolved "https://registry.yarnpkg.com/anondb/-/anondb-0.0.21.tgz#6885dd4e535102c2f537ca171038b3c5f1c5faa3"
integrity sha512-0FR5NpjSI0E7R5r2Ok9O0xziUBbJanprTQzu2lM+szbUOckYDOQw42tWxvCfiamzhZDqcD7MHCLCs1tehf3P1Q==
dependencies:
"@ungap/structured-clone" "^1.2.0"
async-lock "^1.2.11"
idb "^6.0.0"
nanoid "^3.1.30"
@@ -4807,11 +4814,6 @@ bfj@^7.0.2:
hoopy "^0.1.4"
tryer "^1.0.1"
big-integer@^1.6.42, big-integer@^1.6.48:
version "1.6.51"
resolved "https://registry.yarnpkg.com/big-integer/-/big-integer-1.6.51.tgz#0df92a5d9880560d3ff2d5fd20245c889d130686"
integrity sha512-GPEid2Y9QU1Exl1rpO9B2IPJGHPSupF5GnVIP0blYvNOMer2bTvSWs1jGOUg04hTmu67nmLsQ9TBo1puaotBHg==
big.js@^5.2.2:
version "5.2.2"
resolved "https://registry.yarnpkg.com/big.js/-/big.js-5.2.2.tgz#65f0af382f578bcdc742bd9c281e9cb2d7768328"
@@ -5461,19 +5463,12 @@ cipher-base@^1.0.0, cipher-base@^1.0.1, cipher-base@^1.0.3:
inherits "^2.0.1"
safe-buffer "^5.0.1"
circom_runtime@0.1.20:
version "0.1.20"
resolved "https://registry.yarnpkg.com/circom_runtime/-/circom_runtime-0.1.20.tgz#14411846448b541bcb71548a23e6d982e7a051a6"
integrity sha512-61AnccA8Ozo5apyDf3hR1JMDDNx1DttKll2bdxVpNjUaTiawDuuYE0VNmRvuoKlcy/WAY+HtD3K994WGrOFhJQ==
circom_runtime@0.1.24:
version "0.1.24"
resolved "https://registry.yarnpkg.com/circom_runtime/-/circom_runtime-0.1.24.tgz#60ca8a31c3675802fbab5a0bcdeb02556e510733"
integrity sha512-H7/7I2J/cBmRnZm9docOCGhfxzS61BEm4TMCWcrZGsWNBQhePNfQq88Oj2XpUfzmBTCd8pRvRb3Mvazt3TMrJw==
dependencies:
ffjavascript "0.2.55"
circom_runtime@0.1.21:
version "0.1.21"
resolved "https://registry.yarnpkg.com/circom_runtime/-/circom_runtime-0.1.21.tgz#0ee93bb798b5afb8ecec30725ed14d94587a999b"
integrity sha512-qTkud630B/GK8y76hnOaaS1aNuF6prfV0dTrkeRsiJKnlP1ryQbP2FWLgDOPqn6aKyaPlam+Z+DTbBhkEzh8dA==
dependencies:
ffjavascript "0.2.56"
ffjavascript "0.2.60"
cjs-module-lexer@^1.0.0:
version "1.2.2"
@@ -6966,7 +6961,7 @@ ethereumjs-util@^6.0.0, ethereumjs-util@^6.2.1:
ethjs-util "0.1.6"
rlp "^2.2.3"
ethers@^5.6.8, ethers@^5.7.2:
ethers@^5.7.2:
version "5.7.2"
resolved "https://registry.yarnpkg.com/ethers/-/ethers-5.7.2.tgz#3a7deeabbb8c030d4126b24f84e525466145872e"
integrity sha512-wswUsmWo1aOK8rR7DIKiWSw9DbLWe6x98Jrn8wcTflTVvaXhAMaB5zGAXy0GYQEQp9iO1iSHWVyARQm11zUtyg==
@@ -7300,23 +7295,13 @@ fd-slicer@~1.1.0:
dependencies:
pend "~1.2.0"
ffjavascript@0.2.55:
version "0.2.55"
resolved "https://registry.yarnpkg.com/ffjavascript/-/ffjavascript-0.2.55.tgz#fb4bc53265501526a2916d6a20bbbc06d113d7be"
integrity sha512-8X0FCIPOWiK6DTWh3pnE3O6D6nIQsirStAXpWMzRDnoDX7SEnDX4I28aVhwjL7L35XS1vy2AU7zc0UCGYxdLjw==
dependencies:
big-integer "^1.6.48"
wasmbuilder "^0.0.12"
wasmcurves "0.1.0"
web-worker "^1.2.0"
ffjavascript@0.2.56:
version "0.2.56"
resolved "https://registry.yarnpkg.com/ffjavascript/-/ffjavascript-0.2.56.tgz#3509f98fcbd3e44ea93cd23519071b76d6eae433"
integrity sha512-em6G5Lrj7ucIqj4TYEgyoHs/j99Urwwqa4+YxEVY2hggnpRimVj+noX5pZQTxI1pvtiekZI4rG65JBf0xraXrg==
ffjavascript@0.2.60:
version "0.2.60"
resolved "https://registry.yarnpkg.com/ffjavascript/-/ffjavascript-0.2.60.tgz#4d8ae613d6bf4e98b3cc29ba10c626f5853854cf"
integrity sha512-T/9bnEL5xAZRDbQoEMf+pM9nrhK+C3JyZNmqiWub26EQorW7Jt+jR54gpqDhceA4Nj0YctPQwYnl8xa52/A26A==
dependencies:
wasmbuilder "0.0.16"
wasmcurves "0.2.0"
wasmcurves "0.2.2"
web-worker "^1.2.0"
ffjavascript@^0.2.48:
@@ -7896,14 +7881,6 @@ global-dirs@^3.0.0:
dependencies:
ini "2.0.0"
global-factory@^0.0.0:
version "0.0.0"
resolved "https://registry.yarnpkg.com/global-factory/-/global-factory-0.0.0.tgz#707927bb18f1919b3001e8fc364a66d18ccd0979"
integrity sha512-ICxRVNqj7t/MhVLB2gyrIrKRs1E+zCCfRw1myuPrzwrl9qoBMSMMxn8lES64niqZ7Y+P7cMWH6H7NIRxYsaW6g==
dependencies:
"@ethersproject/address" "^5.7.0"
"@ethersproject/keccak256" "^5.7.0"
global-factory@^0.0.2:
version "0.0.2"
resolved "https://registry.yarnpkg.com/global-factory/-/global-factory-0.0.2.tgz#64e16ceca0d2eda6833d48a5e1e66e3428a8277f"
@@ -10882,16 +10859,16 @@ nanoassert@^2.0.0:
resolved "https://registry.yarnpkg.com/nanoassert/-/nanoassert-2.0.0.tgz#a05f86de6c7a51618038a620f88878ed1e490c09"
integrity sha512-7vO7n28+aYO4J+8w96AzhmU8G+Y/xpPDJz/se19ICsqj/momRbb9mh9ZUtkoJ5X3nTnPdhEJyc0qnM6yAsHBaA==
nanoid@3, nanoid@^3.1.30, nanoid@^3.3.4:
version "3.3.4"
resolved "https://registry.yarnpkg.com/nanoid/-/nanoid-3.3.4.tgz#730b67e3cd09e2deacf03c027c81c9d9dbc5e8ab"
integrity sha512-MqBkQh/OHTS2egovRtLk45wEyNXwF+cokD+1YPf9u5VfJiRdAiRwB2froX5Co9Rh20xs4siNPm8naNotSD6RBw==
nanoid@3.3.3:
version "3.3.3"
resolved "https://registry.yarnpkg.com/nanoid/-/nanoid-3.3.3.tgz#fd8e8b7aa761fe807dba2d1b98fb7241bb724a25"
integrity sha512-p1sjXuopFs0xg+fPASzQ28agW1oHD7xDsd9Xkf3T15H3c/cifrFHVwrh74PdoklAPi+i7MdRsE47vm2r6JoB+w==
nanoid@^3.1.30, nanoid@^3.3.4:
version "3.3.4"
resolved "https://registry.yarnpkg.com/nanoid/-/nanoid-3.3.4.tgz#730b67e3cd09e2deacf03c027c81c9d9dbc5e8ab"
integrity sha512-MqBkQh/OHTS2egovRtLk45wEyNXwF+cokD+1YPf9u5VfJiRdAiRwB2froX5Co9Rh20xs4siNPm8naNotSD6RBw==
nanoid@^3.3.6:
version "3.3.6"
resolved "https://registry.yarnpkg.com/nanoid/-/nanoid-3.3.6.tgz#443380c856d6e9f9824267d960b4236ad583ea4c"
@@ -12491,25 +12468,15 @@ quick-lru@^4.0.1:
resolved "https://registry.yarnpkg.com/quick-lru/-/quick-lru-4.0.1.tgz#5b8878f113a58217848c6482026c73e1ba57727f"
integrity sha512-ARhCpm70fzdcvNQfPoy49IaanKkTlRWF2JMzqhcJbhSFRZv7nPTvZJdcY7301IPmvW+/p0RgIWnQDLJxifsQ7g==
r1csfile@0.0.40:
version "0.0.40"
resolved "https://registry.yarnpkg.com/r1csfile/-/r1csfile-0.0.40.tgz#410e10e3cec8daf62ff87b022460cf180fd51d58"
integrity sha512-3tKaFLncf42ZTRpPMlgyiFBdk6kir4S4O3X+u4UQjgLYoDPHfizazNbK0Jzj++PVIXVUFAqugSbIo4W3UDuHcQ==
r1csfile@0.0.47:
version "0.0.47"
resolved "https://registry.yarnpkg.com/r1csfile/-/r1csfile-0.0.47.tgz#ed95a0dc8e910e9c070253906f7a31bd8c5333c8"
integrity sha512-oI4mAwuh1WwuFg95eJDNDDL8hCaZkwnPuNZrQdLBWvDoRU7EG+L/MOHL7SwPW2Y+ZuYcTLpj3rBkgllBQZN/JA==
dependencies:
"@iden3/bigarray" "0.0.2"
"@iden3/binfileutils" "0.0.11"
fastfile "0.0.20"
ffjavascript "0.2.55"
r1csfile@0.0.41:
version "0.0.41"
resolved "https://registry.yarnpkg.com/r1csfile/-/r1csfile-0.0.41.tgz#e3d2709d36923156dd1fc2db9858987b30c92948"
integrity sha512-Q1WDF3u1vYeAwjHo4YuddkA8Aq0TulbKjmGm99+Atn13Lf5fTsMZBnBV9T741w8iSyPFG6Uh6sapQby77sREqA==
dependencies:
"@iden3/bigarray" "0.0.2"
"@iden3/binfileutils" "0.0.11"
fastfile "0.0.20"
ffjavascript "0.2.56"
ffjavascript "0.2.60"
randomatic@^3.0.0:
version "3.1.1"
@@ -13487,37 +13454,21 @@ smart-buffer@^4.2.0:
resolved "https://registry.yarnpkg.com/smart-buffer/-/smart-buffer-4.2.0.tgz#6e1d71fa4f18c05f7d0ff216dd16a481d0e8d9ae"
integrity sha512-94hK0Hh8rPqQl2xXc3HsaBoOXKV20MToPkcXvwbISWLEs+64sBq5kFgn2kJDHb1Pry9yrP0dxrCI9RRci7RXKg==
snarkjs@^0.4.7:
version "0.4.27"
resolved "https://registry.yarnpkg.com/snarkjs/-/snarkjs-0.4.27.tgz#6f00e17e2b0b197dd69029a65ee570085b49a5f0"
integrity sha512-2CH4JpOIkaoEiPvc/d9eiA7Vs0mC2ZnQAhFIFF+qp8eVxhHpDXFZn50hEZhcb8lypGry8ZiiEQ73a3hOFOUbYQ==
snarkjs@^0.7.0:
version "0.7.1"
resolved "https://registry.yarnpkg.com/snarkjs/-/snarkjs-0.7.1.tgz#c96ecaf4db8c2eb44d60b17ee02f37ed39c821bb"
integrity sha512-Qs1oxssa135WZkzfARgEp5SuKHKvKNtcspeJbE5je6MurUpBylD1rzcAzQSTGWA/EH/BV/TmUyTaTD64xScvbA==
dependencies:
"@iden3/binfileutils" "0.0.11"
bfj "^7.0.2"
blake2b-wasm "^2.4.0"
circom_runtime "0.1.20"
circom_runtime "0.1.24"
ejs "^3.1.6"
fastfile "0.0.20"
ffjavascript "0.2.55"
ffjavascript "0.2.60"
js-sha3 "^0.8.0"
logplease "^1.2.15"
r1csfile "0.0.40"
snarkjs@^0.5.0:
version "0.5.0"
resolved "https://registry.yarnpkg.com/snarkjs/-/snarkjs-0.5.0.tgz#cf26bf1d3835eb16b4b330a438bad9824837d6b0"
integrity sha512-KWz8mZ2Y+6wvn6GGkQo6/ZlKwETdAGohd40Lzpwp5TUZCn6N6O4Az1SuX1rw/qREGL6Im+ycb19suCFE8/xaKA==
dependencies:
"@iden3/binfileutils" "0.0.11"
bfj "^7.0.2"
blake2b-wasm "^2.4.0"
circom_runtime "0.1.21"
ejs "^3.1.6"
fastfile "0.0.20"
ffjavascript "0.2.56"
js-sha3 "^0.8.0"
logplease "^1.2.15"
r1csfile "0.0.41"
r1csfile "0.0.47"
sockjs@^0.3.24:
version "0.3.24"
@@ -13569,10 +13520,10 @@ solc@0.7.3:
semver "^5.5.0"
tmp "0.0.33"
solc@^0.8.16:
version "0.8.19"
resolved "https://registry.yarnpkg.com/solc/-/solc-0.8.19.tgz#cac6541106ae3cff101c740042c7742aa56a2ed3"
integrity sha512-yqurS3wzC4LdEvmMobODXqprV4MYJcVtinuxgrp61ac8K2zz40vXA0eSAskSHPgv8dQo7Nux39i3QBsHx4pqyA==
solc@^0.8.21:
version "0.8.21"
resolved "https://registry.yarnpkg.com/solc/-/solc-0.8.21.tgz#c3cd505c360ea2fa0eaa5ab574ef96bffb1a2766"
integrity sha512-N55ogy2dkTRwiONbj4e6wMZqUNaLZkiRcjGyeafjLYzo/tf/IvhHY5P5wpe+H3Fubh9idu071i8eOGO31s1ylg==
dependencies:
command-exists "^1.2.8"
commander "^8.1.0"
@@ -14864,21 +14815,6 @@ wasmbuilder@0.0.16:
resolved "https://registry.yarnpkg.com/wasmbuilder/-/wasmbuilder-0.0.16.tgz#f34c1f2c047d2f6e1065cbfec5603988f16d8549"
integrity sha512-Qx3lEFqaVvp1cEYW7Bfi+ebRJrOiwz2Ieu7ZG2l7YyeSJIok/reEQCQCuicj/Y32ITIJuGIM9xZQppGx5LrQdA==
wasmbuilder@^0.0.12:
version "0.0.12"
resolved "https://registry.yarnpkg.com/wasmbuilder/-/wasmbuilder-0.0.12.tgz#a60cb25d6d11f314fe5ab3f4ee041ccb493cb78a"
integrity sha512-dTMpBgrnLOXrN58i2zakn2ScynsBhq9LfyQIsPz4CyxRF9k1GAORniuqn3xmE9NnI1l7g3iiVCkoB2Cl0/oG8w==
dependencies:
big-integer "^1.6.48"
wasmcurves@0.1.0:
version "0.1.0"
resolved "https://registry.yarnpkg.com/wasmcurves/-/wasmcurves-0.1.0.tgz#0bc3f9d465367fcd8243395cb0094a05577e5609"
integrity sha512-kIlcgbVUAv2uQ6lGsepGz/m5V40+Z6rvTBkqCYn3Y2+OcXst+UaP4filJYLh/xDxjJl62FFjZZeAnpeli1Y5/Q==
dependencies:
big-integer "^1.6.42"
blakejs "^1.1.0"
wasmcurves@0.2.0:
version "0.2.0"
resolved "https://registry.yarnpkg.com/wasmcurves/-/wasmcurves-0.2.0.tgz#ccfc5a7d3778b6e0768b82a9336c80054f9bc0cf"
@@ -14886,6 +14822,13 @@ wasmcurves@0.2.0:
dependencies:
wasmbuilder "0.0.16"
wasmcurves@0.2.2:
version "0.2.2"
resolved "https://registry.yarnpkg.com/wasmcurves/-/wasmcurves-0.2.2.tgz#ca444f6a6f6e2a5cbe6629d98ff478a62b4ccb2b"
integrity sha512-JRY908NkmKjFl4ytnTu5ED6AwPD+8VJ9oc94kdq7h5bIwbj0L4TDJ69mG+2aLs2SoCmGfqIesMWTEJjtYsoQXQ==
dependencies:
wasmbuilder "0.0.16"
watchpack@^2.4.0:
version "2.4.0"
resolved "https://registry.yarnpkg.com/watchpack/-/watchpack-2.4.0.tgz#fa33032374962c78113f93c7f2fb4c54c9862a5d"