Skip to content

Commit

Permalink
Merge pull request #10 from zkparty/feat/nico/entropy-input
Browse files Browse the repository at this point in the history
Feat/nico/entropy input
  • Loading branch information
glamperd authored Jul 14, 2023
2 parents 71b7f44 + 8067dc5 commit 25a1b10
Show file tree
Hide file tree
Showing 15 changed files with 947 additions and 556 deletions.
45 changes: 45 additions & 0 deletions packages/backend/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,51 @@

> TODO: description
## Instructions to run

Before running the `backend` you would need the `powersOfTau28_hez_final_14.ptau`, `circuits/semaphore01` and `circuits/semaphore02` files. To generate them you can run the following commands:

```bash
# 1. Install circom following https://docs.circom.io/getting-started/installation/

# 2. Install snarkjs
npm install -g snarkjs

# 3. Clone the semaphore repo
git clone https://github.com/semaphore-protocol/semaphore

# 4. Move to the circuits folder
cd packages/circuits

# 5. Install dependencies
yarn install

# 6. Remember to change ../node_modules to ../../node_modules
# in semaphore.circom and tree.circom

# 7. Generate the circuits
circom --r1cs --wasm -o ./ ./semaphore.circom

# 8. Download the .ptau file
wget https://hermez.s3-eu-west-1.amazonaws.com/powersOfTau28_hez_final_15.ptau

# 9. Generate the 0001 key
snarkjs g16s ./semaphore.r1cs ./powersOfTau28_hez_final_15.ptau semaphore_0001.zkey

# 10. Generate the 0002 key
snarkjs g16s ./semaphore.r1cs ./powersOfTau28_hez_final_15.ptau semaphore_0002.zkey
```

To run the `backend` package you need to follow and execute these steps:

```bash
# 1. Install dependencies
yarn install

# 2. Run the backend
yarn backend start
```

## Usage

```
Expand Down
3 changes: 3 additions & 0 deletions packages/frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@
"@mui/material": "^5.13.5",
"@mui/styled-engine": "npm:@mui/styled-engine-sc@latest",
"@mui/styled-engine-sc": "^5.12.0",
"@mui/styles": "^5.13.7",
"@mui/x-data-grid": "^6.8.0",
"@noble/bls12-381": "^1.4.0",
"@noble/hashes": "^1.3.1",
"@types/material-ui": "^0.21.12",
"css-minimizer-webpack-plugin": "^5.0.0",
"dayjs": "^1.11.7",
Expand Down
2 changes: 1 addition & 1 deletion packages/frontend/public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="icon" href="favicon.ico" />
<link rel="icon" href="pse_logo.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<meta name="trusted setup" content="" />
Expand Down
78 changes: 38 additions & 40 deletions packages/frontend/src/app/ParticipantSection.tsx
Original file line number Diff line number Diff line change
@@ -1,58 +1,56 @@
import { useContext, useEffect, useRef } from "react";
import { Typography } from '@mui/material';
import { useContext, useEffect } from 'react'
import { Typography } from '@mui/material'

import { State } from "../types/ceremony";
import { State } from '../types/ceremony'

import WelcomePanel from "../components/WelcomePanel";
import ProgressPanel from "../components/ProgressPanel";
import LoginPanel from "../components/LoginPanel";
import state from '../contexts/state';
import { observer } from 'mobx-react-lite';
import { useSnackbar } from "notistack";
import AttestationPanel from "../components/AttestationPanel";
import WelcomePanel from '../components/WelcomePanel'
import ProgressPanel from '../components/ProgressPanel'
import LoginPanel from '../components/LoginPanel'
import state from '../contexts/state'
import { observer } from 'mobx-react-lite'
import { useSnackbar } from 'notistack'
import AttestationPanel from '../components/AttestationPanel'


const stepText = (step: string) => (<Typography align="center">{step}</Typography>);
const stepText = (step: string) => (
<Typography align="center">{step}</Typography>
)

const ParticipantSection = observer(() => {
const { ceremony } = useContext(state) as State;
const { enqueueSnackbar } = useSnackbar();
const { ceremony } = useContext(state) as State
const { enqueueSnackbar } = useSnackbar()

const { inQueue, loadingInitial, contributionHashes, authenticated, ceremonyState } = ceremony;
const { inQueue, loadingInitial, contributionHashes, ceremonyState } =
ceremony

const statusUpdate = (message: string) => {
enqueueSnackbar(message);
};
enqueueSnackbar(message)
}

const { contributionUpdates } = ceremony;
const { contributionUpdates } = ceremony
useEffect(() => {
if (contributionUpdates.length > 0) {
statusUpdate(contributionUpdates[contributionUpdates.length - 1]);
}
}, [contributionUpdates.length] );
statusUpdate(contributionUpdates[contributionUpdates.length - 1])
}
}, [contributionUpdates.length])

const { circuitStats } = ceremonyState;
const done = (contributionHashes
? (Object.keys(contributionHashes).length >= circuitStats?.length)
: false);
const { circuitStats } = ceremonyState
const done = contributionHashes
? Object.keys(contributionHashes).length >= circuitStats?.length
: false

let content = (<></>);
if (loadingInitial || !authenticated ) {
let content = <></>
if (loadingInitial) {
// Display welcome text until the 'go ahead' button is clicked.
content = (<WelcomePanel />);
} else if (!inQueue && !(contributionHashes?.length>0) && !done) {
content = (<LoginPanel />);
content = <WelcomePanel />
} else if (!inQueue && !(contributionHashes?.length > 0) && !done) {
content = <LoginPanel />
} else if (done) {
content = (<AttestationPanel />);
content = <AttestationPanel />
} else {
content = (<ProgressPanel />);
};
content = <ProgressPanel />
}

return (
<div>
{content}
</div>
);
});
return <div>{content}</div>
})

export default ParticipantSection;
export default ParticipantSection
Loading

0 comments on commit 25a1b10

Please sign in to comment.