-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from ZkNoid/one_round_contract
One round contract
- Loading branch information
Showing
35 changed files
with
2,610 additions
and
2,743 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
bafkreif2ett25ddjcevhnmaxmimkjdoigtsaj6bfyfil5gu65l2r6luxqm | ||
bafkreicnannsz4gqqk3ccfwfd3z2hfzonr63z3hgsplefgrmz37psay23y |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,29 @@ | ||
import { getPLottery } from '../src/PLottery.js'; | ||
import { DistributionProgram } from '../src/Proofs/DistributionProof.js'; | ||
import { writeFileSync } from 'fs'; | ||
import { PublicKey } from 'o1js'; | ||
import { findPlottery } from './utils.js'; | ||
// import { getPLottery } from '../src/PLottery.js'; | ||
// import { DistributionProgram } from '../src/Proofs/DistributionProof.js'; | ||
// import { writeFileSync } from 'fs'; | ||
// import { PublicKey } from 'o1js'; | ||
// import { findPlottery } from './utils.js'; | ||
|
||
let { PLottery } = findPlottery(); | ||
// let { PLottery } = findPlottery(); | ||
|
||
const lotteryResult = await PLottery.analyzeMethods(); | ||
const distributionResult = await DistributionProgram.analyzeMethods(); | ||
// const lotteryResult = await PLottery.analyzeMethods(); | ||
// const distributionResult = await DistributionProgram.analyzeMethods(); | ||
|
||
if (!PLottery._methods) { | ||
console.log("Can't find methods for Lottery"); | ||
throw new Error("Can't find methods for Lottery"); | ||
} | ||
// if (!PLottery._methods) { | ||
// console.log("Can't find methods for Lottery"); | ||
// throw new Error("Can't find methods for Lottery"); | ||
// } | ||
|
||
let result: { [name: string]: number } = {}; | ||
// let result: { [name: string]: number } = {}; | ||
|
||
for (const method of PLottery._methods) { | ||
result[`Lottery_${method.methodName}`] = | ||
lotteryResult[method.methodName].rows; | ||
} | ||
// for (const method of PLottery._methods) { | ||
// result[`Lottery_${method.methodName}`] = | ||
// lotteryResult[method.methodName].rows; | ||
// } | ||
|
||
result[`DistributionProof_init`] = distributionResult.init.rows; | ||
result[`DistibutionProof_addTicket`] = distributionResult.addTicket.rows; | ||
// result[`DistributionProof_init`] = distributionResult.init.rows; | ||
// result[`DistibutionProof_addTicket`] = distributionResult.addTicket.rows; | ||
|
||
console.log(result); | ||
// console.log(result); | ||
|
||
writeFileSync('analyze_result.json', JSON.stringify(result, null, 2)); | ||
// writeFileSync('analyze_result.json', JSON.stringify(result, null, 2)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,29 @@ | ||
import { Field, Mina, Poseidon } from 'o1js'; | ||
import { RandomManagerManager } from '../src/StateManager/RandomManagerManager'; | ||
import { | ||
compileRandomManager, | ||
configDefaultInstance, | ||
findPlottery, | ||
findRandomManager, | ||
getDeployer, | ||
getRMStoreManager, | ||
storeRMStoreManager, | ||
} from './utils'; | ||
import { CommitValue } from '../src/Random/RandomManager'; | ||
// import { Field, Mina, Poseidon } from 'o1js'; | ||
// import { RandomManagerManager } from '../src/StateManager/RandomManagerManager'; | ||
// import { | ||
// compileRandomManager, | ||
// configDefaultInstance, | ||
// findPlottery, | ||
// findRandomManager, | ||
// getDeployer, | ||
// getRMStoreManager, | ||
// storeRMStoreManager, | ||
// } from './utils'; | ||
// import { CommitValue } from '../src/Random/RandomManager'; | ||
|
||
configDefaultInstance(); | ||
// configDefaultInstance(); | ||
|
||
let deploy_epoch = process.argv[2] ? process.argv[2] : 'current'; | ||
// let deploy_epoch = process.argv[2] ? process.argv[2] : 'current'; | ||
|
||
let { deployer, deployerKey } = getDeployer(); | ||
// let { deployer, deployerKey } = getDeployer(); | ||
|
||
let { randomManager } = findRandomManager(deploy_epoch); | ||
// let { randomManager } = findRandomManager(deploy_epoch); | ||
|
||
await compileRandomManager(deploy_epoch); | ||
// await compileRandomManager(deploy_epoch); | ||
|
||
let tx = await Mina.transaction(deployer, async () => { | ||
await randomManager.callZkon(); | ||
}); | ||
// let tx = await Mina.transaction(deployer, async () => { | ||
// await randomManager.callZkon(); | ||
// }); | ||
|
||
await tx.prove(); | ||
await tx.sign([deployerKey]).send(); | ||
// await tx.prove(); | ||
// await tx.sign([deployerKey]).send(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,47 @@ | ||
import { Field, Mina } from 'o1js'; | ||
import { RandomManagerManager } from '../src/StateManager/RandomManagerManager'; | ||
import { | ||
compileRandomManager, | ||
configDefaultInstance, | ||
findPlottery, | ||
findRandomManager, | ||
getDeployer, | ||
getRMStoreManager, | ||
storeRMStoreManager, | ||
} from './utils'; | ||
import { CommitValue } from '../src/Random/RandomManager'; | ||
// import { Field, Mina } from 'o1js'; | ||
// import { RandomManagerManager } from '../src/StateManager/RandomManagerManager'; | ||
// import { | ||
// compileRandomManager, | ||
// configDefaultInstance, | ||
// findPlottery, | ||
// findRandomManager, | ||
// getDeployer, | ||
// getRMStoreManager, | ||
// storeRMStoreManager, | ||
// } from './utils'; | ||
// import { CommitValue } from '../src/Random/RandomManager'; | ||
|
||
configDefaultInstance(); | ||
// configDefaultInstance(); | ||
|
||
let round = process.argv[2]; | ||
// let round = process.argv[2]; | ||
|
||
if (!round) { | ||
throw Error(`You should specify round`); | ||
} | ||
// if (!round) { | ||
// throw Error(`You should specify round`); | ||
// } | ||
|
||
let deploy_epoch = process.argv[3] ? process.argv[3] : 'current'; | ||
// let deploy_epoch = process.argv[3] ? process.argv[3] : 'current'; | ||
|
||
let { deployer, deployerKey } = getDeployer(); | ||
// let { deployer, deployerKey } = getDeployer(); | ||
|
||
let { randomManager } = findRandomManager(deploy_epoch); | ||
// let { randomManager } = findRandomManager(deploy_epoch); | ||
|
||
await compileRandomManager(deploy_epoch); | ||
// await compileRandomManager(deploy_epoch); | ||
|
||
let rmStoreManager: RandomManagerManager = getRMStoreManager(deploy_epoch); | ||
// let rmStoreManager: RandomManagerManager = getRMStoreManager(deploy_epoch); | ||
|
||
let value = Field.random(); | ||
let salt = Field.random(); | ||
let commitValue = new CommitValue({ value, salt }); | ||
// let value = Field.random(); | ||
// let salt = Field.random(); | ||
// let commitValue = new CommitValue({ value, salt }); | ||
|
||
const { witness: commitRoundWitness } = rmStoreManager.getCommitWitness(+round); | ||
// const { witness: commitRoundWitness } = rmStoreManager.getCommitWitness(+round); | ||
|
||
let tx = await Mina.transaction(deployer, async () => { | ||
await randomManager.commit(commitValue, commitRoundWitness); | ||
}); | ||
// let tx = await Mina.transaction(deployer, async () => { | ||
// await randomManager.commit(commitValue, commitRoundWitness); | ||
// }); | ||
|
||
await tx.prove(); | ||
await tx.sign([deployerKey]).send(); | ||
// await tx.prove(); | ||
// await tx.sign([deployerKey]).send(); | ||
|
||
rmStoreManager.addCommit(+round, commitValue); | ||
// rmStoreManager.addCommit(+round, commitValue); | ||
|
||
storeRMStoreManager(rmStoreManager, deploy_epoch); | ||
// storeRMStoreManager(rmStoreManager, deploy_epoch); |
Oops, something went wrong.