Skip to content

Commit 7ad76aa

Browse files
committed
chore: add more documents
1 parent 87c8daa commit 7ad76aa

10 files changed

+190
-84
lines changed

Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ lint:
99
fix:
1010
@cargo clippy --fix --workspace --tests
1111

12+
test:
13+
@cargo test --workspace -- --nocapture
14+
1215
# cargo install twiggy
1316
twiggy:
1417
twiggy top -n 12 target/wasm32-unknown-unknown/release/ic_panda_luckypool.wasm

README.md

Lines changed: 7 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# ICPanda DAO
2-
🐼 A decentralized Panda meme brand built on the Internet Computer.
2+
🐼 A decentralized Panda meme platform featuring E2E encrypted messaging, lucky draws, airdrops.
3+
4+
## dMsg (ICPanda Message)
5+
6+
[dMsg System Overview](./docs/dMsg_system_overview.md)
7+
8+
[dMsg Design Choices](./docs/dMsg_design_choices.md)
39

410
## Whitepaper
511

@@ -26,7 +32,6 @@
2632
| | -- **10%** | -- 100,000,000 | CEX Incentive |
2733
| | -- **10%** | -- 100,000,000 | DEX Liquidity |
2834

29-
3035
### Token utility
3136

3237
PANDA is the only token issued by ICPanda DAO. By holding PANDA tokens, users can participate in:
@@ -44,87 +49,5 @@ PANDA is the only token issued by ICPanda DAO. By holding PANDA tokens, users ca
4449
- Twitter: [https://twitter.com/ICPandaDAO](https://twitter.com/ICPandaDAO)
4550
- GitHub: [https://github.com/ldclabs/ic-panda](https://github.com/ldclabs/ic-panda)
4651

47-
## Running the project locally
48-
49-
If you want to test your project locally, you can use the following commands:
50-
51-
```bash
52-
# Starts the replica
53-
dfx start
54-
55-
# Creates the canisters with the specified IDs
56-
dfx canister create --specified-id rdmx6-jaaaa-aaaaa-aaadq-cai internet_identity
57-
dfx canister create --specified-id ryjl3-tyaaa-aaaaa-aaaba-cai icp_ledger_canister
58-
dfx canister create --specified-id c63a7-6yaaa-aaaap-ab3gq-cai ic_panda_frontend
59-
dfx canister create --specified-id f75us-gyaaa-aaaap-ab3wq-cai ic_panda_infra
60-
dfx canister create --specified-id a7cug-2qaaa-aaaap-ab3la-cai ic_panda_luckypool
61-
dfx canister create --specified-id q5mxo-eyaaa-aaaap-ahfoq-cai ic_panda_ai
62-
63-
# Deploys the ICP Ledger canister with the specified initial values
64-
dfx identity use default
65-
export MINTER_ACCOUNT_ID=$(dfx ledger account-id)
66-
export DEFAULT_ACCOUNT_ID=$(dfx ledger account-id)
67-
dfx deploy --specified-id ryjl3-tyaaa-aaaaa-aaaba-cai icp_ledger_canister --argument "
68-
(variant {
69-
Init = record {
70-
minting_account = \"$MINTER_ACCOUNT_ID\";
71-
initial_values = vec {
72-
record {
73-
\"$DEFAULT_ACCOUNT_ID\";
74-
record {
75-
e8s = 21_000_000_000_000_000 : nat64;
76-
};
77-
};
78-
};
79-
send_whitelist = vec {};
80-
transfer_fee = opt record {
81-
e8s = 10_000 : nat64;
82-
};
83-
token_symbol = opt \"LICP\";
84-
token_name = opt \"Local ICP\";
85-
}
86-
})
87-
"
88-
89-
# Deploys the ICRC-1 token Ledger canister with the specified initial values
90-
dfx identity use default
91-
export MINTER=$(dfx identity get-principal)
92-
export DEFAULT=$(dfx identity get-principal)
93-
export ARCHIVE_CONTROLLER=$(dfx identity get-principal)
94-
export TOKEN_NAME="ICPanda"
95-
export TOKEN_SYMBOL="PANDA"
96-
export PRE_MINTED_TOKENS=100_000_000_000_000_000
97-
export TRANSFER_FEE=10_000
98-
export TRIGGER_THRESHOLD=2000
99-
export NUM_OF_BLOCK_TO_ARCHIVE=1000
100-
export CYCLE_FOR_ARCHIVE_CREATION=10000000000000
101-
export FEATURE_FLAGS=true
102-
103-
dfx deploy icrc1_ledger_canister --specified-id druyg-tyaaa-aaaaq-aactq-cai --argument "(variant {Init =
104-
record {
105-
token_symbol = \"${TOKEN_SYMBOL}\";
106-
token_name = \"${TOKEN_NAME}\";
107-
minting_account = record { owner = principal \"${MINTER}\" };
108-
transfer_fee = ${TRANSFER_FEE};
109-
metadata = vec {};
110-
feature_flags = opt record{icrc2 = ${FEATURE_FLAGS}};
111-
initial_balances = vec { record { record { owner = principal \"${DEFAULT}\"; }; ${PRE_MINTED_TOKENS}; }; };
112-
archive_options = record {
113-
num_blocks_to_archive = ${NUM_OF_BLOCK_TO_ARCHIVE};
114-
trigger_threshold = ${TRIGGER_THRESHOLD};
115-
controller_id = principal \"${ARCHIVE_CONTROLLER}\";
116-
cycles_for_archive_creation = opt ${CYCLE_FOR_ARCHIVE_CREATION};
117-
};
118-
}
119-
})"
120-
121-
# Deploys other canisters
122-
dfx deploy
123-
```
124-
125-
Open the frontend in your default browser
126-
127-
http://c63a7-6yaaa-aaaap-ab3gq-cai.localhost:4943/
128-
12952
## License
13053
Copyright © 2024 [LDC Labs](https://github.com/ldclabs).
125 KB
Loading
242 KB
Loading
143 KB
Loading

diagrams/dMsg_mk_data_flow.png

156 KB
Loading
141 KB
Loading

docs/dMsg_design_choices.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# dMsg (ICPanda Message) Design Choices
2+
3+
## CBOR
4+
5+
The Concise Binary Object Representation ([CBOR, RFC 8949](https://datatracker.ietf.org/doc/html/rfc8949)) is a data format whose design goals include the possibility of extremely small code size, fairly small message size, and extensibility without the need for version negotiation. These design goals make it different from earlier binary serializations such as ASN.1 and MessagePack.
6+
7+
The Internet Computer source code also makes extensive use of CBOR. All dMsg smart contracts and the client use CBOR as the primary data serialization format.
8+
9+
## COSE
10+
11+
COSE ([RFC 9052](https://datatracker.ietf.org/doc/html/rfc9052), [RFC 9053](https://datatracker.ietf.org/doc/html/rfc9053)) is a standard for signing and encrypting data in the CBOR data format. It is designed to be simple and efficient, and to be usable in constrained environments. It is intended to be used in a variety of applications, including the Internet of Things, and is designed to be extensible to support new algorithms and applications.
12+
13+
dMsg uses COSE as the standard for message encryption and key exchange.
14+
15+
## IC-COSE
16+
17+
[IC-COSE](https://github.com/ldclabs/ic-cose) is a decentralized COnfiguration service with Signing and Encryption on the Internet Computer.
18+
19+
After registering a username, dMsg users gain a dedicated namespace on the COSE service for key derivation, key storage, and other confidential information.
20+
21+
## IC-OSS
22+
23+
[IC-OSS](https://github.com/ldclabs/ic-oss) is a decentralized Object Storage Service on the Internet Computer.
24+
25+
dMsg uses IC-OSS to store user avatars, channel logos, and channel files. Each channel has a dedicated folder on the OSS service for file storage.

docs/dMsg_system_overview.md

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# dMsg (ICPanda Message) System Overview
2+
3+
![dMsg System Overview](../diagrams/dMsg_component_interaction.png)
4+
5+
## dMsg On-Chain Side
6+
7+
### Backend Smart Contracts
8+
9+
- Management canister:
10+
- Source code: [ic_message](../src/ic_message)
11+
- Description: The management canister that handles users management, canisters management, price management and channels management.
12+
- `ic_message` canister: [nscli-qiaaa-aaaaj-qa4pa-cai](https://dashboard.internetcomputer.org/canister/nscli-qiaaa-aaaaj-qa4pa-cai)
13+
- User public profile canister:
14+
- Source code: [ic_message_profile](../src/ic_message_profile)
15+
- Description: The profile canister that handles user public profiles management. The number of profile canisters can be increased based on user scale.
16+
- `ic_message_profile` Canister: [ijyxz-wyaaa-aaaaj-qa4qa-cai](https://dashboard.internetcomputer.org/canister/ijyxz-wyaaa-aaaaj-qa4qa-cai)
17+
- Channel canister:
18+
- Source code: [ic_message_channel](../src/ic_message_channel)
19+
- Description: The channel canister that handles channels management and messages management. The number of channel canisters can be increased based on user scale.
20+
- `ic_message_channel` canister: [nvdn4-5qaaa-aaaaj-qa4pq-cai](https://dashboard.internetcomputer.org/canister/nvdn4-5qaaa-aaaaj-qa4pq-cai)
21+
- `ic_message_channel_02` canister: [zof5a-5yaaa-aaaai-acr2q-cai](https://dashboard.internetcomputer.org/canister/zof5a-5yaaa-aaaai-acr2q-cai)
22+
- `ic_message_channel_03` canister: [4jxyd-pqaaa-aaaah-qdqtq-cai](https://dashboard.internetcomputer.org/canister/4jxyd-pqaaa-aaaah-qdqtq-cai)
23+
- COSE canister:
24+
- Source code: [ic-cose](https://github.com/ldclabs/ic-cose)
25+
- Description: IC-COSE is a decentralized COnfiguration service with Signing and Encryption on the Internet Computer. Users who register a username gain a dedicated namespace on the COSE service for key derivation, key storage, and other confidential information. The number of COSE canisters can be increased based on user scale.
26+
- `ic_cose_canister` canister: [n3bau-gaaaa-aaaaj-qa4oq-cai](https://dashboard.internetcomputer.org/canister/n3bau-gaaaa-aaaaj-qa4oq-cai)
27+
- OSS canister:
28+
- Source code: [ic-oss](https://github.com/ldclabs/ic-oss)
29+
- Description: IC-OSS is a decentralized Object Storage Service on the Internet Computer. Channels have a dedicated folder on the OSS service to store files. The number of IC-OSS bucket canisters can be increased based on user scale.
30+
- `ic_oss_cluster` canister: [5szpn-tiaaa-aaaaj-qncoq-cai](https://dashboard.internetcomputer.org/canister/5szpn-tiaaa-aaaaj-qncoq-cai)
31+
- `ic_oss_bucket` canister: [532er-faaaa-aaaaj-qncpa-cai](https://dashboard.internetcomputer.org/canister/532er-faaaa-aaaaj-qncpa-cai)
32+
- `ic_oss_bucket_02` canister: [sb6zj-3aaaa-aaaaj-qndla-cai](https://dashboard.internetcomputer.org/canister/sb6zj-3aaaa-aaaaj-qndla-cai)
33+
34+
### Channels Management and Access Control
35+
36+
![Channels](../diagrams/dMsg_channels_data_flow.png)
37+
38+
- No public channels.
39+
- After creating a channel, multiple managers and regular members can be invited.
40+
- Managers can remove regular members but cannot remove other managers.
41+
- Users can read channel info and all (encrypted) messages only after joining.
42+
- After joining, users use ECDH to obtain the KEK from managers for encrypting and decrypting the DEK.
43+
- Users encrypt and decrypt messages and files with the DEK on the client side.
44+
- The channel and its data are deleted when the last manager leaves.
45+
- Sending messages and uploading files consume Gas.
46+
47+
## dMsg Client Side
48+
49+
### Master Key Derivation
50+
51+
![Master key](../diagrams/dMsg_mk_data_flow.png)
52+
53+
The client supports three types of master keys:
54+
- **Free users**: The master key (I) is generated using an on-chain derived IV and the user’s password. `MK = HKDF-SHA-256(argon2id(password, ID), IV)`
55+
- **Paid users**: The master key (II) is generated using an on-chain derived PK and the user’s password. `MK = HKDF-SHA-256(argon2id(password, ID), PK)`
56+
- **Paid users (with vetkey)**: Once the vetkey feature is live, the master key (III) will be generated using an on-chain derived vetkey and an optional user password. `MK = HKDF-SHA-256(argon2id(password, ID), Vetkey)`
57+
58+
### Key Encryption Key (KEK) Exchanging
59+
60+
![KEK Exchanging](../diagrams/dMsg_kek_exchanging_data_flow.png)
61+
62+
- The MK encrypts and decrypts the KEK.
63+
- The KEK is used to encrypt and decrypt the DEK for message channels, with a 1:1 mapping.
64+
- The encryption scheme follows AES-256-GCM as defined in RFC 9053 (COSE).
65+
- The exchanging scheme follows ECDH-ES + X25519 as defined in RFC 9053 (COSE).

scripts/deployment_guide.md

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
# Deployment Guide
2+
3+
## Running the project locally
4+
5+
If you want to test your project locally, you can use the following commands:
6+
7+
```bash
8+
# Starts the replica
9+
dfx start
10+
11+
# Creates the canisters with the specified IDs
12+
dfx canister create --specified-id rdmx6-jaaaa-aaaaa-aaadq-cai internet_identity
13+
dfx canister create --specified-id ryjl3-tyaaa-aaaaa-aaaba-cai icp_ledger_canister
14+
dfx canister create --specified-id c63a7-6yaaa-aaaap-ab3gq-cai ic_panda_frontend
15+
dfx canister create --specified-id a7cug-2qaaa-aaaap-ab3la-cai ic_panda_luckypool
16+
dfx canister create --specified-id nscli-qiaaa-aaaaj-qa4pa-cai ic_message
17+
dfx canister create --specified-id nvdn4-5qaaa-aaaaj-qa4pq-cai ic_message_channel
18+
dfx canister create --specified-id ijyxz-wyaaa-aaaaj-qa4qa-cai ic_message_profile
19+
dfx canister create --specified-id 2fvu6-tqaaa-aaaap-akksa-cai ic_message_frontend
20+
dfx canister create --specified-id n3bau-gaaaa-aaaaj-qa4oq-cai ic_cose_canister
21+
dfx canister create --specified-id 5szpn-tiaaa-aaaaj-qncoq-cai ic_oss_cluster
22+
dfx canister create --specified-id 532er-faaaa-aaaaj-qncpa-cai ic_oss_bucket
23+
24+
# Deploys the ICP Ledger canister with the specified initial values
25+
dfx identity use default
26+
export MINTER_ACCOUNT_ID=$(dfx ledger account-id)
27+
export DEFAULT_ACCOUNT_ID=$(dfx ledger account-id)
28+
dfx deploy --specified-id ryjl3-tyaaa-aaaaa-aaaba-cai icp_ledger_canister --argument "
29+
(variant {
30+
Init = record {
31+
minting_account = \"$MINTER_ACCOUNT_ID\";
32+
initial_values = vec {
33+
record {
34+
\"$DEFAULT_ACCOUNT_ID\";
35+
record {
36+
e8s = 21_000_000_000_000_000 : nat64;
37+
};
38+
};
39+
};
40+
send_whitelist = vec {};
41+
transfer_fee = opt record {
42+
e8s = 10_000 : nat64;
43+
};
44+
token_symbol = opt \"LICP\";
45+
token_name = opt \"Local ICP\";
46+
}
47+
})
48+
"
49+
50+
# Deploys the ICRC-1 token Ledger canister with the specified initial values
51+
dfx identity use default
52+
export MINTER=$(dfx identity get-principal)
53+
export DEFAULT=$(dfx identity get-principal)
54+
export ARCHIVE_CONTROLLER=$(dfx identity get-principal)
55+
export TOKEN_NAME="ICPanda"
56+
export TOKEN_SYMBOL="PANDA"
57+
export PRE_MINTED_TOKENS=100_000_000_000_000_000
58+
export TRANSFER_FEE=10_000
59+
export TRIGGER_THRESHOLD=2000
60+
export NUM_OF_BLOCK_TO_ARCHIVE=1000
61+
export CYCLE_FOR_ARCHIVE_CREATION=10000000000000
62+
export FEATURE_FLAGS=true
63+
64+
dfx deploy icrc1_ledger_canister --specified-id druyg-tyaaa-aaaaq-aactq-cai --argument "(variant {Init =
65+
record {
66+
token_symbol = \"${TOKEN_SYMBOL}\";
67+
token_name = \"${TOKEN_NAME}\";
68+
minting_account = record { owner = principal \"${MINTER}\" };
69+
transfer_fee = ${TRANSFER_FEE};
70+
metadata = vec {};
71+
feature_flags = opt record{icrc2 = ${FEATURE_FLAGS}};
72+
initial_balances = vec { record { record { owner = principal \"${DEFAULT}\"; }; ${PRE_MINTED_TOKENS}; }; };
73+
archive_options = record {
74+
num_blocks_to_archive = ${NUM_OF_BLOCK_TO_ARCHIVE};
75+
trigger_threshold = ${TRIGGER_THRESHOLD};
76+
controller_id = principal \"${ARCHIVE_CONTROLLER}\";
77+
cycles_for_archive_creation = opt ${CYCLE_FOR_ARCHIVE_CREATION};
78+
};
79+
}
80+
})"
81+
82+
# Deploys other canisters
83+
dfx deploy
84+
85+
# TODO: Add the following command to configure the dMsg canisters
86+
```
87+
88+
Open the frontend in your default browser
89+
90+
http://2fvu6-tqaaa-aaaap-akksa-cai.localhost:4943/

0 commit comments

Comments
 (0)