-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: moving docs repo into the monorepo (#848)
Co-authored-by: isk <0xisk>
- Loading branch information
Showing
20 changed files
with
669 additions
and
1 deletion.
There are no files selected for viewing
2 changes: 1 addition & 1 deletion
2
.github/workflows/deploy.yml → .github/workflows/deployDemo.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
name: Deploy | ||
name: Deploy demo | ||
on: | ||
push: | ||
branches: [main] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
name: Deploy docs | ||
on: | ||
push: | ||
branches: [main] | ||
paths: | ||
- "docs/**" | ||
|
||
permissions: | ||
contents: read | ||
pages: write | ||
id-token: write | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.ref }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-22.04 | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Setup mdBook | ||
uses: peaceiris/actions-mdbook@v1 | ||
with: | ||
mdbook-version: 'latest' | ||
|
||
- name: Setup Pages | ||
id: pages | ||
uses: actions/configure-pages@v3 | ||
|
||
- name: Change to Docs Directory | ||
run: cd docs | ||
|
||
- name: Build with mdBook | ||
run: mdbook build | ||
|
||
- name: Upload artifact | ||
uses: actions/upload-pages-artifact@v2 | ||
with: | ||
path: ./book | ||
|
||
deploy: | ||
environment: | ||
name: github-pages | ||
url: ${{ steps.deployment.outputs.page_url }} | ||
runs-on: ubuntu-latest | ||
needs: build | ||
steps: | ||
- name: Deploy to GitHub Pages | ||
id: deployment | ||
uses: actions/deploy-pages@v2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
--- | ||
description: (formerly ZK Keeper) | ||
--- | ||
|
||
# 👋 Welcome to CryptKeeper | ||
|
||
## Quick links | ||
|
||
{% content-ref url="what-is-cryptkeeper/overview.md" %} | ||
[overview.md](what-is-cryptkeeper/overview.md) | ||
{% endcontent-ref %} | ||
|
||
{% content-ref url="what-is-cryptkeeper/features.md" %} | ||
[features.md](what-is-cryptkeeper/features.md) | ||
{% endcontent-ref %} | ||
|
||
{% embed url="https://github.com/privacy-scaling-explorations/crypt-keeper-extension" %} | ||
|
||
## Guides | ||
|
||
We've put together some helpful guides for you to get setup quickly and easily. | ||
|
||
{% content-ref url="guides/quick-setup.md" %} | ||
[quick-setup.md](guides/quick-setup.md) | ||
{% endcontent-ref %} | ||
|
||
{% content-ref url="guides/integrating-cryptkeeper/" %} | ||
[integrating-cryptkeeper](guides/integrating-cryptkeeper/) | ||
{% endcontent-ref %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Table of contents | ||
|
||
* [👋 Welcome to CryptKeeper](README.md) | ||
|
||
## What is CryptKeeper? | ||
|
||
* [💡 Overview](what-is-cryptkeeper/overview.md) | ||
* [✨ Features](what-is-cryptkeeper/features.md) | ||
|
||
## Guides | ||
|
||
* [🛠 Quick setup](guides/quick-setup.md) | ||
* [🧱 Integrating CryptKeeper](guides/integrating-cryptkeeper/README.md) | ||
* [🔌 Connect to extension](guides/integrating-cryptkeeper/connect-to-extension.md) | ||
* [🎯 Inject client](guides/integrating-cryptkeeper/inject-client.md) | ||
* [🆔 Create identity](guides/integrating-cryptkeeper/create-identity.md) | ||
* [⚡ Generate proof](guides/integrating-cryptkeeper/generate-proof.md) | ||
* [🐰 Zkitter examples](guides/integrating-cryptkeeper/zkitter-examples.md) | ||
|
||
## References | ||
|
||
* [📘 Terms](references/terms.md) | ||
* [🤔 FAQ](references/faq.md) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
[book] | ||
authors = ["AtHeartEngineer", "0xIsk", "0xmad"] | ||
language = "en" | ||
multilingual = false | ||
src = "src" | ||
title = "CryptKeeper Documentation" | ||
|
||
[build] | ||
create-missing = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# Summary | ||
|
||
- [Cryptkeeper](cryptkeeper/_intro.md) | ||
- [Features](cryptkeeper/features.md) | ||
- [Overview](cryptkeeper/overview.md) | ||
- [Guides](guides/_intro.md) | ||
- [Contributing](guides/contributing.md) | ||
- [Integration](guides/integration/_intro.md) | ||
- [Connect to Extension](guides/integration/connect-to-extension.md) | ||
- [Create Identity](guides/integration/create-identity.md) | ||
- [Generate Proof](guides/integration/generate-proof.md) | ||
- [Inject Client](guides/integration/inject-client.md) | ||
- [Zkitter Examples](guides/integration/zkitter-examples.md) | ||
- [References](references/_intro.md) | ||
- [Faq](references/faq.md) | ||
- [Terms](references/terms.md) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# CryptKeeper | ||
|
||
Welcome to CryptKeeper, a simple, easy to use, and secure zk identity manager |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# ✨ Features | ||
|
||
The following features are supported currently: | ||
|
||
* Identity secret and Identity commitment generation | ||
* Semaphore ZK-Proof generation | ||
* RLN ZK-Proof generation | ||
|
||
Proof generation is enabled in two ways: | ||
|
||
* by providing Merkle witness (Merkle tree components) directly as a [structured input](https://github.com/privacy-scaling-explorations/crypt-keeper-extension/blob/817ec0e1f336ab61c9c70f4918853e7c279dd21d/src/types/index.ts#L56):  | ||
* by providing a secure service (i.e. smart contract) address from which the Merkle witness should be obtained |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# 💡 Overview | ||
|
||
CryptKeeper is a browser extension for managing zero-knowledge identities. It securely separates ZK identity and ZK proof generation from the application layer. Specifically, it manages identities created using the [Semaphore](https://semaphore.appliedzkp.org/) protocol and allows proof generation from [RLN](https://github.com/Rate-Limiting-Nullifier/) and Semaphore. | ||
|
||
 This plugin is still in development and uses the [zk-kit library](https://github.com/appliedzkp/zk-kit). | ||
|
||
## Video overview | ||
|
||
{% embed url="https://www.youtube.com/watch?index=16&list=PLV91V4b0yVqRQ62Mv0nUgWxJhi4E67XSY&v=F5ic66_eNAs" %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# Guides |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# 🛠 Quick setup | ||
|
||
## Development | ||
|
||
1. Install the necessary packages by running the command `npm install` in your terminal. | ||
2. Start the development server by running the command `npm run dev` | ||
3. In your browser, navigate to the extensions settings and load the `dist` directory as an unpacked extension. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# Integrations |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# 🔌 Connect to extension | ||
|
||
## Connect to extension | ||
|
||
Use `zkpr.connect` to access the extension. | ||
|
||
Initialize the `zkpr.connect` function, which returns a promise that resolves to the client object. | ||
|
||
 Once you have the client object, you can use it to make RPC calls to the extension. | ||
|
||
 [@src/contentscripts/injected.ts](https://github.com/privacy-scaling-explorations/crypt-keeper-extension/blob/master/src/contentscripts/injected.ts) | ||
|
||
```typescript | ||
async function connect() { | ||
let result | ||
try { | ||
const approved = await tryInject(window.location.origin) | ||
|
||
if (approved) { | ||
await addHost(window.location.origin) | ||
result = client | ||
} | ||
} catch (err) { | ||
// eslint-disable-next-line no-console | ||
console.log('Err: ', err) | ||
result = null | ||
} | ||
|
||
await post({ method: RPCAction.CLOSE_POPUP }) | ||
|
||
return result | ||
} | ||
|
||
declare global { | ||
interface Window { | ||
zkpr: { | ||
connect: () => any | ||
} | ||
} | ||
}// Some code | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
# 🆔 Create identity | ||
|
||
By default, CryptKeeper uses MetaMask to create a new Semaphore Identity \[link]. | ||
|
||
1. In MetaMask, a user signs a message with the private key of their Ethereum account. | ||
2. In your dapp, the user creates a deterministic identity \[link] with the signed message. | ||
3. The user can now recreate their Semaphore identity whenever they want by signing the same message with their Ethereum account in Metamask. | ||
|
||
Semaphore identities can also be created using other data (such as web2 reputations from [Interep](https://interep.link/)) or using random numbers. | ||
|
||
[@src/background/zk-keeper.ts](https://github.com/privacy-scaling-explorations/crypt-keeper-extension/blob/master/src/background/zk-keeper.ts) | ||
|
||
```typescript | ||
this.add( | ||
RPCAction.CREATE_IDENTITY, | ||
LockService.ensure, | ||
async (payload: NewIdentityRequest) => { | ||
try { | ||
const { strategy, messageSignature, options } = payload | ||
if (!strategy) throw new Error('strategy not provided') | ||
|
||
const numOfIdentites = await this.identityService.getNumOfIdentites() | ||
const config: any = { | ||
...options, | ||
name: options?.name || `Account # ${numOfIdentites}` | ||
} | ||
|
||
if (strategy === 'interrep') { | ||
console.log("CREATE_IDENTITY: 1") | ||
config.messageSignature = messageSignature; | ||
console.log("CREATE_IDENTITY: 2") | ||
} | ||
|
||
const identity: ZkIdentityWrapper | undefined = await identityFactory(strategy, config) | ||
console.log("CREATE_IDENTITY: 4", identity); | ||
|
||
if (!identity) { | ||
throw new Error('Identity not created, make sure to check strategy') | ||
} | ||
|
||
await this.identityService.insert(identity) | ||
|
||
return true | ||
} catch (error: any) { | ||
console.log("CREATE_IDENTITY: Error", error); | ||
throw new Error(error.message) | ||
} | ||
} | ||
) | ||
``` | ||
|
||
  | ||
|
||
1. Import the `ZkKeeperController` class and initialize an instance of it. | ||
2. Use the `RPCAction.CREATE_IDENTITY` method, which is a function provided by the `ZkKeeperController` class, and pass in the necessary parameters as the payload. The payload should include a `strategy`, `messageSignature`, and `options` object. | ||
3. The `strategy` parameter is a string that specifies the type of identity you want to create. | ||
4. The `messageSignature` parameter is a string that is the signature of some message that is used to verify the authenticity of the client. | ||
5. The `options` object contains additional options for creating the identity including an `identityName` field which is a string that sets the name of the newly created identity. | ||
6. The function returns a promise that resolves to the new identity's commitment. Once the identity is created, it can be used to generate ZK proofs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
# ⚡ Generate proof | ||
|
||
CryptKeeper lets dapps outsource ZK proof generation via the Semaphore and RLN protocols. This section will review Semaphore proofs. | ||
|
||
 [@src/contentscripts/injected.ts](https://github.com/privacy-scaling-explorations/crypt-keeper-extension/blob/master/src/contentscripts/injected.ts) | ||
|
||
```typescript | ||
async function semaphoreProof( | ||
externalNullifier: string, | ||
signal: string, | ||
circuitFilePath: string, | ||
zkeyFilePath: string, | ||
merkleProofArtifactsOrStorageAddress: string | MerkleProofArtifacts, | ||
merkleProof?: MerkleProof | ||
) { | ||
``` | ||
 The `semaphoreProof` function allows the user to create a proof of a signal to be sent to the Semaphore contract. CryptKeeper uses values provided by the dapp and the private user values to generate the proof and returns it to the dapp for verification.   | ||
Your dapp should pass in public values (`externalNullifier` and `signal`). | ||
Any circuit files (`circuitFilePath` and `zkeyFilePath`) can be used, but ready-to-use and audited circuit files can be found [here](http://www.trusted-setup-pse.org/) and [here](https://drive.google.com/file/d/1Yi14jwly70VwMSuqJrPCc3j15MWeE7mc/view?usp=sharing). | ||
Merkle witness or Merkle tree components (`merkleProofArtifactsOrStorageAddress` can be provided by a smart contract or as a structured input:  | ||
* `StorageAddress` points to a Merkle tree on-chain | ||
* `merkleProofArtifact` is a Merkle tree in a specific format | ||
* [@src/types/index.ts](https://github.com/privacy-scaling-explorations/crypt-keeper-extension/blob/817ec0e1f336ab61c9c70f4918853e7c279dd21d/src/types/index.ts#L56) | ||
* ```typescript | ||
export type MerkleProofArtifacts = { | ||
leaves: string[] | ||
depth: number | ||
leavesPerNode: number | ||
} | ||
``` | ||
`SemaphoreProof` requires the following arguments: | ||
`externalNullifier` | ||
* a unique identifier for the signal to prevent double signaling | ||
* public input provided by dapp | ||
`signal` | ||
* hash of the content of the message | ||
* public input provided by dapp | ||
`circuitFilePath` | ||
* location of the circuit file | ||
* used to generate the ZK proof in the browser | ||
`zkeyFilePath` | ||
* the zkeyFile contains the trusted setup \[link] files and is the starting point for creating a circuit | ||
* location of the zkey file | ||
`merkleProofArtifactsOrStorageAddress` | ||
* object providing Merkle witness <mark style="color:blue;"></mark> directly (`merkleProofArtifact`) or the secure service address from which the Merkle witness should be obtained (`merkleStorageAddress`)  | ||
* To generate a proof, a user must provide the Merkle path that leads to the user’s identity in the Merkle tree  | ||
  | ||
**RLN Proofs** | ||
[RLN (Rate-Limiting Nullifier)](https://rate-limiting-nullifier.github.io/rln-docs/) is a ZK gadget or mechanism that enables spam prevention for anonymous environments. RLN Proofs are the same as Semaphore proofs except they generate proofs for a specific epoch (time period) and require an additional argument: `rlnIdentifier`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# 🎯 Inject client | ||
|
||
CryptKeeper injects an object called `zkpr` into the browser. This is similar to how | ||
|
||
MetaMask injects a [global API](https://docs.metamask.io/guide/ethereum-provider.html#ethereum-provider-api) into websites visited by its users at `window.ethereum` (formerly [window.web3](https://docs.metamask.io/guide/provider-migration.html#replacing-window-web3)) | ||
|
||
The injected client serves as bridge between frontend and backend processes. It is passed into the web page by the extension through an API allows the web page to make calls to CryptKeeper. From here you can manually generate and verify proofs, create identities, and set permissions. | ||
|
||
You should be able to access the injected client’s functions and permissions once connected: | ||
|
||
* `getIdentityCommitments`: Retrieves the commitments of the current identity. | ||
* `getActiveIdentity`: Retrieves the currently active identity. | ||
* `getHostPermissions`: Retrieves the permissions for the specified host. | ||
* `setHostPermissions`: Sets the permissions for the specified host. | ||
* `createIdentity`: Creates a new identity and returns the result. | ||
* `createDummyRequest`: Creates a dummy request and returns the result. | ||
* `semaphoreProof`: Sends a Semaphore proof request and returns the result. | ||
* `rlnProof`: Sends a RLN proof request and returns the result. | ||
* `clearApproved`: Clears the approved list of requests. | ||
* `getApproved`: Retrieves the approved list of requests. | ||
* `openPopup`: Opens the extension's popup window. | ||
* `closePopup`: Closes the extension's popup window. | ||
* `post`: Sends a request to the extension and returns the result. | ||
|
||
[@src/contentscripts/injected.ts](https://github.com/privacy-scaling-explorations/crypt-keeper-extension/blob/817ec0e1f336ab61c9c70f4918853e7c279dd21d/src/contentscripts/injected.ts) | ||
|
||
```typescript | ||
const client = { | ||
openPopup, | ||
getIdentityCommitments, | ||
getActiveIdentity, | ||
createIdentity, | ||
getHostPermissions, | ||
setHostPermissions, | ||
semaphoreProof, | ||
rlnProof, | ||
on, | ||
off, | ||
// dev-only | ||
clearApproved, | ||
createDummyRequest | ||
} | ||
|
||
``` | ||
|
Oops, something went wrong.