Merge pull request #4301 from ethereum/zkp_readme

Zkp update readme
pull/4309/head
yann300 1 year ago committed by GitHub
commit f7d8f4df1b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 5
      apps/doc-viewer/src/app/App.tsx
  2. 13
      apps/doc-viewer/src/app/docviewer.ts
  3. 9
      libs/remix-ui/workspace/src/lib/actions/index.ts
  4. 35
      libs/remix-ws-templates/src/templates/hashchecker/README.md
  5. 10
      libs/remix-ws-templates/src/templates/hashchecker/README.txt
  6. 2
      libs/remix-ws-templates/src/templates/hashchecker/index.ts
  7. 46
      libs/remix-ws-templates/src/templates/rln/README.md
  8. 26
      libs/remix-ws-templates/src/templates/semaphore/README.md
  9. 10
      libs/remix-ws-templates/src/templates/semaphore/README.txt
  10. 2
      libs/remix-ws-templates/src/templates/semaphore/index.ts

@ -12,9 +12,14 @@ export default function App() {
setContents(fileContents) setContents(fileContents)
}) })
}, []) }, [])
const edit = () => {
if (!client.mdFile) return
client.call('fileManager', 'open' as any, client.mdFile)
}
return ( return (
<> <>
<div className="m-5 p-2"> <div className="m-5 p-2">
<button className="btn btn-secondary mb-2" onClick={edit}>EDIT</button>
<ReactMarkdown children={contents} remarkPlugins={[remarkGfm]} /> <ReactMarkdown children={contents} remarkPlugins={[remarkGfm]} />
</div> </div>
</> </>

@ -5,6 +5,7 @@ import EventEmitter from 'events'
export class DocViewer extends PluginClient { export class DocViewer extends PluginClient {
mdFile: string mdFile: string
eventEmitter: EventEmitter eventEmitter: EventEmitter
refreshId: any
constructor() { constructor() {
super() super()
this.eventEmitter = new EventEmitter() this.eventEmitter = new EventEmitter()
@ -14,9 +15,17 @@ export class DocViewer extends PluginClient {
this.onload() this.onload()
} }
async viewDocs(docs: string[]) { private async refresh() {
this.mdFile = docs[0] if (!this.mdFile) return clearInterval(this.refreshId)
const contents = await this.call('fileManager', 'readFile', this.mdFile) const contents = await this.call('fileManager', 'readFile', this.mdFile)
this.eventEmitter.emit('contentsReady', contents) this.eventEmitter.emit('contentsReady', contents)
} }
async viewDocs(docs: string[]) {
this.mdFile = docs[0]
this.refresh()
this.refreshId = setInterval(async () => {
this.refresh()
}, 500)
}
} }

@ -344,8 +344,13 @@ export const emitContextMenuEvent = async (cmd: customAction) => {
} }
export const handleClickFile = async (path: string, type: 'file' | 'folder' | 'gist') => { export const handleClickFile = async (path: string, type: 'file' | 'folder' | 'gist') => {
await plugin.fileManager.open(path) if (type === 'file' && path.endsWith('.md')) {
dispatch(focusElement([{ key: path, type }])) // 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[]) => { export const handleExpandPath = (paths: string[]) => {

@ -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)`

@ -1,10 +0,0 @@
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.

@ -9,6 +9,6 @@ export default async () => {
// @ts-ignore // @ts-ignore
'templates/groth16_verifier.sol.ejs': (await import('!!raw-loader!./templates/groth16_verifier.sol.ejs')).default, 'templates/groth16_verifier.sol.ejs': (await import('!!raw-loader!./templates/groth16_verifier.sol.ejs')).default,
// @ts-ignore // @ts-ignore
'README.txt': (await import('raw-loader!./README.txt')).default 'README.md': (await import('raw-loader!./README.md')).default
} }
} }

@ -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 ### 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.
prevention in anonymous environments.
The core parts of RLN are: ### first steps:
* 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)).
--- #### 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`).

@ -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.

@ -1,10 +0,0 @@
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.

@ -13,6 +13,6 @@ export default async () => {
// @ts-ignore // @ts-ignore
'templates/groth16_verifier.sol.ejs': (await import('!!raw-loader!./templates/groth16_verifier.sol.ejs')).default, 'templates/groth16_verifier.sol.ejs': (await import('!!raw-loader!./templates/groth16_verifier.sol.ejs')).default,
// @ts-ignore // @ts-ignore
'README.txt': (await import('raw-loader!./README.txt')).default 'README.md': (await import('raw-loader!./README.md')).default
} }
} }
Loading…
Cancel
Save