Code Monkey home page Code Monkey logo

Safehill-Crypto

A (soon-to-be-cross-platform) library to manage encryption and decryption of data.

Sharing encrypted content

All users have a set of locally generated asymmetric keys (private P, public Q):

  • Alice has private key PA and corresponding public key QA
  • Bob has private key PB and corresponding public key QB
  • Charlie has private key PC and corresponding public key QC

Their public key is usually shared publicly with everyone, on a server.

Encrypting and sharing with a subset of users

Alice (A) wants to share d1 securely and privately with Bob (B) and Charlie (C).

In order to do so, Alice does the following:

  1. Alice encrypts the unencrypted data d1 (CLEAR) using a symmetric key Pd1 to obtain Ed1 (CYPHER) Ed1 = E(d1, Pd1)
  2. Alice stores Pd1 in the keychain (protecting data at rest). The keychain is usually synced, so Alice can get to the data from any of her devices.
  3. Alice then encrypts Pd1 with Bob and Charlie's public keys (QB and QC, respectively) to get EBPd1 and ECPd1 (encrypted Pd1 for Bob and Charlie, respectively) EBPd1 = E(Pd1, QB) ECPd1 = E(Pd1, QC)
  4. Alice sends Ed1 and EBPd1 to Bob, and Ed1 and ECPd1 to Charlie
  5. Bob decrypts EBPd1 using his private key PB to obtain d1's decryption key, then decrypts Ed1 Pd1 = D(EBPd1, PB) d1 = D(Ed1, Pd1)
  6. Charlie decrypts ECPd1 using his private key PB to obtain d1's decryption key, then decrypts Ed1 Pd1 = D(ECPd1, PC) d1 = D(Ed1, Pd1)
  7. All 3 parties have now access to d1, but noone else can read the data

Adding users to the share

Alice now wants to add Dave (D) to the existing share of d1.

This process only requires to share extra encrypted key with Dave (or uploading extra metadata to a server). It does not involve other users in the share and does not require any modifications to the content.

  1. Alice encrypts Pd1 with Dave's public key (QD) to get EDPd1 (encrypted Pd1 for Dave) EDPd1 = E(Pd1, QD)
  2. Alice sends Ed1 and EDPd1 to Dave
  3. Dave - as Bob and Charlie - decrypts EDPd1 using his private key PD to obtain d1's decryption key, then decrypts Ed1 Pd1 = D(EDPd1, PD) d1 = D(Ed1, Pd1)

Revoking access

Alice now wants to revoke Charlie's access to d1

  1. Alice re-encrypts d1 with a new symmetric key P'd1 E'd1 = E(d1, P'd1)
  2. Alice encrypts P'd1 with Bob's public key QB EBP'd1 = E(P'd1, QB)
  3. Alice notifies Bob about the change, by sending him both E'd1 and EBP'd1 (or uploading it to a server).

safehill's Projects

exytechat icon exytechat

A SwiftUI Chat UI framework with fully customizable message cells and a built-in media picker

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.