Aggregatable BLS sigantures

Related tags

Cryptography bls
Overview

bls Crates.io

Boneh-Lynn-Shacham (BLS) signatures have slow signing, very slow verification, require slow and much less secure pairing friendly curves, and tend towards dangerous malleability. Yet, BLS permits a diverse array of signature aggregation options far beyond any other known signature scheme, which makes BLS a preferred scheme for voting in consensus algorithms and for threshold signatures.

In this crate, we take a largely unified approach to aggregation techniques and verifier optimisations for BLS signature: We support the BLS12-381 (Barreto-Lynn-Scott) curves via ZCash's traits, but abstract the pairing so that developers can choose their preferred orientation for BLS signatures. We provide aggregation techniques based on messages being distinct, on proofs-of-possession, and on delinearization, although we do not provide all known optimisations for delinearization.

We cannot claim these abstractions provide miss-use resistance, but they at least structure the problem, provide some guidlines, and maximize the relevance of warnings present in the documentation.

Documentation

You first bring the bls crate into your project just as you normally would.

use bls_like::{Keypair,ZBLS};

let keypair = Keypair::<ZBLS>::generate(::rand::thread_rng());
let message = Message::new(b"Some context",b"Some message");
let sig = keypair.sign(message);
assert!( sig.verify() );

In this example, sig is a SignedMessage<ZBLS> that contains the message hash, the signer's public key, and of course the signature, but one should usually detach these constituents for wire formats.

Aggregated and blind signatures are almost the only reasons anyone would consider using BLS signatures, so we focus on aggregation here. We assume for brevity that sigs is an array of SignedMessages, as one might construct like

let sigs = msgs.iter().zip(keypairs.iter_mut()).map(|(m,k)| k.sign(*m)).collect::<Vec<_>>();  

As a rule, aggregation that requires distinct messages still requires one miller loop step per message, so aggregate signatures have rather slow verification times. You can nevertheless achieve quite small signature sizes like

let mut dms = sigs.iter().try_fold(
    ::bls::distinct::DistinctMessages::<ZBLS>::new(), 
    |dm,sig| dm.add(sig)
).unwrap();
dms.signature()

Anyone who receives the already aggregated signature along with a list of messages and public keys might reconstruct this like:

let mut dms = msgs.iter().zip(publickeys).try_fold(
    ::bls::distinct::DistinctMessages::<ZBLS>::new(), 
    |dm,(message,publickey)| dm.add_message_n_publickey(message,publickey)
) ?;
dms.dms.add_signature(signature);
dms.verify()

We recommend distinct message aggregation like this primarily for verifying proofs-of-possession, meaning checking the self certificates for numerous keys.

Assuming you already have proofs-of-possession, then you'll want to do aggregation with BitPoPSignedMessage or some variant tuned to your use case. We recommend more care when using BatchAssumingProofsOfPossession because it provides no mechanism for checking a proof-of-possession table.

// TODO: Use BitPoPSignedMessage

If you lack proofs-of-possesion, then delinearized approaches are provided in the delinear module, but such schemes might require a more customised approach.

Security Warnings

This library does not make any guarantees about constant-time operations, memory access patterns, or resistance to side-channel attacks.

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Comments
  • Use WB hash to curve for BLS Engine

    Use WB hash to curve for BLS Engine

    This require in part to replace the dependancy to arkworsk-w3f. This also temprory breaks BLS12-381 signature. Because WB hash has not implement for BLS12-381 yet. But the tests should pass for BLS12-377.

    opened by drskalman 4
  • Update BLS library to Pairing and Serialization changes

    Update BLS library to Pairing and Serialization changes

    There are quite few changes in Arkworks Algebra which need to be reflected in the BLS library. including the renaming of the Projective and Affine Curve, removal of to_bytes and from_bytes interfaces and changes in pairing engine. BLS library need to compile and pass the tests again.

    opened by drskalman 3
  • Make ValidatorSet generic over public key type

    Make ValidatorSet generic over public key type

    ValidatorSet is a set of authority ids, of type of primitive::beefy::crypto:Public which is currently hard wired to ECDSA public key. We need to change primitives::beefy::crypto:Public to primitives::beefy::crypto:ECDSAPublic and then make primitives::beefy::crypto:Public generic to be either ECDSA or ECDSA,BLS pair. that way the whole code of beefy validator can be generic over type of the public key.

    opened by drskalman 3
  • Implement BLS crypto type for Substrate

    Implement BLS crypto type for Substrate

    Substrate requires a crypto type similar to: https://github.com/paritytech/substrate/blob/master/primitives/application-crypto/src/ecdsa.rs to be able to instantiate a signer for beefy capable of bls sigining. Implementing such crypto types help implementers to kick off BLS on beefy.

    opened by drskalman 3
  • Review, verify, clean up and update README.md

    Review, verify, clean up and update README.md

    Check if the fact mentioned in the README.md of the crate is still relevant and if the README code compiles. Additionally:

    • [x] Emphasize on simple cases so we do not scare people out: One messaged singed by two party according to IETF proposal.
    • [x] Add explanation for the hash to curve because the library is opinionated about it.
    • [x] Explain Schnorr pop.
    opened by drskalman 3
  • Implement different trait for generating and verifying PoP

    Implement different trait for generating and verifying PoP

    Sample interface is on the branch: origin/skalman-pok-new-interface

    • Generate trait should be implemented by the secret key.
    • Verify trait should be implemented by the public key.
    opened by drskalman 3
  • implement `From<<Self as engine::EngineBLS>::PublicKeyGroupAffine>`

    implement `From<::PublicKeyGroupAffine>`

    I have introduced auxaulary types PublicKey/SignaturePrepared to make the EngineBLS compatible with Zexe Curves but so I need to tell rust how to convert from pairing agnostic curves to the elements prepared specififcally for G1 or G2.

    opened by drskalman 3
  • Reverse beefy messages to only support  unaggregated BLS signatures in Beefy

    Reverse beefy messages to only support unaggregated BLS signatures in Beefy

    APK proof can only be applied to bitfield (disjoint) aggregated BLS signature (in oppose with counted aggregation). This makes it impossible for validator to apply disjoint aggregation to aggregated BLS signatures they receive in a disorganized gossip. As such till we have a more intelligent gossip topolgy it is impossible for validators to aggregate BLS signatures before gossiping them again. As such they should sent the full list of unaggregated signatures and the prover will aggregate them before producing the proof.

    opened by drskalman 2
  • clean up the depenedancy so they are compatible with substrate

    clean up the depenedancy so they are compatible with substrate

    blake2 implementation of substrate is different from the one used in bls-like. Furthermore there are dev depenedency which are marked as dependancy and they don't blong there.

    opened by drskalman 2
  • Resolve the failing bls library tests after backend upgrade

    Resolve the failing bls library tests after backend upgrade

    • [ ] test single::tests::single_messages ... FAILED
    • [X] test delinear::tests::delinearized ... ok
    • [X] test distinct::tests::distinct_messages ... ok
    • [ ] test bit::tests::proofs_of_possession ... FAILED
    opened by drskalman 2
  • fix the serialization interface between bls and zexe

    fix the serialization interface between bls and zexe

    zexe now uses serde like serialization as zkcrypto was using a EncodedPoint trait. We need to either adapt or migrate to new serialization or the tests won't pass.

    opened by drskalman 2
  • Make `keystore_vs_validator_set` test generic over the keystore

    Make `keystore_vs_validator_set` test generic over the keystore

    this test run create_beefy_worker which needs to be generic and creates a validator set. All this should be generic and then tested on both ecdas and the ecdsa_n_bls schemes.

    opened by drskalman 1
  • Write test for BeefyECDSAandBLSKeystore

    Write test for BeefyECDSAandBLSKeystore

    Tests for BeefyECDSAKeystore should also be adapted to BeefyECDSAandBLSKeystore or the should become generic so can be run for both (or all three keystores).

    opened by drskalman 1
  • Skalman hash to curve wb

    Skalman hash to curve wb

    • Adapting the new arkworks frame work.
    • fixing hacks and using from_be_bytes_mod_order.
    • Using compressed serialized and new test for it.
    • Pass All tests
    opened by drskalman 1
  • How is `context` meant to be used when creating a new `Message`?

    How is `context` meant to be used when creating a new `Message`?

    Most code from this library uses the text "ctx" although the README uses "Some context" and the From impl for Message uses a blank string.

    It seems like the string plus length of message gets prepended to the message itself, implying any signatures derived from this Message will be affected by the choice of context.

    What is it for, and what is best practice for its usage?

    opened by jonarmani 0
  • modify  `client/beefy/src/worker.rs` to use either ECDSA or BLSnECDSA keystores

    modify `client/beefy/src/worker.rs` to use either ECDSA or BLSnECDSA keystores

    worker.rs currently only using BeefyKeystore to carry out crypto tasks, however in the new structure BeefyKeystore is only a trait now and the worker either need to instiate BeefyECDSAKeystor or BeefyBLSnECDSAKeystore depending if they want to certify their BEEFY messages using Merkle tree of ECDSA signature or an aggregated BLS signature.

    opened by drskalman 0
Owner
Web3 Foundation
Web3 Foundation
Aggregatable Distributed Key Generation

Aggregatable DKG and VUF WARNING: this code should not be used in production! Implementation of Aggregatable Distributed Key Generation, a distributed

Kobi Gurkan 38 Nov 30, 2022
BLS Signatures in Rust

BLS Signatures Implementation of BLS signatures in pure Rust. Development BLST Portability To enable the portable feature when building blst dependenc

Filecoin 50 Dec 25, 2022