Pattern β : Bob hasn't done the initial DMTP setup
Last updated
Last updated
Until Bob finishes the initial setup, the messages to Bob are encrypted with the shared key (Alice & DMTP) and stored. At this time, the messages are not E2EE and we (DMTP) can see the messages.
Once Bob finishes the initial setup and generates keys, DMTP encrypts the messages with the shared key (Bob & DMTP) and delivers it to Bob. Bob re-encrypts the messages with the shared key (Alice & Bob). Finally, those messages are stored in DB and others encrypted with the DMTP shared key are deleted. This makes them E2EE and no one can decrypt them. even later.
Now let's take a look at the detailed flow
DMTP server verifies the signature and prove that DMTP key pair haven't been manipulated.
Alice client retrieves DMTP's pubKey
from the DB
Alice decrypts Alice’s DMTP_priKey
with her wallet.
Alice generates the combined secret
from Alice’s DMTP_priKey
and DMTP’s DMTP_pubKey
Alice encrypts messages with combined key (Alice & DMTP)
Store the encrypted messages
in the DB and IPFS
The data to be stored will look something like this.
The CID of message data is stored in Message
table in DB and CID
table in DB
【Messages Table】 ⇒ CID
【CIDs Table】 ⇒ [CID, CID, CID, CID, CID, CID]
The Message table is stored in Processing Chats
in 【Users Table】
【Users Table】⇒ Processing Chats
[ Room ID, Room ID, Room ID]
Periodically, sync all data in CID
table to IPFS and get CID
All CIDs are stored in this file
This CID is stored in the blockchain (Polygon)
Once Bob's initial DMTP setup is complete, DMTP server retrieves all message data and Bob's DMTP_pubKey
DMTP server verifies the signature and prove that DMTP key pair haven't been manipulated.
DMTP server generates the combined key from DMTP’s priKey
and Alice's DMTP_pubKey
and decrypts all messages with that.
DMTP server generates the combined key from DMTP’s priKey
& Bob's DMTP_pubKey
,and encrypts all messages with that. The encrypted message is updated in DB
Bob client retrieves the encrypted message (DMTP & Bob) & DMTP key pair
Decrypts the encrypted DMTP_priKey
with Bob’s priKey
Generates the combine secret
from Bob’s DMTP_prikey
& DMTP’s DMTP_pubKey
Use the combined secret(Bob & DMTP)
to decrypt all messages
Generates the combine secret
from Bob’s DMTP_prikey
& Alice’s DMTP_pubKey
Use the combined secret (Alice & Bob)
to decrypt all messages
Update message data stored in DB
Store new message data in IPFS and get CID
Store CID in DB
Periodically, sync all data in CID
table to IPFS and get CID
All CIDs are stored in this file
This CID is stored in the blockchain (Polygon)