Git Product home page Git Product logo

cf-e2eechat's Introduction

cf-e2eechat

End-to-end encrypted chat demo using Cloudflare Workers and Durable Objects.

Live demo: https://e2eechat.migrant.workers.dev/

Screencast: e2eechat.mp4

Usage

  1. Two users start chatting over an insecure channel which might be eavesdropping on the conversation.
  2. Both parties open https://e2eechat.migrant.workers.dev/ and copy their public key.
  3. They exchange keys over the existing channel and enter the other party's key in e2eechat.
  4. Once both users join the shared channel, they can start messaging each other with end-to-end encryption.

Inner workings

  • worker.mjs runs as a Cloudflare Worker to serve static contents (index.*) and delegates websocket requests to a Durable Object "Channel".
  • When index.html is loaded, index.js generates an ephemeral ECC key pair on the client side. The public key is hex-encoded and shown to the user for sharing.
  • After the user enters the other party's public key, a websocket connection is established at /api/channel/{channel-id}. The channel id is deterministically generated from both public keys.
  • When the other user joins the channel which is handled by the same Durable Object instance, both clients are ready for E2EE messaging.
  • Using a secret derived from the sender's private key and the recipient's public key, each message is AES-encrypted on the client side, relayed by the shared Durable Object on the server side, and eventually decrypted by the recipient on the other end.

Limitations

  • A channel allows two users only. It requires a more sophisticated E2EE protocol to support group chat.
  • For simplicity's sake, this demo does not prevent denial-of-service, message replay, and message tampering attacks.
  • No attempt is made to reconnect to a broken websocket session.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.