Git Product home page Git Product logo

channels's Introduction

channels

experimental: derive keys from keys. built on redschnorr for hypercore-red.

hypercore is a secure, distributed append-only log that can be replicated on p2p networks.

this library is a proof of concept meant to demonstrate the viability of deterministically generating namespaced subfeeds associated with a given feed, which is possible because hypercore feeds are identified by public keys.

this library works with an experimental and incompatible fork of an implementation of hypercore in rust that is still under development. it is insecure, so don't use it.

examples

public channels

// generate Alice's keypair { public, secret }
let alice = generate_keypair();
let channel = b"cats";

// derive the keypair for Alice's `cats` channel from Alice's secret key
let cats_secret_key = derive_channel_secret::<Sha512>(&alice.secret, channel).unwrap();
let cats_public_key = derive_public_key(&cats_secret_key).unwrap();

// derive the public key for Alice's `cats` channel from Alice's public key
let pub_cats_public_key = derive_channel_public::<Sha512>(&alice.public, channel).unwrap();

println!("{:?}", pub_cats_public_key == cats_public_key);

shared secret channels

// generate Alice and Bob's keypairs { public, secret } and derive their shared secret
let alice = generate_keypair();
let bob = generate_keypair();
let shared_secret = derive_shared_secret(&alice.secret, &bob.public).unwrap().to_bytes();

// derive Alice's private channels to and from Bob
let to_bob_secret = derive_channel_secret::<Sha512>(&alice.secret, &shared_secret).unwrap();
let to_bob_public = derive_public_key(&to_bob_secret).unwrap();
let from_bob_public = derive_channel_public::<Sha512>(&bob.public, &shared_secret).unwrap();

// derive Bob's private channels to and from Alice
let to_alice_secret = derive_channel_secret::<Sha512>(&bob.secret, &shared_secret).unwrap();
let to_alice_public = derive_public_key(&to_alice_secret).unwrap();
let from_alice_public = derive_channel_public::<Sha512>(&alice.public, &shared_secret).unwrap();

println!("{:?}", from_bob_public == to_alice_public);
println!("{:?}", from_alice_public == to_bob_public);

channels's People

Contributors

lukeburns avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  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.