-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds basic deserialization fuzzing to the library to avoid unexpected panics. Updates documentation. Because this is not part of CI, it should be tested manually. To do so, [install](https://github.com/rust-fuzz/cargo-fuzz) `cargo-fuzz` and run it with the nightly toolchain until you get bored: `cargo +nightly fuzz run proofs` Closes #78.
- Loading branch information
1 parent
5b87644
commit a81b105
Showing
4 changed files
with
50 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
target | ||
corpus | ||
artifacts | ||
coverage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
[package] | ||
name = "tari_bulletproofs_plus_fuzz" | ||
version = "0.0.0" | ||
publish = false | ||
edition = "2018" | ||
|
||
[package.metadata] | ||
cargo-fuzz = true | ||
|
||
[dependencies] | ||
libfuzzer-sys = "0.4" | ||
|
||
[dependencies.tari_bulletproofs_plus] | ||
path = ".." | ||
|
||
[workspace] | ||
members = ["."] | ||
|
||
[profile.release] | ||
debug = 1 | ||
|
||
[[bin]] | ||
name = "proofs" | ||
path = "fuzz_targets/proofs.rs" | ||
test = false | ||
doc = false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// Copyright 2023 The Tari Project | ||
// SPDX-License-Identifier: BSD-3-Clause | ||
|
||
#![no_main] | ||
|
||
use libfuzzer_sys::fuzz_target; | ||
use tari_bulletproofs_plus::ristretto::RistrettoRangeProof; | ||
|
||
// Test basic deserialization and canonical serialization | ||
fuzz_target!(|data: &[u8]| { | ||
// If deserialization succeeds, serialization should be canonical | ||
if let Ok(proof) = RistrettoRangeProof::from_bytes(data) { | ||
assert_eq!(&proof.to_bytes(), data); | ||
} | ||
}); |