Skip to content

Commit

Permalink
Merge pull request #4301 from ethereum/zkp_readme
Browse files Browse the repository at this point in the history
Zkp update readme
  • Loading branch information
yann300 authored Dec 6, 2023
2 parents f0c31cb + 41b7807 commit f7d8f4d
Show file tree
Hide file tree
Showing 10 changed files with 115 additions and 43 deletions.
5 changes: 5 additions & 0 deletions apps/doc-viewer/src/app/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,14 @@ export default function App() {
setContents(fileContents)
})
}, [])
const edit = () => {
if (!client.mdFile) return
client.call('fileManager', 'open' as any, client.mdFile)
}
return (
<>
<div className="m-5 p-2">
<button className="btn btn-secondary mb-2" onClick={edit}>EDIT</button>
<ReactMarkdown children={contents} remarkPlugins={[remarkGfm]} />
</div>
</>
Expand Down
13 changes: 11 additions & 2 deletions apps/doc-viewer/src/app/docviewer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import EventEmitter from 'events'
export class DocViewer extends PluginClient {
mdFile: string
eventEmitter: EventEmitter
refreshId: any
constructor() {
super()
this.eventEmitter = new EventEmitter()
Expand All @@ -14,9 +15,17 @@ export class DocViewer extends PluginClient {
this.onload()
}

async viewDocs(docs: string[]) {
this.mdFile = docs[0]
private async refresh() {
if (!this.mdFile) return clearInterval(this.refreshId)
const contents = await this.call('fileManager', 'readFile', this.mdFile)
this.eventEmitter.emit('contentsReady', contents)
}

async viewDocs(docs: string[]) {
this.mdFile = docs[0]
this.refresh()
this.refreshId = setInterval(async () => {
this.refresh()
}, 500)
}
}
9 changes: 7 additions & 2 deletions libs/remix-ui/workspace/src/lib/actions/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -344,8 +344,13 @@ export const emitContextMenuEvent = async (cmd: customAction) => {
}

export const handleClickFile = async (path: string, type: 'file' | 'folder' | 'gist') => {
await plugin.fileManager.open(path)
dispatch(focusElement([{ key: path, type }]))
if (type === 'file' && path.endsWith('.md')) {
// just opening the preview
await plugin.call('doc-viewer' as any, 'viewDocs', [path])
} else {
await plugin.fileManager.open(path)
dispatch(focusElement([{ key: path, type }]))
}
}

export const handleExpandPath = (paths: string[]) => {
Expand Down
35 changes: 35 additions & 0 deletions libs/remix-ws-templates/src/templates/hashchecker/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@

## CIRCOM ZKP Hash Checker WORKSPACE

Welcome to the Remix Circom ZKP Hash Checker Workspace.

The workspace comprises two main directories:

### circuits: Contains sample Hash Checker contracts. These can be compiled to generate a witness using 'Circom ZKP Compiler' plugin.

### scripts: Provides a sample script designed for a trusted setup using snarkjs. This script also aids in generating Solidity code, which is essential for on-chain deployment.

### first steps:

#### 1) compile the hash checker circuit using the remix circom compiler. This will generate artifacts.

#### 2) execute the file `run_setup.ts`:

This step generate a verification key that can be used for generating proof, it will also generate a Solidity contract for on-chain verification.

Note that this section should only be used for development purposes as this way of running the setup is heavily centralized (although some pieces of this script can be used to achieve that).

This generates a verification key (`./zk/build/verification_key.json`) and artifacts from the setup (`./zk/build/zk_setup.txt`).

#### 3) execute the file `run_verification.ts`:

This script:

- generate a witness and a proof of execution. The input parameters of `snarkjs.wtns.calculate` are:

- 4 values, that should remain private. We want to verify that we know a hash that satisfy these 4 values.
- a hash, this is a public signal.

The witness will be generated only if the provided hash is the poseidon hash of these 4 values.

- verify that the proof is valid `(snarkjs.groth16.verify)`
10 changes: 0 additions & 10 deletions libs/remix-ws-templates/src/templates/hashchecker/README.txt

This file was deleted.

2 changes: 1 addition & 1 deletion libs/remix-ws-templates/src/templates/hashchecker/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ export default async () => {
// @ts-ignore
'templates/groth16_verifier.sol.ejs': (await import('!!raw-loader!./templates/groth16_verifier.sol.ejs')).default,
// @ts-ignore
'README.txt': (await import('raw-loader!./README.txt')).default
'README.md': (await import('raw-loader!./README.md')).default
}
}
46 changes: 29 additions & 17 deletions libs/remix-ws-templates/src/templates/rln/README.md
Original file line number Diff line number Diff line change
@@ -1,26 +1,38 @@
<h1 align=center>Rate-Limiting Nullifier circuits in Circom</h1>
<p align="center">
<img src="https://github.com/Rate-Limiting-Nullifier/rln-circuits-v2/workflows/Test/badge.svg" width="110">
</p>

<div align="center">

## What's RLN?

*The project was audited by Veridise, yAcademy fellows and internally.*
Welcome to the Remix Circom ZKP RLN Workspace.

</div>
RLN is a zero-knowledge gadget that enables spam prevention in anonymous environments.
To learn more on RLN and how it works - check out [documentation](https://rate-limiting-nullifier.github.io/rln-docs/).

___
The workspace comprises two main directories:

## What's RLN?
### circuits: Contains sample semaphore contracts. These can be compiled to generate a witness using 'Circom ZKP Compiler' plugin.

RLN is a zero-knowledge gadget that enables spam
prevention in anonymous environments.
### scripts: Provides a sample script designed for a trusted setup using snarkjs. This script also aids in generating Solidity code, which is essential for on-chain deployment.

The core parts of RLN are:
* zk-circuits in Circom (this repo);
* [registry smart-contract](https://github.com/Rate-Limiting-Nullifier/rln-contract);
* set of libraries to build app with RLN ([rlnjs](https://github.com/Rate-Limiting-Nullifier/rlnjs), [zerokit](https://github.com/vacp2p/zerokit)).
### first steps:

---
#### 1) compile the semaphore circuit using the remix circom compiler. This will generate artifacts.

To learn more on RLN and how it works - check out [documentation](https://rate-limiting-nullifier.github.io/rln-docs/).
#### 2) execute the file `run_setup.ts`:

This step generate a verification key that can be used for generating proof, it will also generate a Solidity contract for on-chain verification.

Note that this section should only be used for development purposes as this way of running the setup is heavily centralized (although some pieces of this script can be used to achieve that).

This generates a verification key (`./zk/build/verification_key.json`) and artifacts from the setup (`./zk/build/zk_setup.txt`).

#### 3) execute the file `run_verification.ts`:

This script:

- create a list of identity commitments and add it to a `IncrementalMerkleTree`. The tree is used to generate a merkle proof that a specified identity is actually in the tree (see`tree.createProof(0)`).

- generate a witness and a proof of execution with `messageId`equal to 0.

- generate a witness and a proof of execution with `messageId`equal to 0.

- generating 2 proofs (two different messages) with the same `messageId` reveal the two points of the polynomial necessary to deduct the `identitySecret` (using `shamirRecovery`).
26 changes: 26 additions & 0 deletions libs/remix-ws-templates/src/templates/semaphore/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@

## CIRCOM ZKP SEMAPHORE WORKSPACE

Welcome to the Remix Circom ZKP Semaphore Workspace.

The workspace comprises two main directories:

### circuits: Contains sample semaphore contracts. These can be compiled to generate a witness using 'Circom ZKP Compiler' plugin.

### scripts: Provides a sample script designed for a trusted setup using snarkjs. This script also aids in generating Solidity code, which is essential for on-chain deployment.

### first steps:

#### 1) compile the semaphore circuit using the remix circom compiler. This will generate artifacts.

#### 2) execute the file `run_setup.ts`:
This step generate a verification key that can be used for generating proof, it will also generate a Solidity contract for on-chain verification.
Note that this section should only be used for development purposes as this way of running the setup is heavily centralized (although some pieces of this script can be used to achieve that).
This generates a verification key (`./zk/build/verification_key.json`) and artifacts from the setup (`./zk/build/zk_setup.txt`).

#### 3) execute the file `run_verification.ts`:
This script:
- create a list of identity commitments and add it to a `IncrementalMerkleTree`. The tree is used to generate a merkle proof that a specified identity is actually in the tree (see`tree.createProof(0)`).
- generate a witness and a proof of execution.
- verify that the proof is valid `(snarkjs.groth16.verify)`
- ultimately verify that the hash generated by the circom compiler is the same as the root hash for the Tree. `(proof1.root.toString() === publicSignals[0]`). This assert that the identity provided to the circuit is actually part of that semaphore group.
10 changes: 0 additions & 10 deletions libs/remix-ws-templates/src/templates/semaphore/README.txt

This file was deleted.

2 changes: 1 addition & 1 deletion libs/remix-ws-templates/src/templates/semaphore/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ export default async () => {
// @ts-ignore
'templates/groth16_verifier.sol.ejs': (await import('!!raw-loader!./templates/groth16_verifier.sol.ejs')).default,
// @ts-ignore
'README.txt': (await import('raw-loader!./README.txt')).default
'README.md': (await import('raw-loader!./README.md')).default
}
}

0 comments on commit f7d8f4d

Please sign in to comment.