This commit is contained in:
poma 2021-02-02 14:38:11 +03:00
parent 4d6a05a88b
commit a4a6b92e6b
No known key found for this signature in database
GPG Key ID: BA20CB01FE165657
7 changed files with 17 additions and 22 deletions

View File

@ -2,5 +2,4 @@
artifacts artifacts
cache cache
circuits circuits
scripts
contracts/verifiers contracts/verifiers

View File

@ -1,3 +1,4 @@
/* global task, ethers */
require('@nomiclabs/hardhat-waffle') require('@nomiclabs/hardhat-waffle')
// This is a sample Hardhat task. To learn how to create your own go to // This is a sample Hardhat task. To learn how to create your own go to

View File

@ -1,32 +1,32 @@
// We require the Hardhat Runtime Environment explicitly here. This is optional // We require the Hardhat Runtime Environment explicitly here. This is optional
// but useful for running the script in a standalone fashion through `node <script>`. // but useful for running the script in a standalone fashion through `node <script>`.
// //
// When running the script with `hardhat run <script>` you'll find the Hardhat // When running the script with `hardhat run <script>` you'll find the Hardhat
// Runtime Environment's members available in the global scope. // Runtime Environment's members available in the global scope.
const hre = require("hardhat"); const hre = require('hardhat')
async function main() { async function main() {
// Hardhat always runs the compile task when running scripts with its command // Hardhat always runs the compile task when running scripts with its command
// line interface. // line interface.
// //
// If this script is run directly using `node` you may want to call compile // If this script is run directly using `node` you may want to call compile
// manually to make sure everything is compiled // manually to make sure everything is compiled
// await hre.run('compile'); // await hre.run('compile');
// We get the contract to deploy // We get the contract to deploy
const Greeter = await hre.ethers.getContractFactory("Greeter"); const Greeter = await hre.ethers.getContractFactory('Greeter')
const greeter = await Greeter.deploy("Hello, Hardhat!"); const greeter = await Greeter.deploy('Hello, Hardhat!')
await greeter.deployed(); await greeter.deployed()
console.log("Greeter deployed to:", greeter.address); console.log('Greeter deployed to:', greeter.address)
} }
// We recommend this pattern to be able to use async/await everywhere // We recommend this pattern to be able to use async/await everywhere
// and properly handle errors. // and properly handle errors.
main() main()
.then(() => process.exit(0)) .then(() => process.exit(0))
.catch(error => { .catch((error) => {
console.error(error); console.error(error)
process.exit(1); process.exit(1)
}); })

View File

@ -1,7 +1,7 @@
const ethers = require('ethers') const ethers = require('ethers')
const BigNumber = ethers.BigNumber const BigNumber = ethers.BigNumber
const { bitsToNumber, toFixedHex, toBuffer, poseidonHash, poseidonHash2 } = require('./utils') const { bitsToNumber, toBuffer, poseidonHash } = require('./utils')
const jsSHA = require('jssha') const jsSHA = require('jssha')

View File

@ -1,9 +1,4 @@
/* global artifacts, web3, contract */ /* global ethers */
const { expect } = require('chai')
const MerkleTree = require('fixed-merkle-tree')
const jsSHA = require('jssha')
const { poseidonHash2 } = require('../src/utils')
const { batchTreeUpdate, prove } = require('../src/controller')
const instances = [ const instances = [
'0xc6325fa78E0764993Bf2997116A3771bCbcb3fa9', '0xc6325fa78E0764993Bf2997116A3771bCbcb3fa9',
@ -18,11 +13,9 @@ const hashes = [
'0x57f7b90a3cb4ea6860e6dd5fa44ac4f53ebe6ae3948af577a01ef51738313246', '0x57f7b90a3cb4ea6860e6dd5fa44ac4f53ebe6ae3948af577a01ef51738313246',
] ]
const levels = 20
const CHUNK_TREE_HEIGHT = 7 const CHUNK_TREE_HEIGHT = 7
describe.skip('Pack', () => { describe.skip('Pack', () => {
it('should work', async () => { it('should work', async () => {
const tree = new MerkleTree(levels, [], { hashFunction: poseidonHash2 })
const Pack = await ethers.getContractFactory('Pack') const Pack = await ethers.getContractFactory('Pack')
const pack = await Pack.deploy() const pack = await Pack.deploy()

View File

@ -1,4 +1,3 @@
/* global artifacts, web3, contract */
const { expect } = require('chai') const { expect } = require('chai')
const MerkleTree = require('fixed-merkle-tree') const MerkleTree = require('fixed-merkle-tree')
const { poseidonHash2, randomBN } = require('../src/utils') const { poseidonHash2, randomBN } = require('../src/utils')
@ -19,5 +18,7 @@ describe('Snark', () => {
} }
const data = await batchTreeUpdate(tree, events) const data = await batchTreeUpdate(tree, events)
const proof = await prove(data, './artifacts/circuits/BatchTreeUpdate') const proof = await prove(data, './artifacts/circuits/BatchTreeUpdate')
expect(proof.length).to.be.gt(0)
}) })
}) })

View File

@ -1,3 +1,4 @@
/* global ethers */
const { expect } = require('chai') const { expect } = require('chai')
const { toFixedHex, poseidonHash2, randomBN } = require('../src/utils') const { toFixedHex, poseidonHash2, randomBN } = require('../src/utils')
const MerkleTree = require('fixed-merkle-tree') const MerkleTree = require('fixed-merkle-tree')