From a8e8e78edbbce67dcc310ad1dceed5c7c58439e9 Mon Sep 17 00:00:00 2001 From: AtHeartEngineer <1675654+AtHeartEngineer@users.noreply.github.com> Date: Wed, 12 Jul 2023 00:30:44 -0400 Subject: [PATCH] repo work --- Discreetly.md | 40 ++++++++++++++++++++++++ PLAN.md | 78 +++++++++++++++++++++++++++++++++++++++++++++++ README.md | 12 ++++++++ package-lock.json | 14 ++++----- 4 files changed, 137 insertions(+), 7 deletions(-) create mode 100644 Discreetly.md create mode 100644 PLAN.md create mode 100644 README.md diff --git a/Discreetly.md b/Discreetly.md new file mode 100644 index 0000000..b776fc3 --- /dev/null +++ b/Discreetly.md @@ -0,0 +1,40 @@ +## Overview + +Discreetly is an open protocol anonymous chat system. + +The example scenario I am going to use throughout this document is a chat room for Steam games, where the barrier to entry for a room is a certain threshold of achievments accomplished in the game (20% by default?) + +## Rooms + +A room can be created by the server owner/admin, with certain criteria/barrier to entry. + +### Karma Culling + +In an anonmyous chat, it is (basically) impossible to know who said something the large majority didn't agree with, but you can prove that you _didn't_ say something. So we can use this to exclude very bad actors using a karma system where users can upvote or downvote messages, which under the hood are non-inclusion proofs, essentially saying "i didn't create this post, and I did or didn't like this". + +> This non-inclusion proof includes a new "transiition identity commitment". + +After a certain trigger (maybe a certain amount of time like 1 day to start and over time move to every 30 days? or after a certain action on chain), the group can choose to transition, where the server would generate a new version of the room, and everyone would have to make a new semaphore proof with either their old identity commitment or a new one, and everyone who wants to participate in the room would have to make a non-inclusion proof for any of the messages that broke some UPVOTE/DOWNVOTE threshold (configurable by the server, something like 2x more downvotes than upvotes, and [over 20 votes total] | [10% of the room] | [the lowest voted post]). + +This would result in multiple iterations of a room, one for each transition, and the rate limit would change per iteration. + +- Most Recent Room (T) + - 1s +- T-1 + - 10s +- T-2 + - 100s // 1:40 +- T-3 + - 1000s // 16:40 +- T-4 + - 10000s // 2:46:40 +- T-5 + - 100000s // 27:46:40 // 1 day 3 hours 46 minutes 40 seconds +- T-6 + - 1000000s // 11:13:46:40 // 11 days 13 hours 46 minutes 40 seconds +- T-7 + - 10000000s // 1:03:13:46:40 // 1 month 3 days 13 hours 46 minutes 40 seconds +- T-8 + - 100000000s // 11:09:03:13:46:40 // 11 months 9 days 3 hours 13 minutes 46 seconds 40 milliseconds +- T-9 + - 1000000000s // 3:01:09:03:13:46:40 // 3 years 1 month 9 days 3 hours 13 minutes 46 seconds 40 milliseconds diff --git a/PLAN.md b/PLAN.md new file mode 100644 index 0000000..4d5d88a --- /dev/null +++ b/PLAN.md @@ -0,0 +1,78 @@ +# ZK-Chat v2 + +## Credential Storage +* Localstorage + * Start with this, its easy, but not super secure +* Cryptkeeper? +* Sismo? +* Zupass? +* Walletconnect/metamask? + +## Group Creation + +* Admin (me) can make groups + * by invite code + * Permission to add 1 identity commitment +* Gated Room Ideas (that you can watch, but can't participate in) + * Steam Games! + * ZK Stamps! + * Events! + * Devconnect + + +### Types of Rooms/Groups +| Type | Read | Write | Encrypted | Centralized | RLN Protected | +| ------- | ------------- | ------------------------------- | ------------------- | ----------- | ------------- | +| Gated | Y | via link/code for specific room | N | Y | Y | +| ------- | ------------- | ------------------------------- | ------------------- | ----------- | ------------- | +| Public? | Y | via link/code for all rooms | N | Y | Y | +| Private | via link/code | via link/code for specific room | N | Y | Y | +| Secure | via link/code | via link/code for specific room | Y (shared password) | Y | Y | +| DM-P2P | via link/code | via link/code for specific room | Y (shared password) | N (p2p) | ? | + +* Start with Gated Rooms + +## Open Questions +* P2P v Centralized? +* Rate Limits? +* Group Membership on contract? + * Staking by tiers with different rate limits? +* Should messages be ephemeral/temporary? (the last day?) + +### Front End +discreetly.chat will be the front end and backend +#### Stack +* Nuxtjs +* websockets + +#### Login +* Cryptkeeper +* Metamask +* Walletconnect +* Sismo +* Zupass + +### Back End +discreetly.chat will be the front end and backend + +stakers.chat will be a standalone backend for eth stakers + +#### Stack +* Javascript / Typescript + * Node? + * Libp2p? + * Shorter development cycle + * Dev process is annoying + * One language stack which is nice +* Python + * Library compatibility issues with RLNjs and maybe any other ZK libraries + * I could write it really fast + * I miss python + +#### Database + +* Libp2p? +* Waku? +* IPFS? +* Firebase? +* SQLite? <- Leaning this way, keep all config/registration stuff in sqlite, and all messages in RAM/ephemeral \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..a0ef02b --- /dev/null +++ b/README.md @@ -0,0 +1,12 @@ +# Dev + +`npm i` + +## Run Redis + +Need to have a redis instance running + +## Run the backend + +`npm i` +`npm run dev` \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index d847578..ebd4e7d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -13,7 +13,7 @@ "body-parser": "^1.20.2", "cors": "^2.8.5", "discreetly-claimcodes": "^1.0.5", - "discreetly-interfaces": "^0.1.3", + "discreetly-interfaces": "^0.1.5", "dotenv": "^16.3.1", "express": "^4.18.2", "poseidon-lite": "^0.2.0", @@ -938,9 +938,9 @@ "integrity": "sha512-ygx8rKtiweDg/Qj5qbHVy31osFV+CcGrNNtxDpeqqRnkO9tkqH9CvtdPJuR3R0R8vzT7kyBTwmN0LGQe3/aXhQ==" }, "node_modules/discreetly-interfaces": { - "version": "0.1.3", - "resolved": "https://registry.npmjs.org/discreetly-interfaces/-/discreetly-interfaces-0.1.3.tgz", - "integrity": "sha512-9NC8KZukSB18/lR3hjHDO1WqMdsxxN0JXu6wOR/0mZ1eCNUkuh4sKkf/8C5xuU7NM0o/sK7wAm3/H0MR4DOkcg==", + "version": "0.1.5", + "resolved": "https://registry.npmjs.org/discreetly-interfaces/-/discreetly-interfaces-0.1.5.tgz", + "integrity": "sha512-RcdBvop3n8K4xlvD6/P9APD7nKhONNon++fh5UdDqa3bjWxLtZsaHna7pTfIuymjUmimDrqiMVB6JCS3ys4MFw==", "dependencies": { "poseidon-lite": "^0.2.0", "rlnjs": "^3.1.4" @@ -3116,9 +3116,9 @@ "integrity": "sha512-ygx8rKtiweDg/Qj5qbHVy31osFV+CcGrNNtxDpeqqRnkO9tkqH9CvtdPJuR3R0R8vzT7kyBTwmN0LGQe3/aXhQ==" }, "discreetly-interfaces": { - "version": "0.1.3", - "resolved": "https://registry.npmjs.org/discreetly-interfaces/-/discreetly-interfaces-0.1.3.tgz", - "integrity": "sha512-9NC8KZukSB18/lR3hjHDO1WqMdsxxN0JXu6wOR/0mZ1eCNUkuh4sKkf/8C5xuU7NM0o/sK7wAm3/H0MR4DOkcg==", + "version": "0.1.5", + "resolved": "https://registry.npmjs.org/discreetly-interfaces/-/discreetly-interfaces-0.1.5.tgz", + "integrity": "sha512-RcdBvop3n8K4xlvD6/P9APD7nKhONNon++fh5UdDqa3bjWxLtZsaHna7pTfIuymjUmimDrqiMVB6JCS3ys4MFw==", "requires": { "poseidon-lite": "^0.2.0", "rlnjs": "^3.1.4"