threshold-pairing 0.1.0

Pairing threshold cryptography
Documentation
# threshold-pairing

A pairing-based threshold cryptosystem for collaborative decryption and signatures.

This is a fork from `threshold_crypto` which updates the dependencies and improves cryptographic standards compliance. **Note: This fork is not backwards compatible with the original `threshold_crypto` due to changes in the hash-to-curve implementation.**

The `threshold-pairing` crate provides cryptographic keys with methods for signing and encrypting messages, as well as key sets for _threshold_ signatures and threshold encryption.

The threshold signature scheme is described in [Threshold Signatures, Multisignatures and Blind Signatures Based on the Gap-Diffie-Hellman-Group Signature Scheme](https://www.iacr.org/archive/pkc2003/25670031/25670031.pdf) by Alexandra Boldyreva. This paper extends [Boneh-Lynn-Shacham](https://www.iacr.org/archive/asiacrypt2001/22480516.pdf) signatures to the threshold setting. Message encryption uses the [scheme by Baek and Zhang](http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.119.1717&rep=rep1&type=pdf).

Our implementation is based on the [`bls12_381`](https://crates.io/crates/bls12_381) elliptic curve library.

## Key Features

- **Threshold Signatures**: Any `t + 1` participants can collaborate to sign a message
- **Threshold Encryption**: Encrypted messages require `t + 1` participants to decrypt
- **Unique Signatures**: Signatures are deterministic and independent of the signing set
- **Distributed Key Generation**: Tools for trustless key generation
- **RFC 9380 Compliance**: Standard hash-to-curve implementation (BLS signatures)

## threshold-crypto

The original code is based on [threshold_crypto](https://docs.rs/threshold_crypto/latest/threshold_crypto/) but we bumped all dependencies to the latest possible version. We also improved the API by hardening it and removing a few foot guns. The two libraries are not fully compatible because we switched the hash-to-curve implementation to the RFC9380 standard.

## Security Audit

An [official security audit](https://github.com/poanetwork/wiki/wiki/Threshold-Crypto-Audit) has been completed on the original `threshold_crypto` by [Jean-Philippe Aumasson](https://aumasson.jp/). No exploitable security issues were found.

## Usage

Add to your `Cargo.toml`:

```toml
[dependencies]
threshold-pairing = "0.1"
```

### Feature Flags

- **`serde`** (enabled by default): Adds `Serialize` and `Deserialize` impls for all public types
- **`bincode`**: Enables bincode serialization support (requires `serde`)
- **`serialization`**: Convenience feature that enables both `serde` and `bincode`
- **`expose-secret`**: Enables `reveal()` methods on secret types for debugging (**dev/debug only, never use in production**)

To use without serde:

```toml
[dependencies]
threshold-pairing = { version = "0.1", default-features = false }
```

To enable all serialization features:

```toml
[dependencies]
threshold-pairing = { version = "0.1", features = ["serialization"] }
```

### Basic Example

```rust
use threshold_pairing::SecretKey;

fn main() {
    let sk = SecretKey::random();
    let pk = sk.public_key();

    let msg = b"Hello, threshold cryptography!";
    let signature = sk.sign(msg);

    assert!(pk.verify(&signature, msg));
}
```

For detailed API documentation, examples, and guides, see the [full documentation on docs.rs](https://docs.rs/threshold-pairing/).

## License

Licensed under either of:

* Apache License, Version 2.0 ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0)
* MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT)

at your option.

## Links

* [Documentation](https://docs.rs/threshold-pairing/)
* [Repository](https://github.com/Sapiens-Engineering/threshold-pairing)
* [Contributing Guide](CONTRIBUTING.md)