Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use resources after trusted setup #100

Closed
mhchia opened this issue Sep 4, 2023 · 10 comments · Fixed by #107
Closed

Use resources after trusted setup #100

mhchia opened this issue Sep 4, 2023 · 10 comments · Fixed by #107
Assignees
Labels
good first issue Good for newcomers

Comments

@mhchia
Copy link
Member

mhchia commented Sep 4, 2023

What's wrong?

Right now we're using a temporary resource, as mentioned in

// TODO: Change to a more permanent URL after trusted setup is complete
.

How to fix it?

Use the resources that can be downloaded on the trusted setup page https://ceremony.pse.dev/projects/RLN%20Trusted%20Setup%20Ceremony.

@mhchia mhchia added the good first issue Good for newcomers label Sep 5, 2023
@0xnakai
Copy link
Contributor

0xnakai commented Sep 15, 2023

I'd like to solve this problem. OK?

@mhchia
Copy link
Member Author

mhchia commented Sep 15, 2023

I'd like to solve this problem. OK?

Definitely! Thanks for taking on this. Let me know if you encounter any issues :)

@mhchia
Copy link
Member Author

mhchia commented Sep 15, 2023

These are the urls for zkeys and verification keys

{
    "circuits": [
        {
            "name": "rln-16",
            "finalZKey": "https://rln-trusted-setup-ceremony-pse-p0tion-production.s3.eu-central-1.amazonaws.com/circuits/rln-16/contributions/rln-16_final.zkey",
            "lastZKey": "https://rln-trusted-setup-ceremony-pse-p0tion-production.s3.eu-central-1.amazonaws.com/circuits/rln-16/contributions/rln-16_00061.zkey",
            "vk": "https://rln-trusted-setup-ceremony-pse-p0tion-production.s3.eu-central-1.amazonaws.com/circuits/rln-16/rln-16_vkey.json",
            "verifier": "https://rln-trusted-setup-ceremony-pse-p0tion-production.s3.eu-central-1.amazonaws.com/circuits/rln-16/rln-16_verifier.sol"
        },
        {
            "name": "rln-17",
            "finalZKey": "https://rln-trusted-setup-ceremony-pse-p0tion-production.s3.eu-central-1.amazonaws.com/circuits/rln-17/contributions/rln-17_final.zkey",
            "lastZKey": "https://rln-trusted-setup-ceremony-pse-p0tion-production.s3.eu-central-1.amazonaws.com/circuits/rln-17/contributions/rln-17_00061.zkey",
            "vk": "https://rln-trusted-setup-ceremony-pse-p0tion-production.s3.eu-central-1.amazonaws.com/circuits/rln-17/rln-17_vkey.json",
            "verifier": "https://rln-trusted-setup-ceremony-pse-p0tion-production.s3.eu-central-1.amazonaws.com/circuits/rln-17/rln-17_verifier.sol"
        },
        {
            "name": "rln-18",
            "finalZKey": "https://rln-trusted-setup-ceremony-pse-p0tion-production.s3.eu-central-1.amazonaws.com/circuits/rln-18/contributions/rln-18_final.zkey",
            "lastZKey": "https://rln-trusted-setup-ceremony-pse-p0tion-production.s3.eu-central-1.amazonaws.com/circuits/rln-18/contributions/rln-18_00061.zkey",
            "vk": "https://rln-trusted-setup-ceremony-pse-p0tion-production.s3.eu-central-1.amazonaws.com/circuits/rln-18/rln-18_vkey.json",
            "verifier": "https://rln-trusted-setup-ceremony-pse-p0tion-production.s3.eu-central-1.amazonaws.com/circuits/rln-18/rln-18_verifier.sol"
        },
        {
            "name": "rln-19",
            "finalZKey": "https://rln-trusted-setup-ceremony-pse-p0tion-production.s3.eu-central-1.amazonaws.com/circuits/rln-19/contributions/rln-19_final.zkey",
            "lastZKey": "https://rln-trusted-setup-ceremony-pse-p0tion-production.s3.eu-central-1.amazonaws.com/circuits/rln-19/contributions/rln-19_00060.zkey",
            "vk": "https://rln-trusted-setup-ceremony-pse-p0tion-production.s3.eu-central-1.amazonaws.com/circuits/rln-19/rln-19_vkey.json",
            "verifier": "https://rln-trusted-setup-ceremony-pse-p0tion-production.s3.eu-central-1.amazonaws.com/circuits/rln-19/rln-19_verifier.sol"
        },
        {
            "name": "rln-20",
            "finalZKey": "https://rln-trusted-setup-ceremony-pse-p0tion-production.s3.eu-central-1.amazonaws.com/circuits/rln-20/contributions/rln-20_final.zkey",
            "lastZKey": "https://rln-trusted-setup-ceremony-pse-p0tion-production.s3.eu-central-1.amazonaws.com/circuits/rln-20/contributions/rln-20_00060.zkey",
            "vk": "https://rln-trusted-setup-ceremony-pse-p0tion-production.s3.eu-central-1.amazonaws.com/circuits/rln-20/rln-20_vkey.json",
            "verifier": "https://rln-trusted-setup-ceremony-pse-p0tion-production.s3.eu-central-1.amazonaws.com/circuits/rln-20/rln-20_verifier.sol"
        },
        {
            "name": "rln-21",
            "finalZKey": "https://rln-trusted-setup-ceremony-pse-p0tion-production.s3.eu-central-1.amazonaws.com/circuits/rln-21/contributions/rln-21_final.zkey",
            "lastZKey": "https://rln-trusted-setup-ceremony-pse-p0tion-production.s3.eu-central-1.amazonaws.com/circuits/rln-21/contributions/rln-21_00060.zkey",
            "vk": "https://rln-trusted-setup-ceremony-pse-p0tion-production.s3.eu-central-1.amazonaws.com/circuits/rln-21/rln-21_vkey.json",
            "verifier": "https://rln-trusted-setup-ceremony-pse-p0tion-production.s3.eu-central-1.amazonaws.com/circuits/rln-21/rln-21_verifier.sol"
        },
        {
            "name": "rln-22",
            "finalZKey": "https://rln-trusted-setup-ceremony-pse-p0tion-production.s3.eu-central-1.amazonaws.com/circuits/rln-22/contributions/rln-22_final.zkey",
            "lastZKey": "https://rln-trusted-setup-ceremony-pse-p0tion-production.s3.eu-central-1.amazonaws.com/circuits/rln-22/contributions/rln-22_00059.zkey",
            "vk": "https://rln-trusted-setup-ceremony-pse-p0tion-production.s3.eu-central-1.amazonaws.com/circuits/rln-22/rln-22_vkey.json",
            "verifier": "https://rln-trusted-setup-ceremony-pse-p0tion-production.s3.eu-central-1.amazonaws.com/circuits/rln-22/rln-22_verifier.sol"
        },
        {
            "name": "rln-23",
            "finalZKey": "https://rln-trusted-setup-ceremony-pse-p0tion-production.s3.eu-central-1.amazonaws.com/circuits/rln-23/contributions/rln-23_final.zkey",
            "lastZKey": "https://rln-trusted-setup-ceremony-pse-p0tion-production.s3.eu-central-1.amazonaws.com/circuits/rln-23/contributions/rln-23_00058.zkey",
            "vk": "https://rln-trusted-setup-ceremony-pse-p0tion-production.s3.eu-central-1.amazonaws.com/circuits/rln-23/rln-23_vkey.json",
            "verifier": "https://rln-trusted-setup-ceremony-pse-p0tion-production.s3.eu-central-1.amazonaws.com/circuits/rln-23/rln-23_verifier.sol"
        },
        {
            "name": "rln-24",
            "finalZKey": "https://rln-trusted-setup-ceremony-pse-p0tion-production.s3.eu-central-1.amazonaws.com/circuits/rln-24/contributions/rln-24_final.zkey",
            "lastZKey": "https://rln-trusted-setup-ceremony-pse-p0tion-production.s3.eu-central-1.amazonaws.com/circuits/rln-24/contributions/rln-24_00058.zkey",
            "vk": "https://rln-trusted-setup-ceremony-pse-p0tion-production.s3.eu-central-1.amazonaws.com/circuits/rln-24/rln-24_vkey.json",
            "verifier": "https://rln-trusted-setup-ceremony-pse-p0tion-production.s3.eu-central-1.amazonaws.com/circuits/rln-24/rln-24_verifier.sol"
        },
        {
            "name": "rln-25",
            "finalZKey": "https://rln-trusted-setup-ceremony-pse-p0tion-production.s3.eu-central-1.amazonaws.com/circuits/rln-25/contributions/rln-25_final.zkey",
            "lastZKey": "https://rln-trusted-setup-ceremony-pse-p0tion-production.s3.eu-central-1.amazonaws.com/circuits/rln-25/contributions/rln-25_00058.zkey",
            "vk": "https://rln-trusted-setup-ceremony-pse-p0tion-production.s3.eu-central-1.amazonaws.com/circuits/rln-25/rln-25_vkey.json",
            "verifier": "https://rln-trusted-setup-ceremony-pse-p0tion-production.s3.eu-central-1.amazonaws.com/circuits/rln-25/rln-25_verifier.sol"
        },
        {
            "name": "rln-26",
            "finalZKey": "https://rln-trusted-setup-ceremony-pse-p0tion-production.s3.eu-central-1.amazonaws.com/circuits/rln-26/contributions/rln-26_final.zkey",
            "lastZKey": "https://rln-trusted-setup-ceremony-pse-p0tion-production.s3.eu-central-1.amazonaws.com/circuits/rln-26/contributions/rln-26_00058.zkey",
            "vk": "https://rln-trusted-setup-ceremony-pse-p0tion-production.s3.eu-central-1.amazonaws.com/circuits/rln-26/rln-26_vkey.json",
            "verifier": "https://rln-trusted-setup-ceremony-pse-p0tion-production.s3.eu-central-1.amazonaws.com/circuits/rln-26/rln-26_verifier.sol"
        },
        {
            "name": "rln-27",
            "finalZKey": "https://rln-trusted-setup-ceremony-pse-p0tion-production.s3.eu-central-1.amazonaws.com/circuits/rln-27/contributions/rln-27_final.zkey",
            "lastZKey": "https://rln-trusted-setup-ceremony-pse-p0tion-production.s3.eu-central-1.amazonaws.com/circuits/rln-27/contributions/rln-27_00058.zkey",
            "vk": "https://rln-trusted-setup-ceremony-pse-p0tion-production.s3.eu-central-1.amazonaws.com/circuits/rln-27/rln-27_vkey.json",
            "verifier": "https://rln-trusted-setup-ceremony-pse-p0tion-production.s3.eu-central-1.amazonaws.com/circuits/rln-27/rln-27_verifier.sol"
        },
        {
            "name": "rln-28",
            "finalZKey": "https://rln-trusted-setup-ceremony-pse-p0tion-production.s3.eu-central-1.amazonaws.com/circuits/rln-28/contributions/rln-28_final.zkey",
            "lastZKey": "https://rln-trusted-setup-ceremony-pse-p0tion-production.s3.eu-central-1.amazonaws.com/circuits/rln-28/contributions/rln-28_00058.zkey",
            "vk": "https://rln-trusted-setup-ceremony-pse-p0tion-production.s3.eu-central-1.amazonaws.com/circuits/rln-28/rln-28_vkey.json",
            "verifier": "https://rln-trusted-setup-ceremony-pse-p0tion-production.s3.eu-central-1.amazonaws.com/circuits/rln-28/rln-28_verifier.sol"
        },
        {
            "name": "rln-29",
            "finalZKey": "https://rln-trusted-setup-ceremony-pse-p0tion-production.s3.eu-central-1.amazonaws.com/circuits/rln-29/contributions/rln-29_final.zkey",
            "lastZKey": "https://rln-trusted-setup-ceremony-pse-p0tion-production.s3.eu-central-1.amazonaws.com/circuits/rln-29/contributions/rln-29_00057.zkey",
            "vk": "https://rln-trusted-setup-ceremony-pse-p0tion-production.s3.eu-central-1.amazonaws.com/circuits/rln-29/rln-29_vkey.json",
            "verifier": "https://rln-trusted-setup-ceremony-pse-p0tion-production.s3.eu-central-1.amazonaws.com/circuits/rln-29/rln-29_verifier.sol"
        },
        {
            "name": "rln-30",
            "finalZKey": "https://rln-trusted-setup-ceremony-pse-p0tion-production.s3.eu-central-1.amazonaws.com/circuits/rln-30/contributions/rln-30_final.zkey",
            "lastZKey": "https://rln-trusted-setup-ceremony-pse-p0tion-production.s3.eu-central-1.amazonaws.com/circuits/rln-30/contributions/rln-30_00057.zkey",
            "vk": "https://rln-trusted-setup-ceremony-pse-p0tion-production.s3.eu-central-1.amazonaws.com/circuits/rln-30/rln-30_vkey.json",
            "verifier": "https://rln-trusted-setup-ceremony-pse-p0tion-production.s3.eu-central-1.amazonaws.com/circuits/rln-30/rln-30_verifier.sol"
        },
        {
            "name": "rln-31",
            "finalZKey": "https://rln-trusted-setup-ceremony-pse-p0tion-production.s3.eu-central-1.amazonaws.com/circuits/rln-31/contributions/rln-31_final.zkey",
            "lastZKey": "https://rln-trusted-setup-ceremony-pse-p0tion-production.s3.eu-central-1.amazonaws.com/circuits/rln-31/contributions/rln-31_00056.zkey",
            "vk": "https://rln-trusted-setup-ceremony-pse-p0tion-production.s3.eu-central-1.amazonaws.com/circuits/rln-31/rln-31_vkey.json",
            "verifier": "https://rln-trusted-setup-ceremony-pse-p0tion-production.s3.eu-central-1.amazonaws.com/circuits/rln-31/rln-31_verifier.sol"
        },
        {
            "name": "rln-32",
            "finalZKey": "https://rln-trusted-setup-ceremony-pse-p0tion-production.s3.eu-central-1.amazonaws.com/circuits/rln-32/contributions/rln-32_final.zkey",
            "lastZKey": "https://rln-trusted-setup-ceremony-pse-p0tion-production.s3.eu-central-1.amazonaws.com/circuits/rln-32/contributions/rln-32_00056.zkey",
            "vk": "https://rln-trusted-setup-ceremony-pse-p0tion-production.s3.eu-central-1.amazonaws.com/circuits/rln-32/rln-32_vkey.json",
            "verifier": "https://rln-trusted-setup-ceremony-pse-p0tion-production.s3.eu-central-1.amazonaws.com/circuits/rln-32/rln-32_verifier.sol"
        },
        {
            "name": "rln-withdraw",
            "finalZKey": "https://rln-trusted-setup-ceremony-pse-p0tion-production.s3.eu-central-1.amazonaws.com/circuits/rln-withdraw/contributions/rln-withdraw_final.zkey",
            "lastZKey": "https://rln-trusted-setup-ceremony-pse-p0tion-production.s3.eu-central-1.amazonaws.com/circuits/rln-withdraw/contributions/rln-withdraw_00062.zkey",
            "vk": "https://rln-trusted-setup-ceremony-pse-p0tion-production.s3.eu-central-1.amazonaws.com/circuits/rln-withdraw/rln-withdraw_vkey.json",
            "verifier": "https://rln-trusted-setup-ceremony-pse-p0tion-production.s3.eu-central-1.amazonaws.com/circuits/rln-withdraw/rln-withdraw_verifier.sol"
        }
    ]
}

@0xnakai
Copy link
Contributor

0xnakai commented Sep 15, 2023

Thank you!
Which branches should I fork, 7a5a4af, which you pasted the github link, or main?

@mhchia
Copy link
Member Author

mhchia commented Sep 15, 2023

Yes, main branch works

@0xnakai
Copy link
Contributor

0xnakai commented Sep 15, 2023

Thanks!!

@0xnakai
Copy link
Contributor

0xnakai commented Sep 19, 2023

I have a question.

In order to change resourse.ts, I need 5 files.
1 const wasmFileURL = ${url}/circuit.wasm
2 const finalZkeyURL = ${url}/final.zkey
3 const verificationKeyURL = ${url}/verification_key.json

4 const wasmFileURL = ${withdrawURL}/circuit.wasm
5 const finalZkeyURL = ${withdrawURL}/final.zkey

I will use this json, which you pasted, for 2&3 . Right?

{
            "name": "rln-20",
            "finalZKey": "https://rln-trusted-setup-ceremony-pse-p0tion-production.s3.eu-central-1.amazonaws.com/circuits/rln-20/contributions/rln-20_final.zkey",
            "lastZKey": "https://rln-trusted-setup-ceremony-pse-p0tion-production.s3.eu-central-1.amazonaws.com/circuits/rln-20/contributions/rln-20_00060.zkey",
            "vk": "https://rln-trusted-setup-ceremony-pse-p0tion-production.s3.eu-central-1.amazonaws.com/circuits/rln-20/rln-20_vkey.json",
            "verifier": "https://rln-trusted-setup-ceremony-pse-p0tion-production.s3.eu-central-1.amazonaws.com/circuits/rln-20/rln-20_verifier.sol"
        },

I will use this json , which you pasted, for 5. Right?

{
            "name": "rln-withdraw",
            "finalZKey": "https://rln-trusted-setup-ceremony-pse-p0tion-production.s3.eu-central-1.amazonaws.com/circuits/rln-withdraw/contributions/rln-withdraw_final.zkey",
            "lastZKey": "https://rln-trusted-setup-ceremony-pse-p0tion-production.s3.eu-central-1.amazonaws.com/circuits/rln-withdraw/contributions/rln-withdraw_00062.zkey",
            "vk": "https://rln-trusted-setup-ceremony-pse-p0tion-production.s3.eu-central-1.amazonaws.com/circuits/rln-withdraw/rln-withdraw_vkey.json",
            "verifier": "https://rln-trusted-setup-ceremony-pse-p0tion-production.s3.eu-central-1.amazonaws.com/circuits/rln-withdraw/rln-withdraw_verifier.sol"
        }

Where is wasm file for 1&4?
I cannot find them.

Please teach them!

@mhchia
Copy link
Member Author

mhchia commented Sep 20, 2023

Thanks for pointing them out. Just updated the json to contain wasm files for each circuit. I've tested them out so they should be accessible. Please let me know if there is any issue :)

{
    "ceremonyName": "rln-trusted-setup-ceremony",
    "bucket": "https://rln-trusted-setup-ceremony-pse-p0tion-production.s3.eu-central-1.amazonaws.com/",
    "circuits": [
        {
            "name": "rln-16",
            "finalZKey": "https://rln-trusted-setup-ceremony-pse-p0tion-production.s3.eu-central-1.amazonaws.com/circuits/rln-16/contributions/rln-16_final.zkey",
            "lastZKey": "https://rln-trusted-setup-ceremony-pse-p0tion-production.s3.eu-central-1.amazonaws.com/circuits/rln-16/contributions/rln-16_00061.zkey",
            "vk": "https://rln-trusted-setup-ceremony-pse-p0tion-production.s3.eu-central-1.amazonaws.com/circuits/rln-16/rln-16_vkey.json",
            "verifier": "https://rln-trusted-setup-ceremony-pse-p0tion-production.s3.eu-central-1.amazonaws.com/circuits/rln-16/rln-16_verifier.sol",
            "wasm": "https://rln-trusted-setup-ceremony-pse-p0tion-production.s3.eu-central-1.amazonaws.com/circuits/rln-16/RLN-16.wasm"
        },
        {
            "name": "rln-17",
            "finalZKey": "https://rln-trusted-setup-ceremony-pse-p0tion-production.s3.eu-central-1.amazonaws.com/circuits/rln-17/contributions/rln-17_final.zkey",
            "lastZKey": "https://rln-trusted-setup-ceremony-pse-p0tion-production.s3.eu-central-1.amazonaws.com/circuits/rln-17/contributions/rln-17_00061.zkey",
            "vk": "https://rln-trusted-setup-ceremony-pse-p0tion-production.s3.eu-central-1.amazonaws.com/circuits/rln-17/rln-17_vkey.json",
            "verifier": "https://rln-trusted-setup-ceremony-pse-p0tion-production.s3.eu-central-1.amazonaws.com/circuits/rln-17/rln-17_verifier.sol",
            "wasm": "https://rln-trusted-setup-ceremony-pse-p0tion-production.s3.eu-central-1.amazonaws.com/circuits/rln-17/RLN-17.wasm"
        },
        {
            "name": "rln-18",
            "finalZKey": "https://rln-trusted-setup-ceremony-pse-p0tion-production.s3.eu-central-1.amazonaws.com/circuits/rln-18/contributions/rln-18_final.zkey",
            "lastZKey": "https://rln-trusted-setup-ceremony-pse-p0tion-production.s3.eu-central-1.amazonaws.com/circuits/rln-18/contributions/rln-18_00061.zkey",
            "vk": "https://rln-trusted-setup-ceremony-pse-p0tion-production.s3.eu-central-1.amazonaws.com/circuits/rln-18/rln-18_vkey.json",
            "verifier": "https://rln-trusted-setup-ceremony-pse-p0tion-production.s3.eu-central-1.amazonaws.com/circuits/rln-18/rln-18_verifier.sol",
            "wasm": "https://rln-trusted-setup-ceremony-pse-p0tion-production.s3.eu-central-1.amazonaws.com/circuits/rln-18/RLN-18.wasm"
        },
        {
            "name": "rln-19",
            "finalZKey": "https://rln-trusted-setup-ceremony-pse-p0tion-production.s3.eu-central-1.amazonaws.com/circuits/rln-19/contributions/rln-19_final.zkey",
            "lastZKey": "https://rln-trusted-setup-ceremony-pse-p0tion-production.s3.eu-central-1.amazonaws.com/circuits/rln-19/contributions/rln-19_00060.zkey",
            "vk": "https://rln-trusted-setup-ceremony-pse-p0tion-production.s3.eu-central-1.amazonaws.com/circuits/rln-19/rln-19_vkey.json",
            "verifier": "https://rln-trusted-setup-ceremony-pse-p0tion-production.s3.eu-central-1.amazonaws.com/circuits/rln-19/rln-19_verifier.sol",
            "wasm": "https://rln-trusted-setup-ceremony-pse-p0tion-production.s3.eu-central-1.amazonaws.com/circuits/rln-19/RLN-19.wasm"
        },
        {
            "name": "rln-20",
            "finalZKey": "https://rln-trusted-setup-ceremony-pse-p0tion-production.s3.eu-central-1.amazonaws.com/circuits/rln-20/contributions/rln-20_final.zkey",
            "lastZKey": "https://rln-trusted-setup-ceremony-pse-p0tion-production.s3.eu-central-1.amazonaws.com/circuits/rln-20/contributions/rln-20_00060.zkey",
            "vk": "https://rln-trusted-setup-ceremony-pse-p0tion-production.s3.eu-central-1.amazonaws.com/circuits/rln-20/rln-20_vkey.json",
            "verifier": "https://rln-trusted-setup-ceremony-pse-p0tion-production.s3.eu-central-1.amazonaws.com/circuits/rln-20/rln-20_verifier.sol",
            "wasm": "https://rln-trusted-setup-ceremony-pse-p0tion-production.s3.eu-central-1.amazonaws.com/circuits/rln-20/RLN-20.wasm"
        },
        {
            "name": "rln-21",
            "finalZKey": "https://rln-trusted-setup-ceremony-pse-p0tion-production.s3.eu-central-1.amazonaws.com/circuits/rln-21/contributions/rln-21_final.zkey",
            "lastZKey": "https://rln-trusted-setup-ceremony-pse-p0tion-production.s3.eu-central-1.amazonaws.com/circuits/rln-21/contributions/rln-21_00060.zkey",
            "vk": "https://rln-trusted-setup-ceremony-pse-p0tion-production.s3.eu-central-1.amazonaws.com/circuits/rln-21/rln-21_vkey.json",
            "verifier": "https://rln-trusted-setup-ceremony-pse-p0tion-production.s3.eu-central-1.amazonaws.com/circuits/rln-21/rln-21_verifier.sol",
            "wasm": "https://rln-trusted-setup-ceremony-pse-p0tion-production.s3.eu-central-1.amazonaws.com/circuits/rln-21/RLN-21.wasm"
        },
        {
            "name": "rln-22",
            "finalZKey": "https://rln-trusted-setup-ceremony-pse-p0tion-production.s3.eu-central-1.amazonaws.com/circuits/rln-22/contributions/rln-22_final.zkey",
            "lastZKey": "https://rln-trusted-setup-ceremony-pse-p0tion-production.s3.eu-central-1.amazonaws.com/circuits/rln-22/contributions/rln-22_00059.zkey",
            "vk": "https://rln-trusted-setup-ceremony-pse-p0tion-production.s3.eu-central-1.amazonaws.com/circuits/rln-22/rln-22_vkey.json",
            "verifier": "https://rln-trusted-setup-ceremony-pse-p0tion-production.s3.eu-central-1.amazonaws.com/circuits/rln-22/rln-22_verifier.sol",
            "wasm": "https://rln-trusted-setup-ceremony-pse-p0tion-production.s3.eu-central-1.amazonaws.com/circuits/rln-22/RLN-22.wasm"
        },
        {
            "name": "rln-23",
            "finalZKey": "https://rln-trusted-setup-ceremony-pse-p0tion-production.s3.eu-central-1.amazonaws.com/circuits/rln-23/contributions/rln-23_final.zkey",
            "lastZKey": "https://rln-trusted-setup-ceremony-pse-p0tion-production.s3.eu-central-1.amazonaws.com/circuits/rln-23/contributions/rln-23_00058.zkey",
            "vk": "https://rln-trusted-setup-ceremony-pse-p0tion-production.s3.eu-central-1.amazonaws.com/circuits/rln-23/rln-23_vkey.json",
            "verifier": "https://rln-trusted-setup-ceremony-pse-p0tion-production.s3.eu-central-1.amazonaws.com/circuits/rln-23/rln-23_verifier.sol",
            "wasm": "https://rln-trusted-setup-ceremony-pse-p0tion-production.s3.eu-central-1.amazonaws.com/circuits/rln-23/RLN-23.wasm"
        },
        {
            "name": "rln-24",
            "finalZKey": "https://rln-trusted-setup-ceremony-pse-p0tion-production.s3.eu-central-1.amazonaws.com/circuits/rln-24/contributions/rln-24_final.zkey",
            "lastZKey": "https://rln-trusted-setup-ceremony-pse-p0tion-production.s3.eu-central-1.amazonaws.com/circuits/rln-24/contributions/rln-24_00058.zkey",
            "vk": "https://rln-trusted-setup-ceremony-pse-p0tion-production.s3.eu-central-1.amazonaws.com/circuits/rln-24/rln-24_vkey.json",
            "verifier": "https://rln-trusted-setup-ceremony-pse-p0tion-production.s3.eu-central-1.amazonaws.com/circuits/rln-24/rln-24_verifier.sol",
            "wasm": "https://rln-trusted-setup-ceremony-pse-p0tion-production.s3.eu-central-1.amazonaws.com/circuits/rln-24/RLN-24.wasm"
        },
        {
            "name": "rln-25",
            "finalZKey": "https://rln-trusted-setup-ceremony-pse-p0tion-production.s3.eu-central-1.amazonaws.com/circuits/rln-25/contributions/rln-25_final.zkey",
            "lastZKey": "https://rln-trusted-setup-ceremony-pse-p0tion-production.s3.eu-central-1.amazonaws.com/circuits/rln-25/contributions/rln-25_00058.zkey",
            "vk": "https://rln-trusted-setup-ceremony-pse-p0tion-production.s3.eu-central-1.amazonaws.com/circuits/rln-25/rln-25_vkey.json",
            "verifier": "https://rln-trusted-setup-ceremony-pse-p0tion-production.s3.eu-central-1.amazonaws.com/circuits/rln-25/rln-25_verifier.sol",
            "wasm": "https://rln-trusted-setup-ceremony-pse-p0tion-production.s3.eu-central-1.amazonaws.com/circuits/rln-25/RLN-25.wasm"
        },
        {
            "name": "rln-26",
            "finalZKey": "https://rln-trusted-setup-ceremony-pse-p0tion-production.s3.eu-central-1.amazonaws.com/circuits/rln-26/contributions/rln-26_final.zkey",
            "lastZKey": "https://rln-trusted-setup-ceremony-pse-p0tion-production.s3.eu-central-1.amazonaws.com/circuits/rln-26/contributions/rln-26_00058.zkey",
            "vk": "https://rln-trusted-setup-ceremony-pse-p0tion-production.s3.eu-central-1.amazonaws.com/circuits/rln-26/rln-26_vkey.json",
            "verifier": "https://rln-trusted-setup-ceremony-pse-p0tion-production.s3.eu-central-1.amazonaws.com/circuits/rln-26/rln-26_verifier.sol",
            "wasm": "https://rln-trusted-setup-ceremony-pse-p0tion-production.s3.eu-central-1.amazonaws.com/circuits/rln-26/RLN-26.wasm"
        },
        {
            "name": "rln-27",
            "finalZKey": "https://rln-trusted-setup-ceremony-pse-p0tion-production.s3.eu-central-1.amazonaws.com/circuits/rln-27/contributions/rln-27_final.zkey",
            "lastZKey": "https://rln-trusted-setup-ceremony-pse-p0tion-production.s3.eu-central-1.amazonaws.com/circuits/rln-27/contributions/rln-27_00058.zkey",
            "vk": "https://rln-trusted-setup-ceremony-pse-p0tion-production.s3.eu-central-1.amazonaws.com/circuits/rln-27/rln-27_vkey.json",
            "verifier": "https://rln-trusted-setup-ceremony-pse-p0tion-production.s3.eu-central-1.amazonaws.com/circuits/rln-27/rln-27_verifier.sol",
            "wasm": "https://rln-trusted-setup-ceremony-pse-p0tion-production.s3.eu-central-1.amazonaws.com/circuits/rln-27/RLN-27.wasm"
        },
        {
            "name": "rln-28",
            "finalZKey": "https://rln-trusted-setup-ceremony-pse-p0tion-production.s3.eu-central-1.amazonaws.com/circuits/rln-28/contributions/rln-28_final.zkey",
            "lastZKey": "https://rln-trusted-setup-ceremony-pse-p0tion-production.s3.eu-central-1.amazonaws.com/circuits/rln-28/contributions/rln-28_00058.zkey",
            "vk": "https://rln-trusted-setup-ceremony-pse-p0tion-production.s3.eu-central-1.amazonaws.com/circuits/rln-28/rln-28_vkey.json",
            "verifier": "https://rln-trusted-setup-ceremony-pse-p0tion-production.s3.eu-central-1.amazonaws.com/circuits/rln-28/rln-28_verifier.sol",
            "wasm": "https://rln-trusted-setup-ceremony-pse-p0tion-production.s3.eu-central-1.amazonaws.com/circuits/rln-28/RLN-28.wasm"
        },
        {
            "name": "rln-29",
            "finalZKey": "https://rln-trusted-setup-ceremony-pse-p0tion-production.s3.eu-central-1.amazonaws.com/circuits/rln-29/contributions/rln-29_final.zkey",
            "lastZKey": "https://rln-trusted-setup-ceremony-pse-p0tion-production.s3.eu-central-1.amazonaws.com/circuits/rln-29/contributions/rln-29_00057.zkey",
            "vk": "https://rln-trusted-setup-ceremony-pse-p0tion-production.s3.eu-central-1.amazonaws.com/circuits/rln-29/rln-29_vkey.json",
            "verifier": "https://rln-trusted-setup-ceremony-pse-p0tion-production.s3.eu-central-1.amazonaws.com/circuits/rln-29/rln-29_verifier.sol",
            "wasm": "https://rln-trusted-setup-ceremony-pse-p0tion-production.s3.eu-central-1.amazonaws.com/circuits/rln-29/RLN-29.wasm"
        },
        {
            "name": "rln-30",
            "finalZKey": "https://rln-trusted-setup-ceremony-pse-p0tion-production.s3.eu-central-1.amazonaws.com/circuits/rln-30/contributions/rln-30_final.zkey",
            "lastZKey": "https://rln-trusted-setup-ceremony-pse-p0tion-production.s3.eu-central-1.amazonaws.com/circuits/rln-30/contributions/rln-30_00057.zkey",
            "vk": "https://rln-trusted-setup-ceremony-pse-p0tion-production.s3.eu-central-1.amazonaws.com/circuits/rln-30/rln-30_vkey.json",
            "verifier": "https://rln-trusted-setup-ceremony-pse-p0tion-production.s3.eu-central-1.amazonaws.com/circuits/rln-30/rln-30_verifier.sol",
            "wasm": "https://rln-trusted-setup-ceremony-pse-p0tion-production.s3.eu-central-1.amazonaws.com/circuits/rln-30/RLN-30.wasm"
        },
        {
            "name": "rln-31",
            "finalZKey": "https://rln-trusted-setup-ceremony-pse-p0tion-production.s3.eu-central-1.amazonaws.com/circuits/rln-31/contributions/rln-31_final.zkey",
            "lastZKey": "https://rln-trusted-setup-ceremony-pse-p0tion-production.s3.eu-central-1.amazonaws.com/circuits/rln-31/contributions/rln-31_00056.zkey",
            "vk": "https://rln-trusted-setup-ceremony-pse-p0tion-production.s3.eu-central-1.amazonaws.com/circuits/rln-31/rln-31_vkey.json",
            "verifier": "https://rln-trusted-setup-ceremony-pse-p0tion-production.s3.eu-central-1.amazonaws.com/circuits/rln-31/rln-31_verifier.sol",
            "wasm": "https://rln-trusted-setup-ceremony-pse-p0tion-production.s3.eu-central-1.amazonaws.com/circuits/rln-31/RLN-31.wasm"
        },
        {
            "name": "rln-32",
            "finalZKey": "https://rln-trusted-setup-ceremony-pse-p0tion-production.s3.eu-central-1.amazonaws.com/circuits/rln-32/contributions/rln-32_final.zkey",
            "lastZKey": "https://rln-trusted-setup-ceremony-pse-p0tion-production.s3.eu-central-1.amazonaws.com/circuits/rln-32/contributions/rln-32_00056.zkey",
            "vk": "https://rln-trusted-setup-ceremony-pse-p0tion-production.s3.eu-central-1.amazonaws.com/circuits/rln-32/rln-32_vkey.json",
            "verifier": "https://rln-trusted-setup-ceremony-pse-p0tion-production.s3.eu-central-1.amazonaws.com/circuits/rln-32/rln-32_verifier.sol",
            "wasm": "https://rln-trusted-setup-ceremony-pse-p0tion-production.s3.eu-central-1.amazonaws.com/circuits/rln-32/RLN-32.wasm"
        },
        {
            "name": "rln-withdraw",
            "finalZKey": "https://rln-trusted-setup-ceremony-pse-p0tion-production.s3.eu-central-1.amazonaws.com/circuits/rln-withdraw/contributions/rln-withdraw_final.zkey",
            "lastZKey": "https://rln-trusted-setup-ceremony-pse-p0tion-production.s3.eu-central-1.amazonaws.com/circuits/rln-withdraw/contributions/rln-withdraw_00062.zkey",
            "vk": "https://rln-trusted-setup-ceremony-pse-p0tion-production.s3.eu-central-1.amazonaws.com/circuits/rln-withdraw/rln-withdraw_vkey.json",
            "verifier": "https://rln-trusted-setup-ceremony-pse-p0tion-production.s3.eu-central-1.amazonaws.com/circuits/rln-withdraw/rln-withdraw_verifier.sol",
            "wasm": "https://rln-trusted-setup-ceremony-pse-p0tion-production.s3.eu-central-1.amazonaws.com/circuits/rln-withdraw/RLN-Withdraw.wasm"
        }
    ]
}

@0xnakai
Copy link
Contributor

0xnakai commented Sep 21, 2023

I changed resourses.ts like this using json you had send me.
(I wrote the new code after //comment out)

import { VerificationKey } from './types'

import axios from 'axios'

type ICircuitParams = {
  wasmFile: string | Uint8Array;
  finalZkey: string | Uint8Array;
}

type IRLNParams = ICircuitParams & { verificationKey: VerificationKey }
type IWithdrawParams = ICircuitParams

// TODO: Change to a more permanent URL after trusted setup is complete
// const resourcesURL = 'https://rln-resources-temp.s3.us-west-1.amazonaws.com/resources'
const resourcesURL =
  'https://rln-trusted-setup-ceremony-pse-p0tion-production.s3.eu-central-1.amazonaws.com/circuits'
const rln20URL = `${resourcesURL}/rln-20`
// const withdrawURL = `${resourcesURL}/withdraw`
const withdrawURL = `${resourcesURL}/rln-withdraw`
const treeDepthToDefaultRLNParamsURL = {
  '20': rln20URL,
}

async function downloadBinary(url: string): Promise<Uint8Array> {
  const resp = await axios.get(url, { responseType: 'arraybuffer' })
  return new Uint8Array(resp.data)
}

function parseVerificationKeyJSON(o: any): VerificationKey {
  // NOTE: This is not a complete check, to do better we can check values are of the correct type
  if (!o.protocol) throw new Error('Verification key has no protocol')
  if (!o.curve) throw new Error('Verification key has no curve')
  if (!o.nPublic) throw new Error('Verification key has no nPublic')
  if (!o.vk_alpha_1) throw new Error('Verification key has no vk_alpha_1')
  if (!o.vk_beta_2) throw new Error('Verification key has no vk_beta_2')
  if (!o.vk_gamma_2) throw new Error('Verification key has no vk_gamma_2')
  if (!o.vk_delta_2) throw new Error('Verification key has no vk_delta_2')
  if (!o.vk_alphabeta_12)
    throw new Error('Verification key has no vk_alphabeta_12')
  if (!o.IC) throw new Error('Verification key has no IC')
  return o
}

async function downloadVerificationKey(url: string): Promise<VerificationKey> {
  const resp = await axios.get(url)
  return parseVerificationKeyJSON(resp.data)
}

export async function getDefaultRLNParams(
  treeDepth: number): Promise<IRLNParams | undefined> {
  const url = treeDepthToDefaultRLNParamsURL[treeDepth.toString()]
  if (!url) {
    return undefined
  }
  // const wasmFileURL = `${url}/circuit.wasm`
  const wasmFileURL = `${url}/RLN-20.wasm`
  // const finalZkeyURL = `${url}/final.zkey`
  const finalZkeyURL = `${url}/rln-20_final.zkey`
  // const verificationKeyURL = `${url}/verification_key.json`
  const verificationKeyURL = `${url}/rln-20_vkey.json`
  const verificationKey = await downloadVerificationKey(verificationKeyURL)
  const [wasmFile, finalZkey] = await Promise.all([
    downloadBinary(wasmFileURL),
    downloadBinary(finalZkeyURL),
  ])
  return {
    wasmFile,
    finalZkey,
    verificationKey,
  }
}

export async function getDefaultWithdrawParams(): Promise<IWithdrawParams> {
  // const wasmFileURL = `${withdrawURL}/circuit.wasm`
  const wasmFileURL = `${withdrawURL}/RLN-Withdraw.wasm`
  // const finalZkeyURL = `${withdrawURL}/rln-withdraw_final.zkey`
  const finalZkeyURL = `${withdrawURL}/rln-withdraw_final.zkey`
  const [wasmFile, finalZkey] = await Promise.all([
    downloadBinary(wasmFileURL),
    downloadBinary(finalZkeyURL),
  ])
  return {
    wasmFile,
    finalZkey,
  }
}

However, I run the test. Error displays.
"TypeError: Converting circular structure to JSON" may be the cause.
I cannot understand the reason.
Do you have any idea? I do not have enough time for final presentation of zkp program. . .

nt@MacBook-Air rlnjs % npm test

> [email protected] test
> jest

 PASS  tests/field-artithmetics.test.ts
 PASS  tests/message-id-counter.test.ts
 PASS  tests/cache.test.ts (6.115 s)
 PASS  tests/circuit-wrapper.test.ts (6.236 s)
node:internal/child_process/serialization:159
    const string = JSONStringify(message) + '\n';
                   ^

TypeError: Converting circular structure to JSON
    --> starting at object with constructor 'Object'
    |     property 'socket' -> object with constructor 'Object'
    --- property '_httpMessage' closes the circle
    at stringify (<anonymous>)
    at writeChannelMessage (node:internal/child_process/serialization:159:20)
    at process.target._send (node:internal/child_process:840:17)
    at process.target.send (node:internal/child_process:740:19)
    at reportSuccess (/Users/nt/zkProjects/rlnjs/node_modules/jest-worker/build/workers/processChild.js:82:11)
 PASS  tests/rln-registry.test.ts (27.148 s)
node:internal/child_process/serialization:159
    const string = JSONStringify(message) + '\n';
                   ^

TypeError: Converting circular structure to JSON
    --> starting at object with constructor 'Object'
    |     property 'socket' -> object with constructor 'Object'
    --- property '_httpMessage' closes the circle
    at stringify (<anonymous>)
    at writeChannelMessage (node:internal/child_process/serialization:159:20)
    at process.target._send (node:internal/child_process:840:17)
    at process.target.send (node:internal/child_process:740:19)
    at reportSuccess (/Users/nt/zkProjects/rlnjs/node_modules/jest-worker/build/workers/processChild.js:82:11)
 PASS  tests/contract.test.ts (52.538 s)
node:internal/child_process/serialization:159
    const string = JSONStringify(message) + '\n';
                   ^

TypeError: Converting circular structure to JSON
    --> starting at object with constructor 'Object'
    |     property 'socket' -> object with constructor 'Object'
    --- property '_httpMessage' closes the circle
    at stringify (<anonymous>)
    at writeChannelMessage (node:internal/child_process/serialization:159:20)
    at process.target._send (node:internal/child_process:840:17)
    at process.target.send (node:internal/child_process:740:19)
    at reportSuccess (/Users/nt/zkProjects/rlnjs/node_modules/jest-worker/build/workers/processChild.js:82:11)
node:internal/child_process/serialization:159
    const string = JSONStringify(message) + '\n';
                   ^

TypeError: Converting circular structure to JSON
    --> starting at object with constructor 'Object'
    |     property 'socket' -> object with constructor 'Object'
    --- property '_httpMessage' closes the circle
    at stringify (<anonymous>)
    at writeChannelMessage (node:internal/child_process/serialization:159:20)
    at process.target._send (node:internal/child_process:840:17)
    at process.target.send (node:internal/child_process:740:19)
    at reportSuccess (/Users/nt/zkProjects/rlnjs/node_modules/jest-worker/build/workers/processChild.js:82:11)
 FAIL  tests/rln.test.ts
  ● Test suite failed to run

    Jest worker encountered 4 child process exceptions, exceeding retry limit

      at ChildProcessWorker.initialize (node_modules/jest-worker/build/workers/ChildProcessWorker.js:181:21)

A worker process has failed to exit gracefully and has been force exited. This is likely caused by tests leaking due to improper teardown. Try running with --detectOpenHandles to find leaks. Active timers can also cause this, ensure that .unref() was called on them.
------------------------|---------|----------|---------|---------|------------------------------------------------------------------------
File                    | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s                                                      
------------------------|---------|----------|---------|---------|------------------------------------------------------------------------
All files               |   62.69 |    31.31 |   53.73 |   63.32 |                                                                        
 src                    |   56.36 |    28.93 |   49.56 |   56.32 |                                                                        
  cache.ts              |   94.23 |     87.5 |   88.88 |   93.47 | 154,161-162                                                            
  circuit-wrapper.ts    |   97.36 |    66.66 |     100 |   96.87 | 132                                                                    
  common.ts             |   85.71 |      100 |      60 |   85.71 | 22,42-43                                                               
  contract-wrapper.ts   |   89.21 |     62.5 |   82.35 |   88.31 | 97-100,107,149,179-180,208-209                                         
  index.ts              |     100 |      100 |    7.69 |     100 |                                                                        
  message-id-counter.ts |     100 |      100 |     100 |     100 |                                                                        
  registry.ts           |   48.55 |    26.82 |      50 |   51.38 | ...-94,103-115,119-122,126-140,144-151,155-166,218,239,249,253,261-270 
  resources.ts          |   14.58 |        0 |       0 |      20 | 25-46,51-66,75-82                                                      
  rln.ts                |   20.75 |        0 |    4.54 |   21.91 | ...438,445,454-460,468,475-476,486,496-543,555-585,595-597,601-603,614 
 tests                  |    87.5 |    47.82 |   78.94 |   92.12 |                                                                        
  configs.ts            |      70 |        0 |     100 |     100 | 10-18                                                                  
  factories.ts          |   94.25 |    66.66 |      80 |   92.85 | 36,43,64,103,112                                                       
  utils.ts              |   86.04 |      100 |   71.42 |   86.11 | 18,42-45                                                               
------------------------|---------|----------|---------|---------|------------------------------------------------------------------------
Test Suites: 1 failed, 6 passed, 7 total
Tests:       35 passed, 35 total
Snapshots:   0 total
Time:        90.852 s
Force exiting Jest: Have you considered using `--detectOpenHandles` to detect async operations that kept running after all tests finished

@0xnakai
Copy link
Contributor

0xnakai commented Sep 22, 2023

Now resourse.ts code.

import { VerificationKey } from './types'

import axios from 'axios'

type ICircuitParams = {
  wasmFile: string | Uint8Array;
  finalZkey: string | Uint8Array;
}

type IRLNParams = ICircuitParams & { verificationKey: VerificationKey }
type IWithdrawParams = ICircuitParams

// TODO: Change to a more permanent URL after trusted setup is complete
// const resourcesURL = 'https://rln-resources-temp.s3.us-west-1.amazonaws.com/resources'
const resourcesURL =
  'https://rln-trusted-setup-ceremony-pse-p0tion-production.s3.eu-central-1.amazonaws.com/circuits'
const rln20URL = `${resourcesURL}/rln-20`
// const withdrawURL = `${resourcesURL}/withdraw`
const withdrawURL = `${resourcesURL}/rln-withdraw`
const treeDepthToDefaultRLNParamsURL = {
  '20': rln20URL,
}

async function downloadBinary(url: string): Promise<Uint8Array> {
  const resp = await axios.get(url, { responseType: 'arraybuffer' })
  return new Uint8Array(resp.data)
}

function parseVerificationKeyJSON(o: any): VerificationKey {
  // NOTE: This is not a complete check, to do better we can check values are of the correct type
  if (!o.protocol) throw new Error('Verification key has no protocol')
  if (!o.curve) throw new Error('Verification key has no curve')
  if (!o.nPublic) throw new Error('Verification key has no nPublic')
  if (!o.vk_alpha_1) throw new Error('Verification key has no vk_alpha_1')
  if (!o.vk_beta_2) throw new Error('Verification key has no vk_beta_2')
  if (!o.vk_gamma_2) throw new Error('Verification key has no vk_gamma_2')
  if (!o.vk_delta_2) throw new Error('Verification key has no vk_delta_2')
  if (!o.vk_alphabeta_12)
    throw new Error('Verification key has no vk_alphabeta_12')
  if (!o.IC) throw new Error('Verification key has no IC')
  return o
}

async function downloadVerificationKey(url: string): Promise<VerificationKey> {
  const resp = await axios.get(url)
  return parseVerificationKeyJSON(resp.data)
}

export async function getDefaultRLNParams(treeDepth: number): Promise<IRLNParams | undefined> {
  const url = treeDepthToDefaultRLNParamsURL[treeDepth.toString()]
  if (!url) {
    return undefined
  }
  // const wasmFileURL = `${url}/circuit.wasm`
  const wasmFileURL = `${url}/RLN-20.wasm`
  // const finalZkeyURL = `${url}/final.zkey`
  const finalZkeyURL = `${url}/contributions/rln-20_final.zkey`
  console.log(url)
  console.log(wasmFileURL)
  console.log(finalZkeyURL)
  // const verificationKeyURL = `${url}/verification_key.json`
  const verificationKeyURL = `${url}/rln-20_vkey.json`
  const verificationKey = await downloadVerificationKey(verificationKeyURL)
  const [wasmFile, finalZkey] = await Promise.all([
    downloadBinary(wasmFileURL),
    downloadBinary(finalZkeyURL),
  ])
  return {
    wasmFile,
    finalZkey,
    verificationKey,
  }
}

export async function getDefaultWithdrawParams(): Promise<IWithdrawParams> {
  // const wasmFileURL = `${withdrawURL}/circuit.wasm`
  const wasmFileURL = `${withdrawURL}/RLN-Withdraw.wasm`
  // const finalZkeyURL = `${withdrawURL}/rln-withdraw_final.zkey`
  const finalZkeyURL = `${withdrawURL}/contributions/rln-withdraw_final.zkey`
  const [wasmFile, finalZkey] = await Promise.all([
    downloadBinary(wasmFileURL),
    downloadBinary(finalZkeyURL),
  ])
  return {
    wasmFile,
    finalZkey,
  }
}

@mhchia mhchia linked a pull request Sep 25, 2023 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants