-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(verification): fixed hardhat task
refactored hardhat task to include authentication, and cleanup
- Loading branch information
Showing
6 changed files
with
67 additions
and
37 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
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,36 +1,57 @@ | ||
import { task } from "hardhat/config" | ||
import { cwd } from "process" | ||
import { verifyCeremony } from "./contracts" | ||
import { initializeUserServices } from "../../test/utils" | ||
import { | ||
createMockUser, | ||
deleteAdminApp, | ||
generatePseudoRandomStringOfNumbers, | ||
initializeAdminServices, | ||
initializeUserServices | ||
} from "../../test/utils" | ||
|
||
task("verifyCeremony", "A task that can be used to verify a ceremony finalization validity") | ||
.addPositionalParam("ceremonyPrefix") | ||
.addPositionalParam("outputDirectory") | ||
.addPositionalParam("solidityVersion") | ||
.addPositionalParam("wasmPath") | ||
.addPositionalParam("circuitInputs") | ||
.addPositionalParam("verifierTemplatePath") | ||
.addPositionalParam("coordinatorUID") | ||
.addPositionalParam("circuitInputsPath") | ||
.setAction(async (taskArgs, hre) => { | ||
// get a signer | ||
const [deployer] = await hre.ethers.getSigners() | ||
|
||
// init user app | ||
const { userFirestore, userFunctions } = initializeUserServices() | ||
// init user and admin app | ||
const { adminAuth, adminFirestore } = initializeAdminServices() | ||
const { userApp, userFirestore, userFunctions } = initializeUserServices() | ||
|
||
// verify ceremony | ||
await verifyCeremony( | ||
userFunctions, | ||
userFirestore, | ||
taskArgs.ceremonyPrefix, | ||
taskArgs.outputDirectory, | ||
taskArgs.solidityVersion, | ||
taskArgs.wasmPath, | ||
taskArgs.circuitInputs, | ||
taskArgs.verifierTemplatePath, | ||
deployer, | ||
taskArgs.coordinatorUID | ||
) | ||
const outputDirectory = `${cwd()}/test/data/artifacts/verification/` | ||
const verifierTemplatePath = `${cwd()}/../../node_modules/snarkjs/templates/verifier_groth16.sol.ejs` | ||
|
||
// if we are here it is because it didn't throw so we can safely assume that it all was veriifer | ||
console.log(`[+] The artifacts generated by the ceremony ${taskArgs.ceremonyPrefix} are valid`) | ||
// create user | ||
const coordinatorEmail = "coordinator@email.com" | ||
const coordinatorPassword = generatePseudoRandomStringOfNumbers(20) | ||
const coordinatorUID = await createMockUser(userApp, coordinatorEmail, coordinatorPassword, true, adminAuth) | ||
|
||
try { | ||
// verify ceremony | ||
await verifyCeremony( | ||
userFunctions, | ||
userFirestore, | ||
taskArgs.ceremonyPrefix, | ||
outputDirectory, | ||
taskArgs.wasmPath, | ||
taskArgs.circuitInputs, | ||
verifierTemplatePath, | ||
deployer | ||
) | ||
|
||
// if we are here it is because it didn't throw so we can safely assume that it all was veriifer | ||
console.log(`[+] The artifacts generated by the ceremony ${taskArgs.ceremonyPrefix} are valid\n`) | ||
} catch (err: any) { | ||
console.log(`[-] Could not verify the ceremony validity. ${err.toString()}\n`) | ||
} finally { | ||
// Clean ceremony and user from DB. | ||
await adminFirestore.collection("users").doc(coordinatorUID).delete() | ||
// Remove Auth user. | ||
await adminAuth.deleteUser(coordinatorUID) | ||
// Delete admin app. | ||
await deleteAdminApp() | ||
} | ||
}) |
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
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