feat: add the old snark artifacts that interep uses

This commit is contained in:
rymnc 2022-12-07 18:12:30 +05:30
parent 6c972f51b6
commit 82888ab3ba
No known key found for this signature in database
GPG Key ID: C740033EE3F41EBD
6 changed files with 59 additions and 5 deletions

View File

@ -3,7 +3,6 @@ import { ethers } from "ethers";
import { createInterepProof, sToBytes32 } from "../common"; import { createInterepProof, sToBytes32 } from "../common";
// @ts-ignore circom // @ts-ignore circom
import { poseidon } from "circomlibjs"; import { poseidon } from "circomlibjs";
import fs from "fs";
import { address, abi } from "../deployments/localhost_integration/RLN.json"; import { address, abi } from "../deployments/localhost_integration/RLN.json";

13
e2e/get-proof.ts Normal file
View File

@ -0,0 +1,13 @@
async function main() {
const { getProof } = await import("./utils");
const proof = await getProof();
console.log(proof);
console.log("SOLIDITY PROOF: ", JSON.stringify(proof.solidityProof));
}
main()
.then(() => process.exit(0))
.catch((e) => {
console.error(e);
process.exit(1);
});

42
e2e/utils.ts Normal file
View File

@ -0,0 +1,42 @@
import createIdentity from "@interep/identity";
import createProof from "@interep/proof";
import { ethers } from "ethers";
// @ts-ignore
import { poseidon } from "circomlibjs";
import { sToBytes32 } from "../common";
// if length is not 64 pad with 0
const pad = (str: string): string => (str.length === 64 ? str : pad("0" + str));
export async function getCredentials() {
const signer = new ethers.Wallet("0x" + process.env.PRIVATE_KEY);
const identity = await createIdentity(
(msg) => signer.signMessage(msg),
"Github"
);
console.log("ID COMMITMENT: " + pad(identity.getCommitment().toString(16)));
console.log(
"ID KEY: " +
pad(
poseidon([identity.getNullifier(), identity.getTrapdoor()]).toString(16)
)
);
return identity;
}
export async function getProof() {
const identity = await getCredentials();
const proof = await createProof(
identity,
"github",
"bronze",
1,
sToBytes32("foo"),
{
wasmFilePath: "./test/oldSnarkArtifacts/semaphore.wasm",
zkeyFilePath: "./test/oldSnarkArtifacts/semaphore.zkey",
},
"goerli"
);
return proof;
}

Binary file not shown.

Binary file not shown.

View File

@ -386,13 +386,13 @@
const checkChain = async (chainId) => { const checkChain = async (chainId) => {
retrieveRLNDetailsButton.disabled = retrievedRLNEvents || chainId !== 5; retrieveRLNDetailsButton.disabled = retrievedRLNEvents || chainId !== 5;
registerButton.disabled = !(chainId === 5 && retrievedRLNEvents); registerButton.disabled = !(chainId === 5 && retrievedRLNEvents);
if (chainId !== 31337) { if (chainId !== 5) {
alert("Switch to Localhost"); alert("Switch to Goerli");
} }
}; };
const rlnDeployBlk = 0; const rlnDeployBlk = 8059743;
const rlnAddress = "0x962a95edCDdcEBbB5A703f1357494009F1A10244"; const rlnAddress = "0xCd41a0aC28c5c025779eAC3208D0bF23baa3a5b6";
const rlnAbi = [ const rlnAbi = [
{ {
inputs: [ inputs: [