🔬
DMTP Docs
  • About DMTP
    • The problems DMTP solves
    • About DMTP Token
    • $DMTP Allocation
    • $DMTP Staking
    • Governance
    • DMTP Protocol
    • DMTP Product
  • How-to-use
    • Guidance
      • Linking Wallet
      • Group chats
      • Chat
  • DMTP System
    • Generation of DMTP key pairs
    • Encryption & Decryption
      • Peer to Peer
        • Pattern α : Bob and Alice have already done the initial DMTP setup.
        • Pattern β : Bob hasn't done the initial DMTP setup
      • Public Unlimited
      • Public Limited
      • Private Group
    • Message data storage
    • Cryptographic algorithm
    • Wide-compatibility
  • Builders Guides
    • 📎SDK Quick Start
    • How to get DMTP API Key
Powered by GitBook
On this page
  1. DMTP System
  2. Encryption & Decryption
  3. Peer to Peer

Pattern α : Bob and Alice have already done the initial DMTP setup.

PreviousPeer to PeerNextPattern β : Bob hasn't done the initial DMTP setup

Last updated 2 years ago

  1. DMTP server verifies the signature and prove that DMTP key pair haven't been manipulated.

  2. Alice client retrieves Alice’s encrypted DMTP_priKey and Bob’s DMTP_pubKeyfrom the DB

  3. Alice decrypts Alice’s DMTP_priKey with her wallet.

  4. Alice generates the combined secret from Alice’s DMTP_priKey and Bob’s DMTP_pubKey

  5. 5.Alice encrypts messages with combined key (Alice & Bob)

  6. Store the encrypted message in DB and IPFS. The data to be stored will look something like this.

    {   
      "messages":"ENCRYPTED_MESSAGE_WITH_COMBINE_KEY",  
      "sender": "SENDER_WALLET_ADDRESS",  
      "receiver": "RECEIVER_WALLET_ADDRESS",  
      "timestamp": "TIMESTAMP"
    }
  7. 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]

  8. Periodically, sync all data in CID table to IPFS and get CID All CIDs are stored in this file

    {
      "ROOM_ID_A": ["CID", "CID", "CID", "CID", "CID"],
      "ROOM_ID_B": ["CID", "CID", "CID", "CID", "CID"],
      "ROOM_ID_C": ["CID", "CID", "CID", "CID", "CID"],
    }
  9. This CID is stored in the blockchain (Polygon)

    string[] cids;
    function storeCID(string memory _cid) public onlyOwner{
      cids.push(_cid);
    }