npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

cryptomancy-extended-oblivion

v1.0.0

Published

tools for more complex behaviour involving oblivious transfer

Downloads

5

Readme

Cryptomancy-extended-oblivion

DISCLAIMER

I'm writing this code as a hobby project.

I don't recommend that you use it for anything critical.

About

cryptomancy-oblivion implements Oblivious-Transfer (OT). That means Bob can choose between two options offered by Alice without revealing which of the options he chose. That's pretty cool and can be useful in situations where you have a yes/no choice to make. If you have more choices to make, you need something a little fancier.

cryptomancy-shard implements a very simple (non-threshold) secret-sharing algorithm, in which a secret can be divided into any number of components, all of which will be necessary to recover the input.

The sharding algorithm allows for us to implement a logical-and operation across choices, facilitating composition into more complex decision structures.

For example, given four secrets {A,B,C,D}

| | 0| 1| | -| -| -| | 0| A| B| | 1| C| D|

To implement choices from larger numbers of elements, you only need to execute more oblivious-transfer protocols.

This module provides basic functions which make this process easier.

Use

comparisons

var Extended = require("cryptomancy-extended-oblivion");

// 'comparisons' computes how many oblivious transfers
// are required to choose between a number of options

var secrets = [" ONE ", " TWO ", "THREE", " FOUR", " FIVE"];

Extended.comparisons(secrets.length); // 3

chooseBuckets

// 'chooseBuckets' takes the index of the element you'd like to choose
// and the number of transfers required for the set
// and returns the choices you'll have to make to choose that item.
// notably, Alice and Bob need to agree on this protocol for Bob to receive
// the element he'd actually like to obtain
Extended.chooseBuckets(1,
    Extended.comparisons(secrets.length)); // [0, 0, 1]

compose

// 'compose' requires a source of randomness to produce shares
// it's pluggable so that you can design your protocol however you want
// you can use a deterministic source of entropy if you want reproducable results.
// unless you have a good reason to do so, use a cryptographically secure source of bytes
var Source = require("cryptomancy-source");

// it's also worth mentionting that you need to convert your secrets into Uint8Arrays
var Format = require("cryptomancy-format");

var u8_secrets = secrets.map(Format.decodeUTF8);

// an array of binary choices is returned
// each choice is an object containing labeled shares
Extended.compose(Source.bytes.secure(), u8_secrets);

Choice structure

// the structure of the choices for [A, B, C, D] is as follows:

/*
var SET = [
    [
        {0: 'A0', 1: 'B0'},
        {2: 'C0', 3: 'D0'},
    ],
    [
        {0: 'A1', 2: 'C1'},
        {1: 'B1', 3: 'D1'}
    ]
];
*/

Recovery

// to recover C from SET, you would choose like so:

// the first array access indicates the index of the choice
// the second indicates which of the two buckets you'd like
// the third indicates the element you'd like from that bucket
var share1 = SET[0][1][2];
var share2 = SET[1][0][2];

// ...and use my shard library to combine the secrets
var Shard = require("cryptomancy-shard");

Shard.combine([
    share1,
    share2
]);

Caveats

In a practical OT protocol you'd want to serialize each bucket in encrypted form, and pad the plaintext to prevent information leak via the size of the ciphertexts.