Giter Site home page Giter Site logo

symbol-secret-sharing's Introduction

npm version

Symbol Secret Sharing Library Concept

Warning: This is an experimental library, it is NOT to be used for production applications.

About

This library utilizes Shamir's Secret Sharing, a mechanism in which a given secret is divided in to a series of parts that can be later be combined to reveal the secret (called the threshold scheme). It uses this mechanism to 'shard' Symbol private keys into multiple shares, of which n of m shares are required to fully reveal the secret. You can read more about Shamir's Secret Sharing here.

This has a host of use cases with Symbol, such as the ability to distribute a private key to multiple individuals for the purposes of an "offline" sort of Symbol multisig.

Basic Usage

The basic usage is outlined below. You can create sharded private keys, encrypt, and decrypt messages. Please note that this may change in the near future, and some edge cases may not (yet) be covered.

  • Install: npm install symbol-secret-sharing
/* Divide a private key into multiple shares */

import { SecretShareMessage } from "symbol-secret-sharing";
import { Account, EncryptedMessage } from "symbol-sdk";

/* The network type */

const networkType = NetworkType.TEST_NET;

const testAccount = Account.createFromPrivateKey(
  "DD7855326A15DD11E33E30C909CD5E66036BF7BB868D143BC8F9735C9A8CFE2C",
  networkType
);

/* The message that you want to encrypt */

const secretMessage: string = "MY secret, and my secret only";

/* The 'threshold, or n of m shares needed to unlock the secret' */

const threshold = 3;

/* Total number of shares to be issued */

const numOfShares = 5;

/* Sharded private key, can be used for encryption */

const privateKeySharded: [any] = SecretShareMessage.createShardedPrivateKey(
  numOfShares,
  threshold,
  networkType,
  testAccount.privateKey
);

/* Use a sharded key to encrypt the message.  It has to have enough info has defined in the threshold */

const encryptedMessage: EncryptedMessage = SecretShareMessage.create(
  secretMessage,
  privateKeySharded,
  threshold
);

/* Use the sharded key to decrypt the message */

const decryptedMessage = SecretShareMessage.decrypt(
  encryptedMessage.payload,
  privateKeySharded,
  threshold,
  networkType
);

symbol-secret-sharing's People

Contributors

crackthecode016 avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

symbol-secret-sharing's Issues

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.