docs: interep ui

This commit is contained in:
rymnc 2022-12-07 20:11:54 +05:30
parent 348263cbed
commit f84ddd1f7b
No known key found for this signature in database
GPG Key ID: C740033EE3F41EBD
3 changed files with 103 additions and 8 deletions

View File

@ -71,6 +71,86 @@ yarn test
10. Now you can send messages from Carol, and they will be validated by Alice. Spam messages will be detected and dropped before relaying to Bob.
## Test with Interep UI deployed on Goerli/other testnets
1. Fund an address with Goerli ETH from https://goerlifaucet.com
2. Fetch dependencies
```shell
yarn
```
3. Set the private key of the funded address into the env of a terminal window
```shell
export PRIVATE_KEY=<your-private-key>
```
4. Navigate to https://goerli.interep.link
5. Connect your wallet (using the funded address)
6. Follow the instructions to authorize a web2 provider of your choice. Note that only Github and Reddit are supported by RLN.
- Note the provider name and reputation you have
- Wait 2 minutes for the transaction containing your registration to be mined
7. In the open terminal window, run
```shell
yarn proof <web2 provider name> <web2 reputation> goerli
```
8. In a new terminal window, run
```
yarn ui
```
- If `http-server` is missing, `yarn global add http-server` will resolve the issue.
9. Navigate to http://127.0.0.1:8080
10. Connect your wallet and fetch the contract state from the blockchain
11. Scroll down to the "Or use credentials you generated elsewhere:" section, and add the credentials obtained in step 7.
12. Scroll down and select "With semaphore proof"
13. Add the proof values from obtained in step 7
14. Click "Register with Proof"
15. Approve the transaction
16. In a new terminal window, Clone [nwaku](https://github.com/waku-org/nwaku) and switch to the `rln-interep-poc` branch
17. Run
```shell
make -j8 wakunode2 RLN=true && ./build/wakunode2 --rln-relay-content-topic:/toy-chat/2/luzhou/proto \
--rln-relay:true \
--rln-relay-dynamic:true \
--rln-relay-eth-contract-address:0xCd41a0aC28c5c025779eAC3208D0bF23baa3a5b6 \
--rln-relay-eth-client-address:ws://<goerli-rpc-url> \
--ports-shift=22 \
--log-level=DEBUG \
--dns-discovery \
--dns-discovery-url:enrtree://AOGECG2SPND25EEFMAJ5WF3KSGJNSGV356DSTL2YVLLZWIV6SAYBM@prod.waku.nodes.status.im \
--discv5-discovery:true \
--lightpush \
--filter \
--websocket-support \
--websocket-port:8000
```
- Make note of the node's multiaddr. It should look something like `/ip4/172.13.4.12/tcp/8022/ws/p2p/16Uiu2HAkvWiyFsgRhuJEb9JfjYxEkoHLgnUQmr1N5mKWnYjxYRVm`
18. In the browser, Add the multiaddr you obtained in step 17.
19. Choose a nickname, and send messages!
## Deploying
- To deploy on local node, first start the local node and then run the deploy script

View File

@ -1,6 +1,12 @@
import { Network } from "@interep/api";
const groupProvider = process.argv[2] || "github";
const groupTier = process.argv[3] || "bronze";
const network = (process.argv[4] || "goerli") as Network;
async function main() {
const { getProof } = await import("./utils");
const proof = await getProof();
const proof = await getProof(groupProvider, groupTier, network);
console.log({
groupId: proof.groupId,
signal: proof.signal,
@ -14,5 +20,6 @@ main()
.then(() => process.exit(0))
.catch((e) => {
console.error(e);
console.log("Usage: yarn proof <groupProvider> <groupTier> <network>");
process.exit(1);
});

View File

@ -1,6 +1,7 @@
import createIdentity from "@interep/identity";
import createProof from "@interep/proof";
import { ethers } from "ethers";
import { Network } from "@interep/api";
// @ts-ignore
import { poseidon } from "circomlibjs";
import { sToBytes32 } from "../common";
@ -8,11 +9,14 @@ import { sToBytes32 } from "../common";
// if length is not 64 pad with 0
const pad = (str: string): string => (str.length === 64 ? str : pad("0" + str));
export async function getCredentials() {
const capitalize = (str: string): string =>
str.charAt(0).toUpperCase() + str.slice(1);
export async function getCredentials(groupProvider: string) {
const signer = new ethers.Wallet("0x" + process.env.PRIVATE_KEY);
const identity = await createIdentity(
(msg) => signer.signMessage(msg),
"Github"
capitalize(groupProvider)
);
console.log("ID COMMITMENT: " + pad(identity.getCommitment().toString(16)));
console.log(
@ -24,19 +28,23 @@ export async function getCredentials() {
return identity;
}
export async function getProof() {
const identity = await getCredentials();
export async function getProof(
groupProvider: string,
groupTier: string,
network: Network
) {
const identity = await getCredentials(groupProvider);
const proof = await createProof(
identity,
"github",
"bronze",
groupProvider,
groupTier,
1,
sToBytes32("foo"),
{
wasmFilePath: "./test/oldSnarkArtifacts/semaphore.wasm",
zkeyFilePath: "./test/oldSnarkArtifacts/semaphore.zkey",
},
"goerli"
network
);
return proof;
}