Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Baseline Calender #480

Merged
merged 19 commits into from
Oct 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions examples/calendar/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# top-most EditorConfig file
root = true

[*]
indent_style=tab
indent_size=tab
tab_width=4
end_of_line=lf
charset=utf-8
trim_trailing_whitespace=true
max_line_length=80
insert_final_newline=true

[*.yml]
indent_style=tab
indent_size=2
end_of_line=lf
7 changes: 7 additions & 0 deletions examples/calendar/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
**/build/*
**/coverage/*
**/dist/*
**/generated/*
**/lib/*
**/node_modules/*
**/.eslintrc.js
16 changes: 16 additions & 0 deletions examples/calendar/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
module.exports = {
...require("@amaurym/eslintrc"),
// FIXME Turn these rules on again.
rules: {
"@typescript-eslint/explicit-function-return-type": "off",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-non-null-assertion": "off",
"@typescript-eslint/no-unsafe-assignment": "off",
"@typescript-eslint/restrict-template-expressions": "off",
"@typescript-eslint/no-unsafe-member-access": "off",
"@typescript-eslint/no-unsafe-call": "off",
"@typescript-eslint/no-unsafe-return": "off",
"@typescript-eslint/no-floating-promises": "off",
"@typescript-eslint/unbound-method": "warn"
}
};
22 changes: 22 additions & 0 deletions examples/calendar/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# See https://help.github.com/ignore-files/ for more about ignoring files.

# dependencies
node_modules
backend/.env
frontend/.env
# testing
coverage
.eslintcache

# production
build

# misc
.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local

# log files
.log*
4 changes: 4 additions & 0 deletions examples/calendar/.prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"trailingComma": "none",
"printWidth": 160
}
1 change: 1 addition & 0 deletions examples/calendar/.prettierrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require("@amaurym/eslintrc/prettierrc");
79 changes: 79 additions & 0 deletions examples/calendar/ReadMe.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
## Problem Statement

Right now when we use calendly, it has gives access to the scheduler and what times they are available. Caldendly also shows the times the person is not available. You have to trust this central authority to ensure proper scheduling takes place.Baseline Calendar uses Zero Knowledge Proof to ensure that privacy of user is mantained. This matching of time availability happens on client side which generates a proof which is then verified by the setter (to make sure incorrect information is not passed around)

## Basic Flow

![Flow](https://i.imgur.com/JsJeEuN.png)
There are two parties giver (giving appointment) and seeker (seeking appointment). The giver (as the name suggests) gives the appointment link
to the seeker.

- Store available times of the giver (giving appointment) in our database (availability)
- Now the giver can share the link to seeker
- The seeker chooses 3 time slots that they are available. When the appointment is successful, it generates the proof.
- The giver verifies the proof and the appointment is finally confirmed to be at that time.

## Main idea.

With help of merkle trees we can prove that one the nodes has a certain root without revealing the nodes. So if we have the merkle root and the node,then we can prove existance (merkle tree) or inexistance (sparse merkle trees). If changes in nodes of merkle tree would change the root.

In this case, we need to prove that person A and person B are scheduled for an appointment without revealing their individual commitments to each other
(more than they need to know).

## Tech Stack

- NodeJS for API creation
- PostgresDB for database purpose
- Circom2 and SNARKJS for proof generation / verification
- ReactJS for frontend

## Circuit Working

![Circuit](https://i.imgur.com/n9eKQAx.png)

## How to run this project?

You can use the following commands to run the code for backend and frontend.

### YARN

```
yarn install
yarn start
```

### NPM

```
npm install .
npm start
```

### Backend Tasks

- [x] User Creation API
- [x] User Authentication API
- [x] Fetch user via ID API
- [x] User Set Time Availability API
- [x] Schedule Appointment API

### Privacy Tasks

- [x] Circom proof to verify appointment times
- [x] Setup [Ceremony of Tau]
- [x] Prove (SnarkJS) with wasm / custom input.json
- [x] Solidity Smart contracts consumption via API [proof]
- [x] Solidity Smart contracts consumption via API [verify]

### Frontend Tasks

- [x] Create Login Page
- [x] Create Scheduling Page
- [x] Set an appointment
- [x] Appointment Page

### Demo Video
[Demo Video](https://www.youtube.com/watch?v=_eVsyjWFXhw)
### Credits

The authentication starter has been used from (https://github.com/amaurym/login-with-metamask-demo), which has been licensed under the MIT License which allows the use of code for commercial / non commercial use and is open to modify and redistribute for free.
3 changes: 3 additions & 0 deletions examples/calendar/backend/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
PROVIDER="https://polygon-mumbai.infura.io/v3/XXXXXXXXX"
VERIFIER_ADDRESS="0x6a142Ce9eE7cf5acF7c87b10e0D811E804a2f1AC"
PRIVATE_KEY_ACCOUNT=""
Empty file.
9 changes: 9 additions & 0 deletions examples/calendar/backend/config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
require("dotenv").config();

/**
* JWT config.
*/
export const config = {
algorithms: ["HS256" as const],
secret: process.env.secret || "shhh"
};
Empty file.
Loading