initial commit
Some checks failed
CI / lint (push) Successful in 1m37s
CI / test-python (push) Successful in 1m49s
CI / test-zig (push) Successful in 1m39s
CI / test-wasm (push) Successful in 1m54s
CI / test (push) Successful in 14m44s
CI / miri (push) Successful in 14m18s
CI / build (push) Successful in 1m9s
CI / fuzz-regression (push) Successful in 9m9s
CI / publish (push) Failing after 1m10s
CI / publish-python (push) Failing after 1m46s
CI / publish-wasm (push) Has been cancelled

Signed-off-by: Kamal Tufekcic <kamal@lo.sh>
This commit is contained in:
Kamal Tufekcic 2026-04-02 23:48:10 +03:00
commit 1d99048c95
No known key found for this signature in database
165830 changed files with 79062 additions and 0 deletions

View file

@ -0,0 +1,37 @@
#![no_main]
use libfuzzer_sys::fuzz_target;
use soliton::identity::{generate_identity, hybrid_sign, hybrid_verify, GeneratedIdentity, IdentityPublicKey, IdentitySecretKey};
use std::sync::LazyLock;
struct SignerKeys {
pk: IdentityPublicKey,
sk: IdentitySecretKey,
}
// Fixed signer — keygen is expensive, amortise across corpus runs.
static SIGNER: LazyLock<SignerKeys> = LazyLock::new(|| {
let GeneratedIdentity { public_key: pk, secret_key: sk, .. } = generate_identity().unwrap();
SignerKeys { pk, sk }
});
fuzz_target!(|data: &[u8]| {
if data.is_empty() {
return;
}
// Property 1: sign(msg) → verify(msg, sig) must always succeed.
let Ok(sig) = hybrid_sign(&SIGNER.sk, data) else {
panic!("hybrid_sign failed on a valid key");
};
if hybrid_verify(&SIGNER.pk, data, &sig).is_err() {
panic!("hybrid_verify rejected a freshly-signed message");
}
// Property 2: verify(tampered_msg, sig) must always fail.
// Flip the LSB of the first byte — always changes the message content.
let mut tampered = data.to_vec();
tampered[0] ^= 0x01;
if hybrid_verify(&SIGNER.pk, &tampered, &sig).is_ok() {
panic!("hybrid_verify accepted a message that differs by exactly one bit");
}
});