Groups are an important concept when we speak about privacy and zero knowledge technologies. They can be thought of as anonymity sets, and are a way to establish necessary trust between a set of participants. The goal of this project is to provide a comprehensive infrastructure to allow anyone to create and manage their own groups. |
---|
Bandada consists of a back-end to store the groups and provide the API, two front-ends: the dashboard to manage groups and members and a demo application to allow end-users to join the groups, and the contracts Additionally, it also provides a set of JavaScript libraries to support developers.
Two types of groups can be created from the dashboard: manual or credential groups. In the former you can add members by entering IDs directly or by creating invite links, while in the latter you can define credentials that members must prove they have in order to access the group.
Once you create your manual group in the dashboard you can either create an API key to add or remove members or use the invite codes to add members with the @bandada/api-sdk
library. Credential groups can instead be accessed by redirecting users to the appropriate page in the dashboard (i.e. https://bandada.pse.dev/credentials?group=<groupId>&member=<memberId>&provider=<providerName>
).
Bandada also provides a preset of credential validators that can, however, be extended with the @bandada/credentials
library.
For more information about our applications and libraries, use the links below to go to their specific README files.
- API: /apps/api
- Dashboard: /apps/dashboard
- Demo: /apps/client
- Contracts: /apps/contracts
Package | Version | Downloads |
---|---|---|
@bandada/hardhat |
|
|
@bandada/contracts |
|
|
@bandada/utils |
|
|
@bandada/credentials |
|
|
@bandada/api-sdk |
|
|
Clone this repository:
git clone https://github.com/privacy-scaling-explorations/bandada.git
and install the dependencies:
cd bandada && yarn
Run the following command to start the applications in a development environment:
yarn dev
or the following command to start the applications in production mode:
yarn start
Run the following command to build the libraries/applications:
yarn build
A dist
folder will be created in each library/application.
Run ESLint to analyze the code and catch bugs:
yarn lint
Run Prettier to check formatting rules:
yarn prettier
or to automatically format the code:
yarn prettier:write
Semaphore uses conventional commits. A command line utility to commit using the correct syntax can be used by running:
yarn commit
It will also automatically check that the modified files comply with ESLint and Prettier rules.
Bandada requires an SQL database to work, which is used by the api
application.
Bandada can work with Postgres and SQLite. Other SQL flavors should work but have not been tested yet.
You can pass the connection URL to the database using the environment variable (see below).
Run Jest to test the code with coverage:
yarn test
You can also run Bandada using Docker by running the below command in the project root:
docker-compose up -d
You can start dependencies essential for local development like a local ethereum network (with data persistence) and TheGraph node using the command below:
docker-compose -f docker-compose.dev.yml up -d
The ethereum node (Ganache) will start on port 8545
and will have the following accounts pre-funded with 100 ETH:
0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266
Private Key: 0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80
This is the same first account generated by Hardhat network as well.
Deploy the contracts to the local network using the below command:
yarn workspace contracts deploy:bandada-semaphore --network local
The addresses of contracts deployed in a fresh local network would be:
Pairing library has been deployed to: 0x5FbDB2315678afecb367f032d93F642f64180aa3
SemaphoreVerifier contract has been deployed to: 0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512
Bandada contract has been deployed to: 0x9fE46736679d2D9a65F0992F2272dE9f3c7fa6e0
BandadaSemaphore contract has been deployed to: 0xCf7Ed3AccA5a467e9e704C703E8D87F634fB0Fc9
These values are set as defaults in libs/utils/src/contract-addresses.ts
. If you change the contract and deploy again, new address needs to be set here.
To reset the local network or TheGraph node, you can stop the docker containers, and delete the respective folders inside ./.data
.
Below are the ENV variables used by the api
:
Key | Description |
---|---|
DB_TYPE | Type of the SQL database - postgres /sqlite . |
DB_URL | Connection string for the database. Path to DB file in case of sqlite . |
API_URL | Public URL of the api. |
DASHBOARD_URL | Public URL of the dashboard. |
ETHEREUM_NETWORK | Ethereum network where the contract is deployed. |
IRON_SESSION_PASSWORD | Secret password used for iron-session. |
INFURA_API_KEY | API Key for Infura. This is used for executing blockchain transactions. |
BACKEND_PRIVATE_KEY | Ethereum wallet private key used for making blockchain transactions. |
SIWE_STATEMENT | Statement used as a SIWE message. |
GITHUB_CLIENT_ID | Github client id used for credential groups. |
GITHUB_CLIENT_SECRET | Github client secret used for credential groups. |
TWITTER_REDIRECT_URI | Twitter redirect URL used for credential groups. |
TWITTER_CLIENT_ID | Twitter client id used for credential groups. |
TWITTER_CLIENT_SECRET | Twitter client secret used for credential groups. |
Bandada provides APIs to get groups data and manage group members. You can add or remove members in a group that you are admin of, using the API key.
To enable API access for a group, you can go to the group page in the dashboard, and switch on the "Enable API Access" toggle button. Once the API is enabled, a new API key will be generated for you.
You can disable the API access anytime using the same toggle button.
For a complete list of the endpoints you can use go to https://api.bandada.pse.dev.