Giter Club home page Giter Club logo

libgossamer's Introduction

Libgossamer

Build Status Static Analysis Latest Stable Version Latest Unstable Version License Downloads

Want to learn about the Gossamer project? Check out our website!

Library that provides most of the plumbing for the Gossamer PKI.

Since version 0.4.0 it also bundles a client-side library for retrieving keys and verifying the signatures of update files.

The code syntax is compatible with PHP 5.3+, but this is only intended for PHP 5.6+, as per WordPress's new minimum supported version.

Getting Started

Installing

First, obtain the source code from Composer/Packagist, like so:

composer require paragonie/libgossamer:^0|^1

This will include two components:

  1. The library that implements the Gossamer specification.
  2. The Gossamer Client.

The next steps will depend entirely on what you want to do with Gossamer. Check out the tutorials directory for specific next steps.

Other Repositories

Documentation

Read the Libgossamer Documentation online.

libgossamer's People

Contributors

p810 avatar paragonie-scott avatar paragonie-security avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Forkers

p810 ndinhbang

libgossamer's Issues

Alternative Cryptographic Ledger (Trillian)

Note: This is a "scoped for the future" milestone item. Not an immediate goal.

When the appropriate change has landed, ecosystems will be able to write to a Chronicle or Trillian, or to both.

Some other projects (e.g. Go, Firefox) already use a Trillian personality to accomplish a similar security goal.

For the sake of interoperation (and/or just flat-out piggybacking off their security analysis). we may want to integrate with Trillian as well.

These are the only two I plan on ever supporting in my design, and only if it's worthwhile. For the time being, just Chronicle is fine.

Limited-Power Keys

Some organizations may wish to provision a signing key that can perform all operations (i.e. their first AppendKey operation), and then delegate limited-power keypairs to their developer teams.

We should add the concept of keys that can only issue an AppendUpdate action, at our protocol level, in case the infrastructures fail to enforce ACLs.

Release Bundlers

There are many ways to ship an update for a PHP dependency

  • zip
  • tar / tar.gz
  • phar
  • diff/patch

We should include different bundler logic for each of these types of deliverables to ensure it's easy to sign updates.

Additional Degree of Freedom for AppendUpdate / RevokeUpdate?

Right now, a software update is identified by the tuple: (provider, package, version). The version string is an opaque string, but most users will provide a version string (e.g. v1.23.45).

We should also consider the possibility of adding a "release type" to the tuple. This results in an additional degree of freedom, but also provides flexibility for different release strategies.

For example, it might be reasonable for PHP libraries to sign both a .tar of the source contents of their source code repository as well as a patch file between the old release and the new release. For people who are first installing their dependency, they'll need the tarball, but for people who are updating, they only need the diff.

Is this worth the additional complexity? If we don't add this, will users just shoehorn it into the opaque version string?

Unit Test Coverage

Before I tag the first release, we need 100% test coverage.

As it stands, we already have 100% static analysis coverage via Psalm.

Post-Quantum Cryptography

Not today, but some day soon, the Internet may need post-quantum cryptography. NIST is currently putting forth the initial effort to standardize some asymmetric KEMs and signature algorithms for a post-quantum Internet.

There has been some debate on the IETF's CFRG mailing list about whether to switch immediately to post-quantum algorithms, or to implement a hybrid approach. Our internal consensus is on a hybrid signature scheme.

In a future release, we will need to add a definition for a new signature algorithm. This will be a hybrid algorithm consisting of Ed25519 and a post-quantum algorithm.

I've included a sketch for a hybrid signature scheme based on FALCON-512 below.

Example: Ed25519 + FALCON-512

Note: A real implementation would use distinct value objects to prevent misuse.

Key Generation

<?php
const PQ_PREFIX_EDDSA  = 'libgossamer_ed25519';
const PQ_PREFIX_FALCON = 'libgossamer_falcon512';

function hybrid_keygen(string $seed): array
{
    // Derive independent, deterministic seeds from the long-term 512-bit secret
    $eddsa_seed = hash_hkdf('sha512', $seed, 32, PQ_PREFIX_EDDSA . $seed);
    $falcon_prng_seed = hash_hkdf('sha512', $seed, 32, PQ_PREFIX_FALCON . $seed);

    // Generate two keypairs (one classical, one post-quantum)
    $eddsa_keypair = sodium_crypto_sign_seed_keypair($eddsa_seed);
    $falcon_keypair = crypto_sign_falcon512_seed_keypair($falcon_prng_seed);

    // Grab components
    $eddsa_secret = sodium_crypto_sign_secretkey($eddsa_keypair);
    $falcon_secret = crypto_sign_falcon512_secretkey($falcon_keypair);
    $eddsa_public = sodium_crypto_sign_publickey($eddsa_keypair);
    $falcon_public = crypto_sign_falcon512_publickey($falcon_keypair);

    return [
        $eddsa_secret . $falcon_secret,
        $eddsa_public . $falcon_public
    ];
}

// 512-bit random byte seed; store this value
$seed = random_bytes(64);
[$secret, $public] = keygen($seed);

Signing

<?php
function hybrid_sign(string $message, string $secret_key): string
{
    $eddsa_sk = mb_substr($secret_key, 0, 64, '8bit');
    $falcon_sk = mb_substr($secret_key, 64, null, '8bit');
    
    $eddsa_sig = sodium_crypto_sign_detached($message, $eddsa_sk);
    $falcon_sig = crypto_sign_falcon512_detached($message, $falcon_sk);
    return $eddsa_sig . $falcon_sig;
}

Verifying

<?php
function hybrid_verify(string $signature, string $message, string $public_key): bool
{
    $eddsa_pk = mb_substr($public_key, 0, 32, '8bit');
    $falcon_pk = mb_substr($public_key, 32, null, '8bit');
    $eddsa_sig = mb_substr($signature, 0, 64, '8bit');
    $falcon_sig = mb_substr($signature, 64, null, '8bit');
    
    $eddsa_valid = sodium_crypto_sign_verify_detached($eddsa_sig, $message, $eddsa_pk);
    $falcon_valid = crypto_sign_falcon512_verify_detached($falcon_sig, $message, $falcon_pk);
    return $eddsa_valid && $falcon_valid;
}

Remarks

By unifying two signature algorithms into one single "hybrid" algorithm, and treating it as if it was just EdDSA (or equivalent), we can prevent an entire class of algorithm misuse vulnerabilities.

Users would be expected to retain a 512-bit (64 byte) secret key, which will be used to create an Ed25519 keypair and PRNG seed for a FALCON-512 keypair. The result would be a single keypair.

  • The first 64 bytes of the hybrid secret key will be an Ed25519 secret key. The remaining bytes will be the FALCON-512 secret key.
  • The first 32 bytes of the hybrid public key will be an Ed25519 public key. The remaining bytes will be the FALCON-512 public key.
  • The first 64 bytes of each signature will be an Ed25519 signature. The remaining bytes will be the FALCON-512 signature.

As you can see, this pattern can be generalized to any post-quantum signature algorithm. (We chose FALCON-512 for this example because it's an attractive candidate in terms of bandwidth and performance.)

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.