New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

cryptomancy-shard

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cryptomancy-shard

really basic secret sharing based on xor

latest
Source
npmnpm
Version
2.0.0
Version published
Weekly downloads
5
-37.5%
Maintainers
1
Weekly downloads
 
Created
Source

Cryptomancy-shard

For secret-sharing schemes which need support for threshold recombination there's cryptomancy-secret. If your needs are incredibly simple, this module may provide a simpler option.

Its goal is to be:

  • small
  • fast
  • flexible
  • readable
  • secure

It's missing:

  • threshold support
  • authentication
  • padding bytes

Use

// the API takes and outputs Uint8Arrays
// so you'll probably want to convert between that and different formats
var Format = require("cryptomancy-format");

// it expects you to supply your own randomness
// so it can be deterministic if that suits your needs
// otherwise use a cryptographically secure source of random bytes
var Source = require("cryptomancy-source");
var secure_bytes = Source.bytes.secure();

var plaintext = "PEW PEW PEW";
var u8_message = Format.decodeUTF8(plaintext);

// load the library
var Shard = require("cryptomancy-shard");

// split the plaintext up into 5 shards
// all of which are necessary to reproduce the original value
var shards = Shard.split(secure_bytes, u8_message, 5);

// print out your shards in whatever format you like
// I like base64 because they're probably not valid UTF8
// and I don't like hex
console.log(shards.map(Format.encode64));

// join the shards
// order doesn't matter because internally it's just xor'ing the values
var recovered = Format.encodeUTF8(Shard.join(shards));

console.log(recovered);

Keywords

cryptomancy

FAQs

Package last updated on 22 Jun 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts