Giter Site home page Giter Site logo

ahdinosaur / secret-channel Goto Github PK

View Code? Open in Web Editor NEW
4.0 3.0 0.0 44 KB

🤫 A protocol for an authenticated and encrypted message stream

JavaScript 98.51% TypeScript 1.49%
aead authenticated authenticated-encryption chacha20-poly1305 chacha20poly1305 crypto cryptography encryption stream streaming

secret-channel's Introduction

"Secret Channel" 🤫

Streaming authenticated encryption using ChaCha20-Poly1305 (RFC 8439) (or other AEADs).

A protocol for a secure message stream, after you've done a secure key exchange.

Fig 7 Le Telephone by T du Moncel Paris 1880

(Note: This protocol has not been audited to be safe. Use at your own risk.)

Specification

See SPEC.md

Packages

JavaScript

ci status

Protocol: secret-channel

npm version npm downloads

Pull Stream: pull-secret-channel

npm version npm downloads

Node Stream

TODO

Rust

Protocol

TODO

Async Stream

TODO

secret-channel's People

Contributors

ahdinosaur avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

secret-channel's Issues

Key usage limits and re-keying

Looks like AEAD algorithms have usage limits: https://www.ietf.org/archive/id/draft-irtf-cfrg-aead-limits-07.html

ChaCha20-Poly1305's limit is 2^100. Wait... that's plenty good.

But @noble/ciphers says 2^46: https://github.com/paulmillr/noble-ciphers#encryption-limits. Why the difference?

Will look into this more. If the limit is low enough, we could set a threshold to automatically re-key.

The idea would be to have the 96-bit nonce constructed similar to STREAM and libsodium's secretstream:

  • 64-bits are a preset (random) nonce
  • 32-bits are a incrementing counter starting at 0.
  • When the 32-bit counter overflows, automatically re-key.

Start with random nonce and increment?

Rather than start our nonce with zero, there's a possible security gain (for the far-away future, since current 192-bit keys are considered secure even with simple counting nonces starting from zero) if we start our nonce with a preset (random) value.

This is what secret-handshake and pull-box-stream did. https://ssbc.github.io/scuttlebutt-protocol-guide/#box-stream

I'm not super convinced it's worth it. But maybe I'm wrong.

I see also that TLS has a counter that starts at zero, but XOR's that counter with a preset (random) value to construct the nonce.

Big endian vs little endian

Not sure whether to use big endian or little endian.

My understanding is most CPUs are LE (so LE is more efficient), but network protocols are "supposed to be" BE. https://developer.mozilla.org/en-US/docs/Glossary/Endianness

One idea is we use little endian for the incrementing nonce (used internally), and big endian for the content length (sent over the network). Little endian for the nonce helps make incrementing with libsodium easy, because libsodium provides a increment function which increments a little-endian buffer.

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.