Crates.io | hints |
lib.rs | hints |
version | |
source | src |
created_at | 2025-03-28 22:52:19.760414+00 |
updated_at | 2025-03-28 23:22:25.497701+00 |
description | A library for computing weighted threshold signatures |
homepage | |
repository | |
max_upload_size | |
id | 1610649 |
Cargo.toml error: | TOML parse error at line 28, column 1 | 28 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include` |
size | 0 |
⚠️ This code has NOT been audited by anyone except the author. Use at your own risk! ⚠️
An implementation of the hinTS paper, heavily modified from the research prototype.
This library provides an efficient mechanism for aggregating BLS signatures ✍️ while verifying that a weighted threshold 🧮 is met. The "silent setup" 🤐 means that anyone can perform the aggregation — no communication needed between signers! 📡 All you need is the public keys of the participants 🪪 and a hint 🔍 that commits to their secret keys 🗝️. The threshold can be different for every message.
Built using ⚙️ arkworks for the cryptographic math 🧙♂️.
⚠️ This code has NOT been audited by anyone except the author. Use at your own risk! ⚠️
hinTS is built on top of BLS signatures and uses Plonk-style arguments with KZG polynomial commitments to efficiently verify signature aggregation. At a high level:
⚠️ This code has NOT been audited by anyone except the author. Use at your own risk! ⚠️
Here's a simple example of how to use hinTS:
use ark_std::{UniformRand, rand::Rng};
use hints::{*, snark::{finish_setup, Hint, KZG, GlobalData, F}};
fn sample_weights(n: usize, rng: &mut impl Rng) -> Vec<F> {
(0..n).map(|_| F::from(u64::rand(rng))).collect()
}
// Generate random ("insecure") KZG setup
let mut rng = ark_std::test_rng();
let domain = 4; // Maximum number of signers
let n = 3;
let gd = GlobalData::from_params(domain, KZG::setup_insecure(domain, &mut rng).expect("Setup failed"));
// Generate keys for each participant
let sk: Vec<SecretKey> = (0..n).map(|_| SecretKey::random(&mut rng)).collect();
let pks: Vec<PublicKey> = sk.iter().map(|sk| sk.public(&gd)).collect();
// Generate hints for each participant
let hints: Vec<Hint> = sk.iter()
.enumerate()
.map(|(i, sk)| snark::hintgen(&gd, sk, domain, i).expect("Failed to generate hints"))
.collect();
// Setup with weights
let weights = sample_weights(n, &mut rng);
let (ak, vk, hint_errors) = finish_setup(&gd, domain, pks, &hints, weights.clone())
.expect("Failed to finish setup");
// Sign a message with each signer
let partials: Vec<(usize, PartialSignature)> = sk.iter()
.enumerate()
.map(|(i, sk)| (i, sk.sign(b"hello")))
.collect();
// Aggregate signatures with a threshold of 1
let sig = ak.aggregate(&gd, F::from(1), &partials, weights, b"hello").unwrap();
// Verify the aggregated signature
let result = sig.verify(&vk, b"hello").unwrap();
assert!(result);
hinTS uses several cryptographic primitives:
The security of hinTS is proven in the Algebraic Group Model and relies on the q-Decisional Diffie-Hellman Inversion assumption.
Performance metrics on a standard machine: