Giter Club home page Giter Club logo

peercrypt's Introduction

peercrypt

encrypted online & offline P2P

peercrypt is a Typescript library that enables asymmetric encrypted peer-to-peer communication between mobile & desktop browsers, both while being online and offline. It uses the libsodium library for hybrid encryption and signature verification between peers, peerjs for online connections and the web-push library for anonymously replaying encrypted push message between offline peers. Online connections An anonymous push relay service is needed

Getting started

To see a working example running peercrypt, clone the project and start an example server and client using the following commands:

git clone https://github.com/bosskabouter/peercrypt.git
cd peercrypt && npm i
npx nx run example-server:serve & npx nx run example-client-react:preview:development

Packages

The peercrypt library consists of the following packages:

  • Client packages:
  • (Optional) Server packages:
    • OnlineServer - a WebRTC Signaling server verifies the client's iD
    • OfflineServer - relays encrypted messages to anonymized client's Push Endpoint
  • shared packages:
    • shared - Contains ID with asymmetric signing and encryption keys. Already included in client and server packages
    • BIP (optional) - Optional BIP32 Hierarchical Deterministic wallet Key and BIP39 mnemonic seed recovery phrase

For detailed information about each package, see their respective pages.

Usage: In short

PeerCrypt ID

All participants (client peers as well as server instances) need a PeerCrypt ID key which holds asymmetric keys for signing and encryption purposes, both derived from a common private seed (if provided). The shared library is exported from all client and server packages, but can also be imported directly from "@peercrypt/shared";

import { ID } from '@peercrypt/shared'; // or import from any of the other packages;

const id = await ID.create('(optional) unique strong seed value' + Math.random());

console.info(`Share your public Key: ` + id.pubicIdentifier);
console.warn(`Save your private Seed: ` + id.seed);

An example On- & Offline PeerCrypt server

import { OnlineServer, ID } from '@peercrypt/online-server';
import { OfflineServer } from '@peercrypt/offline-server';

ID.create(process.env.SEED).then((id) => {
  console.log('PeerCrypt Server using public ID: ' + id.pubKey);
  OnlineServer(id);
  OfflineServer(id);
});

prints:

PeerCrypt Server using public ID: 992f3845a60d8687721db5d722ad3875bfcf09facc5ff340b6bd215ff568ac27

An example On- & Offline PeerCrypt Client

import { OnlineClient } from '@peercrypt/online-client';
import { OfflineClient, ID } from '@peercrypt/offline-client';

ID.create('*strong* seed').then(async (id) => {
  console.log('PeerCrypt Client using public ID: ' + id.pubKey);

  const serverPubKey = '992f3845a60d8687721db5d722ad3875bfcf09facc5ff340b6bd215ff568ac27';

  const onlineClient = new OnlineClient(id, serverPubKey);
  const offlineClient = await OfflineClient.register(id, serverPubKey);
});

prints:

PeerCrypt Client using public ID: 112f3845a60d8687721db5d722ad3875bfcf09facc1ff340b6bd215ff568ac27

An example: sending messages

const anotherClientPubKey = '112f3845a60d8687721db5d722ad3875bfcf09facc1ff340b6bd215ff568ac27';

const onlineClient = new OnlineClient(id);
const offlineClient = await OfflineClient.register(id);

TODO: finish

Contributions

Contributions to this project are welcome! If you would like to contribute, please open an issue or pull request on the GitHub repository.

License

peercrypt is open-source software licensed under the MIT license.

peercrypt's People

Contributors

bosskabouter avatar

Watchers

 avatar

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.