diff --git a/Cargo.lock b/Cargo.lock index 780f07f..e945dc7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -570,7 +570,7 @@ dependencies = [ ] [[package]] -name = "willow-data-model-fuzz" +name = "willow-fuzz" version = "0.0.0" dependencies = [ "arbitrary", diff --git a/data-model/src/encoding/compact_width.rs b/data-model/src/encoding/compact_width.rs index 2018bca..0a2f331 100644 --- a/data-model/src/encoding/compact_width.rs +++ b/data-model/src/encoding/compact_width.rs @@ -117,8 +117,8 @@ pub mod encoding { use crate::encoding::unsigned_int::{U16BE, U32BE, U64BE, U8BE}; - #[syncify_replace(use crate::encoding::parameters_sync::{Decodable, };)] - use crate::encoding::parameters::Decodable; + #[syncify_replace(use crate::encoding::sync::{Decodable};)] + use crate::encoding::Decodable; /// Encode a `u64` integer as a `compact_width(value)`-byte big-endian integer, and consume that with a [`BulkConsumer`]. pub async fn encode_compact_width_be>( diff --git a/data-model/src/encoding/mod.rs b/data-model/src/encoding/mod.rs index 2b90352..d67a710 100644 --- a/data-model/src/encoding/mod.rs +++ b/data-model/src/encoding/mod.rs @@ -1,15 +1,32 @@ -pub mod bytes; -pub mod compact_width; -pub mod error; -pub mod parameters; -pub mod parameters_sync; -pub mod relativity; +mod bytes; +mod compact_width; +mod error; +mod max_power; +mod traits_sync; +mod unsigned_int; + +pub use bytes::encoding::produce_byte; +pub use bytes::is_bitflagged; + +pub use compact_width::encoding::*; +pub use compact_width::CompactWidth; + +pub use error::*; + +mod traits; +pub use traits::*; + +mod relativity; + pub(crate) mod shared_buffers; -pub mod unsigned_int; -pub mod max_power; -pub mod max_power_sync { - use super::max_power; - pub use max_power::encoding_sync::*; - pub use max_power::max_power; +pub use unsigned_int::*; + +pub use max_power::{decode_max_power, encode_max_power, max_power}; + +pub mod sync { + pub use super::bytes::encoding_sync::produce_byte; + pub use super::compact_width::encoding_sync::*; + pub use super::max_power::encoding_sync::*; + pub use super::traits_sync::*; } diff --git a/data-model/src/encoding/relativity.rs b/data-model/src/encoding/relativity.rs index 7d8fd28..eaaeb0c 100644 --- a/data-model/src/encoding/relativity.rs +++ b/data-model/src/encoding/relativity.rs @@ -8,10 +8,10 @@ pub(super) mod encoding { #[syncify_replace(use ufotofu::sync::{BulkConsumer, BulkProducer};)] use ufotofu::local_nb::{BulkConsumer, BulkProducer}; - #[syncify_replace(use crate::encoding::parameters_sync::{Encodable, Decodable, RelativeDecodable, RelativeEncodable};)] - use crate::encoding::parameters::{Decodable, Encodable, RelativeDecodable, RelativeEncodable}; + #[syncify_replace(use crate::encoding::sync::{Encodable, Decodable, RelativeDecodable, RelativeEncodable};)] + use crate::encoding::{Decodable, Encodable, RelativeDecodable, RelativeEncodable}; - #[syncify_replace(use crate::encoding::max_power_sync::{decode_max_power, encode_max_power};)] + #[syncify_replace(use crate::encoding::sync::{decode_max_power, encode_max_power};)] use crate::encoding::max_power::{decode_max_power, encode_max_power}; #[syncify_replace(use crate::encoding::compact_width::encoding_sync::{ decode_compact_width_be, encode_compact_width_be};)] @@ -30,11 +30,7 @@ pub(super) mod encoding { shared_buffers::ScratchSpacePathDecoding, }, entry::Entry, - grouping::{ - area::{Area, AreaSubspace}, - range::{Range, RangeEnd}, - range_3d::Range3d, - }, + grouping::{Area, AreaSubspace, Range, Range3d, RangeEnd}, parameters::{NamespaceId, PayloadDigest, SubspaceId}, path::Path, }; diff --git a/data-model/src/encoding/parameters.rs b/data-model/src/encoding/traits.rs similarity index 100% rename from data-model/src/encoding/parameters.rs rename to data-model/src/encoding/traits.rs diff --git a/data-model/src/encoding/parameters_sync.rs b/data-model/src/encoding/traits_sync.rs similarity index 100% rename from data-model/src/encoding/parameters_sync.rs rename to data-model/src/encoding/traits_sync.rs diff --git a/data-model/src/encoding/unsigned_int.rs b/data-model/src/encoding/unsigned_int.rs index e55ad1b..2e8ea1f 100644 --- a/data-model/src/encoding/unsigned_int.rs +++ b/data-model/src/encoding/unsigned_int.rs @@ -76,8 +76,8 @@ mod encoding { #[syncify_replace(use ufotofu::sync::{BulkConsumer, BulkProducer};)] use ufotofu::local_nb::{BulkConsumer, BulkProducer}; - #[syncify_replace(use crate::encoding::parameters_sync::{Decodable, Encodable};)] - use crate::encoding::parameters::{Decodable, Encodable}; + #[syncify_replace(use crate::encoding::sync::{Decodable, Encodable};)] + use crate::encoding::{Decodable, Encodable}; impl Encodable for U8BE { async fn encode(&self, consumer: &mut Consumer) -> Result<(), Consumer::Error> diff --git a/data-model/src/entry.rs b/data-model/src/entry.rs index fe6eed6..c94cbb2 100644 --- a/data-model/src/entry.rs +++ b/data-model/src/entry.rs @@ -4,7 +4,7 @@ use arbitrary::size_hint::and_all; use arbitrary::Arbitrary; use crate::{ - encoding::{error::DecodeError, unsigned_int::U64BE}, + encoding::{DecodeError, U64BE}, parameters::{IsAuthorisedWrite, NamespaceId, PayloadDigest, SubspaceId}, path::Path, }; @@ -121,8 +121,8 @@ mod encoding { #[syncify_replace(use ufotofu::sync::{BulkConsumer, BulkProducer};)] use ufotofu::local_nb::{BulkConsumer, BulkProducer}; - #[syncify_replace(use crate::encoding::parameters_sync::{Decodable, Encodable};)] - use crate::encoding::parameters::{Decodable, Encodable}; + #[syncify_replace(use crate::encoding::sync::{Decodable, Encodable};)] + use crate::encoding::{Decodable, Encodable}; impl Encodable for Entry diff --git a/data-model/src/grouping/mod.rs b/data-model/src/grouping/mod.rs index d2b3e8c..d0aebc7 100644 --- a/data-model/src/grouping/mod.rs +++ b/data-model/src/grouping/mod.rs @@ -1,4 +1,8 @@ -pub mod area; -pub mod area_of_interest; -pub mod range; -pub mod range_3d; +mod area; +pub use area::*; +mod area_of_interest; +pub use area_of_interest::*; +mod range; +pub use range::*; +mod range_3d; +pub use range_3d::*; diff --git a/data-model/src/lib.rs b/data-model/src/lib.rs index c665034..ddc8ce0 100644 --- a/data-model/src/lib.rs +++ b/data-model/src/lib.rs @@ -1,3 +1,5 @@ +//! Allo! + #![feature( new_uninit, async_fn_traits, @@ -8,7 +10,12 @@ )] pub mod encoding; -pub mod entry; +mod entry; +pub use entry::*; pub mod grouping; -pub mod parameters; -pub mod path; + +mod parameters; +pub use parameters::*; + +mod path; +pub use path::*; diff --git a/data-model/src/path.rs b/data-model/src/path.rs index 8a019e0..4707103 100644 --- a/data-model/src/path.rs +++ b/data-model/src/path.rs @@ -787,16 +787,16 @@ use syncify::syncify_replace; mod encoding { use super::*; - use crate::encoding::{error::DecodeError, shared_buffers::ScratchSpacePathDecoding}; + use crate::encoding::{shared_buffers::ScratchSpacePathDecoding, DecodeError}; #[syncify_replace(use ufotofu::sync::{BulkConsumer, BulkProducer};)] use ufotofu::local_nb::{BulkConsumer, BulkProducer}; - #[syncify_replace(use crate::encoding::parameters_sync::{Decodable, Encodable};)] - use crate::encoding::parameters::{Decodable, Encodable}; + #[syncify_replace(use crate::encoding::sync::{Decodable, Encodable};)] + use crate::encoding::{Decodable, Encodable}; - #[syncify_replace(use crate::encoding::max_power_sync::{decode_max_power, encode_max_power};)] - use crate::encoding::max_power::{decode_max_power, encode_max_power}; + #[syncify_replace(use crate::encoding::sync::{decode_max_power, encode_max_power};)] + use crate::encoding::{decode_max_power, encode_max_power}; impl Encodable for Path { async fn encode(&self, consumer: &mut C) -> Result<(), C::Error> @@ -935,7 +935,7 @@ impl<'a, const MCL: usize, const MCC: usize, const MPL: usize> Arbitrary<'a> /// Like core::iter::Chain, but implements ExactSizeIter if both components implement it. Panics if the resulting length overflows. /// /// Code liberally copy-pasted from the standard library. -pub struct ExactLengthChain { +struct ExactLengthChain { a: Option, b: Option, } diff --git a/earthstar/src/cinn25519.rs b/earthstar/src/cinn25519.rs index 0acc49b..be3fa3a 100644 --- a/earthstar/src/cinn25519.rs +++ b/earthstar/src/cinn25519.rs @@ -4,10 +4,7 @@ use arbitrary::{ }; use either::Either; use ufotofu::local_nb::{BulkConsumer, BulkProducer}; -use willow_data_model::encoding::{ - error::DecodeError, - parameters::{Decodable, Encodable}, -}; +use willow_data_model::encoding::{Decodable, DecodeError, Encodable}; #[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord)] pub struct Shortname(pub Vec); diff --git a/earthstar/src/identity_id.rs b/earthstar/src/identity_id.rs index 7711eba..48d5550 100644 --- a/earthstar/src/identity_id.rs +++ b/earthstar/src/identity_id.rs @@ -1,11 +1,8 @@ use arbitrary::Arbitrary; use ufotofu::local_nb::{BulkConsumer, BulkProducer}; use willow_data_model::{ - encoding::{ - error::DecodeError, - parameters::{Decodable, Encodable}, - }, - parameters::SubspaceId, + encoding::{Decodable, DecodeError, Encodable}, + SubspaceId, }; use crate::cinn25519::{Cinn25519PublicKey, Shortname}; diff --git a/earthstar/src/namespace_id.rs b/earthstar/src/namespace_id.rs index 6a5aa61..b90c688 100644 --- a/earthstar/src/namespace_id.rs +++ b/earthstar/src/namespace_id.rs @@ -1,11 +1,8 @@ use arbitrary::Arbitrary; use ufotofu::local_nb::{BulkConsumer, BulkProducer}; use willow_data_model::{ - encoding::{ - error::DecodeError, - parameters::{Decodable, Encodable}, - }, - parameters::NamespaceId, + encoding::{Decodable, DecodeError, Encodable}, + NamespaceId, }; use crate::cinn25519::{Cinn25519PublicKey, Shortname}; diff --git a/fuzz/Cargo.toml b/fuzz/Cargo.toml index e7f7222..7e9ab60 100644 --- a/fuzz/Cargo.toml +++ b/fuzz/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "willow-data-model-fuzz" +name = "willow-fuzz" version = "0.0.0" publish = false edition = "2021" diff --git a/fuzz/fuzz_targets/area_rel_area_encoding.rs b/fuzz/fuzz_targets/area_rel_area_encoding.rs index 0718710..8dd1b22 100644 --- a/fuzz/fuzz_targets/area_rel_area_encoding.rs +++ b/fuzz/fuzz_targets/area_rel_area_encoding.rs @@ -3,8 +3,8 @@ use earthstar::identity_id::IdentityIdentifier as IdentityId; use libfuzzer_sys::fuzz_target; use ufotofu::local_nb::consumer::TestConsumer; -use willow_data_model::grouping::area::Area; -use willow_data_model_fuzz::encode::relative_encoding_roundtrip; +use willow_data_model::grouping::Area; +use willow_fuzz::encode::relative_encoding_roundtrip; fuzz_target!(|data: ( Area<16, 16, 16, IdentityId>, diff --git a/fuzz/fuzz_targets/area_rel_area_encoding_random.rs b/fuzz/fuzz_targets/area_rel_area_encoding_random.rs index 9f632c8..b80a0a1 100644 --- a/fuzz/fuzz_targets/area_rel_area_encoding_random.rs +++ b/fuzz/fuzz_targets/area_rel_area_encoding_random.rs @@ -2,8 +2,8 @@ use earthstar::identity_id::IdentityIdentifier as IdentityId; use libfuzzer_sys::fuzz_target; -use willow_data_model::grouping::area::Area; -use willow_data_model_fuzz::encode::relative_encoding_random_less_strict; +use willow_data_model::grouping::Area; +use willow_fuzz::encode::relative_encoding_random_less_strict; fuzz_target!(|data: (&[u8], Area<16, 16, 16, IdentityId>)| { // fuzzed code goes here diff --git a/fuzz/fuzz_targets/entry_encoding.rs b/fuzz/fuzz_targets/entry_encoding.rs index 4043c7a..e08bfda 100644 --- a/fuzz/fuzz_targets/entry_encoding.rs +++ b/fuzz/fuzz_targets/entry_encoding.rs @@ -4,9 +4,9 @@ use earthstar::identity_id::IdentityIdentifier as IdentityId; use earthstar::namespace_id::NamespaceIdentifier as EsNamespaceId; use libfuzzer_sys::fuzz_target; use ufotofu::local_nb::consumer::TestConsumer; -use willow_data_model::entry::Entry; -use willow_data_model_fuzz::encode::encoding_roundtrip; -use willow_data_model_fuzz::placeholder_params::FakePayloadDigest; +use willow_data_model::Entry; +use willow_fuzz::encode::encoding_roundtrip; +use willow_fuzz::placeholder_params::FakePayloadDigest; fuzz_target!(|data: ( Entry<3, 3, 3, EsNamespaceId, IdentityId, FakePayloadDigest>, diff --git a/fuzz/fuzz_targets/entry_encoding_random.rs b/fuzz/fuzz_targets/entry_encoding_random.rs index dc2cedf..01fcd9b 100644 --- a/fuzz/fuzz_targets/entry_encoding_random.rs +++ b/fuzz/fuzz_targets/entry_encoding_random.rs @@ -3,10 +3,10 @@ use earthstar::identity_id::IdentityIdentifier as IdentityId; use earthstar::namespace_id::NamespaceIdentifier as EsNamespaceId; -use willow_data_model::entry::Entry; +use willow_data_model::Entry; use libfuzzer_sys::fuzz_target; -use willow_data_model_fuzz::{encode::encoding_random, placeholder_params::FakePayloadDigest}; +use willow_fuzz::{encode::encoding_random, placeholder_params::FakePayloadDigest}; fuzz_target!(|data: &[u8]| { smol::block_on(async { diff --git a/fuzz/fuzz_targets/entry_rel_entry_encoding.rs b/fuzz/fuzz_targets/entry_rel_entry_encoding.rs index e52377e..1a084cd 100644 --- a/fuzz/fuzz_targets/entry_rel_entry_encoding.rs +++ b/fuzz/fuzz_targets/entry_rel_entry_encoding.rs @@ -4,9 +4,9 @@ use earthstar::identity_id::IdentityIdentifier as IdentityId; use earthstar::namespace_id::NamespaceIdentifier as EsNamespaceId; use libfuzzer_sys::fuzz_target; use ufotofu::local_nb::consumer::TestConsumer; -use willow_data_model::entry::Entry; -use willow_data_model_fuzz::encode::relative_encoding_roundtrip; -use willow_data_model_fuzz::placeholder_params::FakePayloadDigest; +use willow_data_model::Entry; +use willow_fuzz::encode::relative_encoding_roundtrip; +use willow_fuzz::placeholder_params::FakePayloadDigest; fuzz_target!(|data: ( Entry<16, 16, 16, EsNamespaceId, IdentityId, FakePayloadDigest>, diff --git a/fuzz/fuzz_targets/entry_rel_entry_encoding_random.rs b/fuzz/fuzz_targets/entry_rel_entry_encoding_random.rs index a905b99..9e2cc21 100644 --- a/fuzz/fuzz_targets/entry_rel_entry_encoding_random.rs +++ b/fuzz/fuzz_targets/entry_rel_entry_encoding_random.rs @@ -3,9 +3,9 @@ use earthstar::identity_id::IdentityIdentifier as IdentityId; use earthstar::namespace_id::NamespaceIdentifier as EsNamespaceId; use libfuzzer_sys::fuzz_target; -use willow_data_model::entry::Entry; -use willow_data_model_fuzz::encode::relative_encoding_random_less_strict; -use willow_data_model_fuzz::placeholder_params::FakePayloadDigest; +use willow_data_model::Entry; +use willow_fuzz::encode::relative_encoding_random_less_strict; +use willow_fuzz::placeholder_params::FakePayloadDigest; fuzz_target!(|data: ( &[u8], diff --git a/fuzz/fuzz_targets/entry_rel_namespace_area_encoding.rs b/fuzz/fuzz_targets/entry_rel_namespace_area_encoding.rs index 596b3d9..d2def9b 100644 --- a/fuzz/fuzz_targets/entry_rel_namespace_area_encoding.rs +++ b/fuzz/fuzz_targets/entry_rel_namespace_area_encoding.rs @@ -4,10 +4,10 @@ use earthstar::identity_id::IdentityIdentifier as IdentityId; use earthstar::namespace_id::NamespaceIdentifier as EsNamespaceId; use libfuzzer_sys::fuzz_target; use ufotofu::local_nb::consumer::TestConsumer; -use willow_data_model::entry::Entry; -use willow_data_model::grouping::area::Area; -use willow_data_model_fuzz::encode::relative_encoding_roundtrip; -use willow_data_model_fuzz::placeholder_params::FakePayloadDigest; +use willow_data_model::grouping::Area; +use willow_data_model::Entry; +use willow_fuzz::encode::relative_encoding_roundtrip; +use willow_fuzz::placeholder_params::FakePayloadDigest; fuzz_target!(|data: ( Entry<16, 16, 16, EsNamespaceId, IdentityId, FakePayloadDigest>, diff --git a/fuzz/fuzz_targets/entry_rel_namespace_area_encoding_random.rs b/fuzz/fuzz_targets/entry_rel_namespace_area_encoding_random.rs index 36381ec..7158f88 100644 --- a/fuzz/fuzz_targets/entry_rel_namespace_area_encoding_random.rs +++ b/fuzz/fuzz_targets/entry_rel_namespace_area_encoding_random.rs @@ -3,10 +3,10 @@ use earthstar::identity_id::IdentityIdentifier as IdentityId; use earthstar::namespace_id::NamespaceIdentifier as EsNamespaceId; use libfuzzer_sys::fuzz_target; -use willow_data_model::entry::Entry; -use willow_data_model::grouping::area::Area; -use willow_data_model_fuzz::encode::relative_encoding_random_less_strict; -use willow_data_model_fuzz::placeholder_params::FakePayloadDigest; +use willow_data_model::grouping::Area; +use willow_data_model::Entry; +use willow_fuzz::encode::relative_encoding_random_less_strict; +use willow_fuzz::placeholder_params::FakePayloadDigest; fuzz_target!( |data: (&[u8], (EsNamespaceId, Area<16, 16, 16, IdentityId>))| { diff --git a/fuzz/fuzz_targets/entry_rel_namespace_range_encoding.rs b/fuzz/fuzz_targets/entry_rel_namespace_range_encoding.rs index 9de40fe..b478c7f 100644 --- a/fuzz/fuzz_targets/entry_rel_namespace_range_encoding.rs +++ b/fuzz/fuzz_targets/entry_rel_namespace_range_encoding.rs @@ -4,10 +4,10 @@ use earthstar::identity_id::IdentityIdentifier as IdentityId; use earthstar::namespace_id::NamespaceIdentifier as EsNamespaceId; use libfuzzer_sys::fuzz_target; use ufotofu::local_nb::consumer::TestConsumer; -use willow_data_model::entry::Entry; -use willow_data_model::grouping::range_3d::Range3d; -use willow_data_model_fuzz::encode::relative_encoding_roundtrip; -use willow_data_model_fuzz::placeholder_params::FakePayloadDigest; +use willow_data_model::grouping::Range3d; +use willow_data_model::Entry; +use willow_fuzz::encode::relative_encoding_roundtrip; +use willow_fuzz::placeholder_params::FakePayloadDigest; fuzz_target!(|data: ( Entry<16, 16, 16, EsNamespaceId, IdentityId, FakePayloadDigest>, diff --git a/fuzz/fuzz_targets/entry_rel_namespace_range_encoding_random.rs b/fuzz/fuzz_targets/entry_rel_namespace_range_encoding_random.rs index 1801a81..45e1626 100644 --- a/fuzz/fuzz_targets/entry_rel_namespace_range_encoding_random.rs +++ b/fuzz/fuzz_targets/entry_rel_namespace_range_encoding_random.rs @@ -3,10 +3,10 @@ use earthstar::identity_id::IdentityIdentifier as IdentityId; use earthstar::namespace_id::NamespaceIdentifier as EsNamespaceId; use libfuzzer_sys::fuzz_target; -use willow_data_model::entry::Entry; -use willow_data_model::grouping::range_3d::Range3d; -use willow_data_model_fuzz::encode::relative_encoding_random_less_strict; -use willow_data_model_fuzz::placeholder_params::FakePayloadDigest; +use willow_data_model::grouping::Range3d; +use willow_data_model::Entry; +use willow_fuzz::encode::relative_encoding_random_less_strict; +use willow_fuzz::placeholder_params::FakePayloadDigest; fuzz_target!( |data: (&[u8], (EsNamespaceId, Range3d<16, 16, 16, IdentityId>))| { diff --git a/fuzz/fuzz_targets/mc_capability_append_delegation.rs b/fuzz/fuzz_targets/mc_capability_append_delegation.rs index 1d2402a..3be9a1b 100644 --- a/fuzz/fuzz_targets/mc_capability_append_delegation.rs +++ b/fuzz/fuzz_targets/mc_capability_append_delegation.rs @@ -1,8 +1,8 @@ #![no_main] use libfuzzer_sys::fuzz_target; -use meadowcap::{mc_capability::McCapability, Delegation, InvalidDelegationError}; -use willow_data_model_fuzz::silly_sigs::{SillyPublicKey, SillySig}; +use meadowcap::{Delegation, InvalidDelegationError, McCapability}; +use willow_fuzz::silly_sigs::{SillyPublicKey, SillySig}; fuzz_target!(|data: ( Delegation<16, 16, 16, SillyPublicKey, SillySig>, diff --git a/fuzz/fuzz_targets/mc_capability_delegation.rs b/fuzz/fuzz_targets/mc_capability_delegation.rs index 025d6ce..57e274f 100644 --- a/fuzz/fuzz_targets/mc_capability_delegation.rs +++ b/fuzz/fuzz_targets/mc_capability_delegation.rs @@ -1,9 +1,9 @@ #![no_main] use libfuzzer_sys::fuzz_target; -use meadowcap::{mc_capability::McCapability, FailedDelegationError}; -use willow_data_model::grouping::area::Area; -use willow_data_model_fuzz::silly_sigs::{SillyPublicKey, SillySecret, SillySig}; +use meadowcap::{FailedDelegationError, McCapability}; +use willow_data_model::grouping::Area; +use willow_fuzz::silly_sigs::{SillyPublicKey, SillySecret, SillySig}; fuzz_target!(|data: ( SillySecret, diff --git a/fuzz/fuzz_targets/mc_capability_rel_area_encoding.rs b/fuzz/fuzz_targets/mc_capability_rel_area_encoding.rs index e4cc38b..63fe3f2 100644 --- a/fuzz/fuzz_targets/mc_capability_rel_area_encoding.rs +++ b/fuzz/fuzz_targets/mc_capability_rel_area_encoding.rs @@ -1,11 +1,11 @@ #![no_main] use libfuzzer_sys::fuzz_target; -use meadowcap::mc_capability::McCapability; +use meadowcap::McCapability; use ufotofu::local_nb::consumer::TestConsumer; -use willow_data_model::grouping::area::Area; -use willow_data_model_fuzz::encode::relative_encoding_roundtrip; -use willow_data_model_fuzz::silly_sigs::{SillyPublicKey, SillySig}; +use willow_data_model::grouping::Area; +use willow_fuzz::encode::relative_encoding_roundtrip; +use willow_fuzz::silly_sigs::{SillyPublicKey, SillySig}; fuzz_target!(|data: ( McCapability<3, 3, 3, SillyPublicKey, SillySig, SillyPublicKey, SillySig>, diff --git a/fuzz/fuzz_targets/mc_capability_rel_area_encoding_random.rs b/fuzz/fuzz_targets/mc_capability_rel_area_encoding_random.rs index d923d09..6c4de9c 100644 --- a/fuzz/fuzz_targets/mc_capability_rel_area_encoding_random.rs +++ b/fuzz/fuzz_targets/mc_capability_rel_area_encoding_random.rs @@ -1,10 +1,10 @@ #![no_main] use libfuzzer_sys::fuzz_target; -use meadowcap::mc_capability::McCapability; -use willow_data_model::grouping::area::Area; -use willow_data_model_fuzz::encode::relative_encoding_random; -use willow_data_model_fuzz::silly_sigs::{SillyPublicKey, SillySig}; +use meadowcap::McCapability; +use willow_data_model::grouping::Area; +use willow_fuzz::encode::relative_encoding_random; +use willow_fuzz::silly_sigs::{SillyPublicKey, SillySig}; fuzz_target!(|data: (&[u8], Area<3, 3, 3, SillyPublicKey>,)| { let (random_bytes, out) = data; diff --git a/fuzz/fuzz_targets/mc_is_authorised_write.rs b/fuzz/fuzz_targets/mc_is_authorised_write.rs index 015b3b6..cd74624 100644 --- a/fuzz/fuzz_targets/mc_is_authorised_write.rs +++ b/fuzz/fuzz_targets/mc_is_authorised_write.rs @@ -1,13 +1,13 @@ #![no_main] use libfuzzer_sys::fuzz_target; -use meadowcap::{mc_authorisation_token::McAuthorisationToken, AccessMode}; +use meadowcap::{AccessMode, McAuthorisationToken}; use signature::Signer; use ufotofu::sync::consumer::IntoVec; -use willow_data_model::encoding::parameters_sync::Encodable; -use willow_data_model::entry::Entry; -use willow_data_model::parameters::IsAuthorisedWrite; -use willow_data_model_fuzz::{ +use willow_data_model::encoding::sync::Encodable; +use willow_data_model::Entry; +use willow_data_model::IsAuthorisedWrite; +use willow_fuzz::{ placeholder_params::FakePayloadDigest, silly_sigs::{SillyPublicKey, SillySig}, }; diff --git a/fuzz/fuzz_targets/mc_subspace_capability_append_delegation.rs b/fuzz/fuzz_targets/mc_subspace_capability_append_delegation.rs index 5fff192..390b9c5 100644 --- a/fuzz/fuzz_targets/mc_subspace_capability_append_delegation.rs +++ b/fuzz/fuzz_targets/mc_subspace_capability_append_delegation.rs @@ -1,11 +1,11 @@ #![no_main] use libfuzzer_sys::fuzz_target; -use meadowcap::subspace_capability::McSubspaceCapability; -use willow_data_model_fuzz::silly_sigs::{SillyPublicKey, SillySig}; +use meadowcap::{McSubspaceCapability, SubspaceDelegation}; +use willow_fuzz::silly_sigs::{SillyPublicKey, SillySig}; fuzz_target!(|data: ( - (SillyPublicKey, SillySig), + SubspaceDelegation, McSubspaceCapability, Vec )| { @@ -22,7 +22,8 @@ fuzz_target!(|data: ( last_receiver = delegee; } - let (delegation_user, delegation_sig) = delegation.clone(); + let delegation_user = delegation.user().clone(); + let delegation_sig = delegation.signature().clone(); let actual_receiver_secret = mut_cap.receiver().corresponding_secret_key(); @@ -52,7 +53,7 @@ fuzz_target!(|data: ( match expected_cap { Ok(cap) => { let valid_delegation = cap.delegations().last().unwrap(); - assert!(valid_delegation.1 != delegation_sig); + assert!(valid_delegation.signature() != &delegation_sig); } Err(_) => panic!("The expected cap should have been fine..."), } diff --git a/fuzz/fuzz_targets/mc_subspace_capability_delegation.rs b/fuzz/fuzz_targets/mc_subspace_capability_delegation.rs index 593e807..c62db68 100644 --- a/fuzz/fuzz_targets/mc_subspace_capability_delegation.rs +++ b/fuzz/fuzz_targets/mc_subspace_capability_delegation.rs @@ -1,8 +1,8 @@ #![no_main] use libfuzzer_sys::fuzz_target; -use meadowcap::subspace_capability::McSubspaceCapability; -use willow_data_model_fuzz::silly_sigs::{SillyPublicKey, SillySecret, SillySig}; +use meadowcap::McSubspaceCapability; +use willow_fuzz::silly_sigs::{SillyPublicKey, SillySecret, SillySig}; fuzz_target!(|data: ( SillySecret, diff --git a/fuzz/fuzz_targets/mc_subspace_capability_encoding.rs b/fuzz/fuzz_targets/mc_subspace_capability_encoding.rs index 734a67d..4db3f7d 100644 --- a/fuzz/fuzz_targets/mc_subspace_capability_encoding.rs +++ b/fuzz/fuzz_targets/mc_subspace_capability_encoding.rs @@ -1,10 +1,10 @@ #![no_main] use libfuzzer_sys::fuzz_target; -use meadowcap::subspace_capability::McSubspaceCapability; +use meadowcap::McSubspaceCapability; use ufotofu::local_nb::consumer::TestConsumer; -use willow_data_model_fuzz::encode::encoding_roundtrip; -use willow_data_model_fuzz::silly_sigs::{SillyPublicKey, SillySig}; +use willow_fuzz::encode::encoding_roundtrip; +use willow_fuzz::silly_sigs::{SillyPublicKey, SillySig}; fuzz_target!(|data: ( McSubspaceCapability, diff --git a/fuzz/fuzz_targets/mc_subspace_capability_encoding_random.rs b/fuzz/fuzz_targets/mc_subspace_capability_encoding_random.rs index 8b3458d..e4d2fc9 100644 --- a/fuzz/fuzz_targets/mc_subspace_capability_encoding_random.rs +++ b/fuzz/fuzz_targets/mc_subspace_capability_encoding_random.rs @@ -1,9 +1,9 @@ #![no_main] use libfuzzer_sys::fuzz_target; -use meadowcap::subspace_capability::McSubspaceCapability; -use willow_data_model_fuzz::encode::encoding_random; -use willow_data_model_fuzz::silly_sigs::{SillyPublicKey, SillySig}; +use meadowcap::McSubspaceCapability; +use willow_fuzz::encode::encoding_random; +use willow_fuzz::silly_sigs::{SillyPublicKey, SillySig}; fuzz_target!(|data: &[u8]| { smol::block_on(async { diff --git a/fuzz/fuzz_targets/path.rs b/fuzz/fuzz_targets/path.rs index 0fc1ca9..e66c012 100644 --- a/fuzz/fuzz_targets/path.rs +++ b/fuzz/fuzz_targets/path.rs @@ -2,7 +2,7 @@ use libfuzzer_sys::fuzz_target; // use willow_data_model::path::*; -use willow_data_model_fuzz::path::*; +use willow_fuzz::path::*; fuzz_target!(|data: (CreatePath, CreatePath)| { let (cp1, cp2) = data; diff --git a/fuzz/fuzz_targets/path2.rs b/fuzz/fuzz_targets/path2.rs index 80cb63a..aade2dc 100644 --- a/fuzz/fuzz_targets/path2.rs +++ b/fuzz/fuzz_targets/path2.rs @@ -2,7 +2,7 @@ use libfuzzer_sys::fuzz_target; // use willow_data_model::path::*; -use willow_data_model_fuzz::path::*; +use willow_fuzz::path::*; fuzz_target!(|data: (CreatePath, CreatePath)| { let (cp1, cp2) = data; diff --git a/fuzz/fuzz_targets/path3.rs b/fuzz/fuzz_targets/path3.rs index d5455f9..3c03aa1 100644 --- a/fuzz/fuzz_targets/path3.rs +++ b/fuzz/fuzz_targets/path3.rs @@ -2,7 +2,7 @@ use libfuzzer_sys::fuzz_target; // use willow_data_model::path::*; -use willow_data_model_fuzz::path::*; +use willow_fuzz::path::*; fuzz_target!(|data: (CreatePath, CreatePath)| { let (cp1, cp2) = data; diff --git a/fuzz/fuzz_targets/path4.rs b/fuzz/fuzz_targets/path4.rs index fe4ab85..9e8ceaa 100644 --- a/fuzz/fuzz_targets/path4.rs +++ b/fuzz/fuzz_targets/path4.rs @@ -2,7 +2,7 @@ use libfuzzer_sys::fuzz_target; // use willow_data_model::path::*; -use willow_data_model_fuzz::path::*; +use willow_fuzz::path::*; fuzz_target!(|data: (CreatePath, CreatePath)| { let (cp1, cp2) = data; diff --git a/fuzz/fuzz_targets/path_encoding.rs b/fuzz/fuzz_targets/path_encoding.rs index 6013aa0..5a5a00c 100644 --- a/fuzz/fuzz_targets/path_encoding.rs +++ b/fuzz/fuzz_targets/path_encoding.rs @@ -2,8 +2,8 @@ use libfuzzer_sys::fuzz_target; use ufotofu::local_nb::consumer::TestConsumer; -use willow_data_model::path::Path; -use willow_data_model_fuzz::encode::encoding_roundtrip; +use willow_data_model::Path; +use willow_fuzz::encode::encoding_roundtrip; const MCL: usize = 300; const MCC: usize = 300; diff --git a/fuzz/fuzz_targets/path_encoding2.rs b/fuzz/fuzz_targets/path_encoding2.rs index 3147686..f81014b 100644 --- a/fuzz/fuzz_targets/path_encoding2.rs +++ b/fuzz/fuzz_targets/path_encoding2.rs @@ -2,8 +2,8 @@ use libfuzzer_sys::fuzz_target; use ufotofu::local_nb::consumer::TestConsumer; -use willow_data_model::path::Path; -use willow_data_model_fuzz::encode::encoding_roundtrip; +use willow_data_model::Path; +use willow_fuzz::encode::encoding_roundtrip; const MCL: usize = 2; const MCC: usize = 3; diff --git a/fuzz/fuzz_targets/path_encoding3.rs b/fuzz/fuzz_targets/path_encoding3.rs index 45ecabf..41dfa9f 100644 --- a/fuzz/fuzz_targets/path_encoding3.rs +++ b/fuzz/fuzz_targets/path_encoding3.rs @@ -2,8 +2,8 @@ use libfuzzer_sys::fuzz_target; use ufotofu::local_nb::consumer::TestConsumer; -use willow_data_model::path::Path; -use willow_data_model_fuzz::encode::encoding_roundtrip; +use willow_data_model::Path; +use willow_fuzz::encode::encoding_roundtrip; const MCL: usize = 4; const MCC: usize = 4; diff --git a/fuzz/fuzz_targets/path_encoding_random.rs b/fuzz/fuzz_targets/path_encoding_random.rs index 40507c5..57359e7 100644 --- a/fuzz/fuzz_targets/path_encoding_random.rs +++ b/fuzz/fuzz_targets/path_encoding_random.rs @@ -1,8 +1,8 @@ #![no_main] use libfuzzer_sys::fuzz_target; -use willow_data_model::path::Path; -use willow_data_model_fuzz::encode::encoding_random; +use willow_data_model::Path; +use willow_fuzz::encode::encoding_random; const MCL: usize = 300; const MCC: usize = 300; diff --git a/fuzz/fuzz_targets/path_encoding_random2.rs b/fuzz/fuzz_targets/path_encoding_random2.rs index b83d37c..19e6700 100644 --- a/fuzz/fuzz_targets/path_encoding_random2.rs +++ b/fuzz/fuzz_targets/path_encoding_random2.rs @@ -1,8 +1,8 @@ #![no_main] use libfuzzer_sys::fuzz_target; -use willow_data_model::path::Path; -use willow_data_model_fuzz::encode::encoding_random; +use willow_data_model::Path; +use willow_fuzz::encode::encoding_random; const MCL: usize = 2; const MCC: usize = 3; diff --git a/fuzz/fuzz_targets/path_encoding_random3.rs b/fuzz/fuzz_targets/path_encoding_random3.rs index cc8f387..0f441f9 100644 --- a/fuzz/fuzz_targets/path_encoding_random3.rs +++ b/fuzz/fuzz_targets/path_encoding_random3.rs @@ -1,8 +1,8 @@ #![no_main] use libfuzzer_sys::fuzz_target; -use willow_data_model::path::Path; -use willow_data_model_fuzz::encode::encoding_random; +use willow_data_model::Path; +use willow_fuzz::encode::encoding_random; const MCL: usize = 4; const MCC: usize = 4; diff --git a/fuzz/fuzz_targets/path_rel_path_encoding.rs b/fuzz/fuzz_targets/path_rel_path_encoding.rs index f4db889..a371b0f 100644 --- a/fuzz/fuzz_targets/path_rel_path_encoding.rs +++ b/fuzz/fuzz_targets/path_rel_path_encoding.rs @@ -3,8 +3,8 @@ use libfuzzer_sys::fuzz_target; use ufotofu::local_nb::consumer::TestConsumer; -use willow_data_model::path::Path; -use willow_data_model_fuzz::encode::relative_encoding_roundtrip; +use willow_data_model::Path; +use willow_fuzz::encode::relative_encoding_roundtrip; const MCL: usize = 300; const MCC: usize = 300; diff --git a/fuzz/fuzz_targets/path_rel_path_encoding2.rs b/fuzz/fuzz_targets/path_rel_path_encoding2.rs index a8fb0ed..d6cdae0 100644 --- a/fuzz/fuzz_targets/path_rel_path_encoding2.rs +++ b/fuzz/fuzz_targets/path_rel_path_encoding2.rs @@ -3,8 +3,8 @@ use libfuzzer_sys::fuzz_target; use ufotofu::local_nb::consumer::TestConsumer; -use willow_data_model::path::Path; -use willow_data_model_fuzz::encode::relative_encoding_roundtrip; +use willow_data_model::Path; +use willow_fuzz::encode::relative_encoding_roundtrip; const MCL: usize = 2; const MCC: usize = 3; diff --git a/fuzz/fuzz_targets/path_rel_path_encoding3.rs b/fuzz/fuzz_targets/path_rel_path_encoding3.rs index 9f53c45..0a31ce5 100644 --- a/fuzz/fuzz_targets/path_rel_path_encoding3.rs +++ b/fuzz/fuzz_targets/path_rel_path_encoding3.rs @@ -3,8 +3,8 @@ use libfuzzer_sys::fuzz_target; use ufotofu::local_nb::consumer::TestConsumer; -use willow_data_model::path::Path; -use willow_data_model_fuzz::encode::relative_encoding_roundtrip; +use willow_data_model::Path; +use willow_fuzz::encode::relative_encoding_roundtrip; const MCL: usize = 4; const MCC: usize = 4; diff --git a/fuzz/fuzz_targets/path_rel_path_encoding_random.rs b/fuzz/fuzz_targets/path_rel_path_encoding_random.rs index cff2c7d..dacb0c1 100644 --- a/fuzz/fuzz_targets/path_rel_path_encoding_random.rs +++ b/fuzz/fuzz_targets/path_rel_path_encoding_random.rs @@ -1,8 +1,8 @@ #![no_main] use libfuzzer_sys::fuzz_target; -use willow_data_model::path::Path; -use willow_data_model_fuzz::encode::relative_encoding_random; +use willow_data_model::Path; +use willow_fuzz::encode::relative_encoding_random; const MCL: usize = 300; const MCC: usize = 300; diff --git a/fuzz/fuzz_targets/path_rel_path_encoding_random2.rs b/fuzz/fuzz_targets/path_rel_path_encoding_random2.rs index 1531fe8..92cc517 100644 --- a/fuzz/fuzz_targets/path_rel_path_encoding_random2.rs +++ b/fuzz/fuzz_targets/path_rel_path_encoding_random2.rs @@ -1,8 +1,8 @@ #![no_main] use libfuzzer_sys::fuzz_target; -use willow_data_model::path::Path; -use willow_data_model_fuzz::encode::relative_encoding_random; +use willow_data_model::Path; +use willow_fuzz::encode::relative_encoding_random; const MCL: usize = 2; const MCC: usize = 3; diff --git a/fuzz/fuzz_targets/path_rel_path_encoding_random3.rs b/fuzz/fuzz_targets/path_rel_path_encoding_random3.rs index 8423fee..746bb4c 100644 --- a/fuzz/fuzz_targets/path_rel_path_encoding_random3.rs +++ b/fuzz/fuzz_targets/path_rel_path_encoding_random3.rs @@ -1,8 +1,8 @@ #![no_main] use libfuzzer_sys::fuzz_target; -use willow_data_model::path::Path; -use willow_data_model_fuzz::encode::relative_encoding_random; +use willow_data_model::Path; +use willow_fuzz::encode::relative_encoding_random; const MCL: usize = 4; const MCC: usize = 4; diff --git a/fuzz/fuzz_targets/path_successor.rs b/fuzz/fuzz_targets/path_successor.rs index 0b1758c..974a89d 100644 --- a/fuzz/fuzz_targets/path_successor.rs +++ b/fuzz/fuzz_targets/path_successor.rs @@ -2,7 +2,7 @@ use libfuzzer_sys::fuzz_target; // use willow_data_model::path::*; -use willow_data_model_fuzz::path::*; +use willow_fuzz::path::*; // MCL, MCC, MPL fuzz_target!(|data: (PathRc<2, 3, 3>, PathRc<2, 3, 3>)| { diff --git a/fuzz/fuzz_targets/path_successor_even_more.rs b/fuzz/fuzz_targets/path_successor_even_more.rs index 40bdaa5..c7b583f 100644 --- a/fuzz/fuzz_targets/path_successor_even_more.rs +++ b/fuzz/fuzz_targets/path_successor_even_more.rs @@ -2,7 +2,7 @@ use libfuzzer_sys::fuzz_target; // use willow_data_model::path::*; -use willow_data_model_fuzz::path::*; +use willow_fuzz::path::*; // MCL, MCC, MPL fuzz_target!(|data: (PathRc<4, 4, 16>, PathRc<4, 4, 16>)| { diff --git a/fuzz/fuzz_targets/path_successor_more.rs b/fuzz/fuzz_targets/path_successor_more.rs index 96d97a2..cc9c56e 100644 --- a/fuzz/fuzz_targets/path_successor_more.rs +++ b/fuzz/fuzz_targets/path_successor_more.rs @@ -2,7 +2,7 @@ use libfuzzer_sys::fuzz_target; // use willow_data_model::path::*; -use willow_data_model_fuzz::path::*; +use willow_fuzz::path::*; // MCL, MCC, MPL fuzz_target!(|data: (PathRc<3, 3, 3>, PathRc<3, 3, 3>)| { diff --git a/fuzz/fuzz_targets/range3d_rel_rang3d_encoding_random.rs b/fuzz/fuzz_targets/range3d_rel_rang3d_encoding_random.rs index 5eb99f0..f2f47e2 100644 --- a/fuzz/fuzz_targets/range3d_rel_rang3d_encoding_random.rs +++ b/fuzz/fuzz_targets/range3d_rel_rang3d_encoding_random.rs @@ -2,8 +2,8 @@ use earthstar::identity_id::IdentityIdentifier as IdentityId; use libfuzzer_sys::fuzz_target; -use willow_data_model::grouping::range_3d::Range3d; -use willow_data_model_fuzz::encode::relative_encoding_random_less_strict; +use willow_data_model::grouping::Range3d; +use willow_fuzz::encode::relative_encoding_random_less_strict; fuzz_target!(|data: (&[u8], Range3d<16, 16, 16, IdentityId>)| { // fuzzed code goes here diff --git a/fuzz/fuzz_targets/range3d_rel_range3d_encoding.rs b/fuzz/fuzz_targets/range3d_rel_range3d_encoding.rs index aaf80bd..ecc3a75 100644 --- a/fuzz/fuzz_targets/range3d_rel_range3d_encoding.rs +++ b/fuzz/fuzz_targets/range3d_rel_range3d_encoding.rs @@ -3,8 +3,8 @@ use earthstar::identity_id::IdentityIdentifier as IdentityId; use libfuzzer_sys::fuzz_target; use ufotofu::local_nb::consumer::TestConsumer; -use willow_data_model::grouping::range_3d::Range3d; -use willow_data_model_fuzz::encode::relative_encoding_roundtrip; +use willow_data_model::grouping::Range3d; +use willow_fuzz::encode::relative_encoding_roundtrip; fuzz_target!(|data: ( Range3d<16, 16, 16, IdentityId>, diff --git a/fuzz/fuzz_targets/successor_of_prefix.rs b/fuzz/fuzz_targets/successor_of_prefix.rs index 12a56ac..128f3f0 100644 --- a/fuzz/fuzz_targets/successor_of_prefix.rs +++ b/fuzz/fuzz_targets/successor_of_prefix.rs @@ -2,7 +2,7 @@ use libfuzzer_sys::fuzz_target; // use willow_data_model::path::*; -use willow_data_model_fuzz::path::*; +use willow_fuzz::path::*; // MCL, MCC, MPL fuzz_target!(|data: (PathRc<2, 3, 3>, PathRc<2, 3, 3>)| { diff --git a/fuzz/fuzz_targets/successor_of_prefix_even_more.rs b/fuzz/fuzz_targets/successor_of_prefix_even_more.rs index 4e00ea1..59b2a7a 100644 --- a/fuzz/fuzz_targets/successor_of_prefix_even_more.rs +++ b/fuzz/fuzz_targets/successor_of_prefix_even_more.rs @@ -2,7 +2,7 @@ use libfuzzer_sys::fuzz_target; // use willow_data_model::path::*; -use willow_data_model_fuzz::path::*; +use willow_fuzz::path::*; // MCL, MCC, MPL fuzz_target!(|data: (PathRc<4, 4, 16>, PathRc<4, 4, 16>)| { diff --git a/fuzz/fuzz_targets/successor_of_prefix_more.rs b/fuzz/fuzz_targets/successor_of_prefix_more.rs index 61837d8..9f2d87c 100644 --- a/fuzz/fuzz_targets/successor_of_prefix_more.rs +++ b/fuzz/fuzz_targets/successor_of_prefix_more.rs @@ -2,7 +2,7 @@ use libfuzzer_sys::fuzz_target; // use willow_data_model::path::*; -use willow_data_model_fuzz::path::*; +use willow_fuzz::path::*; // MCL, MCC, MPL fuzz_target!(|data: (PathRc<3, 3, 3>, PathRc<3, 3, 3>)| { diff --git a/fuzz/fuzz_targets/u16be_encoding.rs b/fuzz/fuzz_targets/u16be_encoding.rs index 1413115..cc9194f 100644 --- a/fuzz/fuzz_targets/u16be_encoding.rs +++ b/fuzz/fuzz_targets/u16be_encoding.rs @@ -2,8 +2,8 @@ use libfuzzer_sys::fuzz_target; use ufotofu::local_nb::consumer::TestConsumer; -use willow_data_model::encoding::unsigned_int::U16BE; -use willow_data_model_fuzz::encode::encoding_roundtrip; +use willow_data_model::encoding::U16BE; +use willow_fuzz::encode::encoding_roundtrip; fuzz_target!(|data: (u16, TestConsumer)| { let (n, mut consumer) = data; diff --git a/fuzz/fuzz_targets/u16be_encoding_random.rs b/fuzz/fuzz_targets/u16be_encoding_random.rs index e664001..ebe95e6 100644 --- a/fuzz/fuzz_targets/u16be_encoding_random.rs +++ b/fuzz/fuzz_targets/u16be_encoding_random.rs @@ -1,8 +1,8 @@ #![no_main] use libfuzzer_sys::fuzz_target; -use willow_data_model::encoding::unsigned_int::U16BE; -use willow_data_model_fuzz::encode::encoding_random; +use willow_data_model::encoding::U16BE; +use willow_fuzz::encode::encoding_random; fuzz_target!(|data: &[u8]| { smol::block_on(async { diff --git a/fuzz/fuzz_targets/u32be_encoding.rs b/fuzz/fuzz_targets/u32be_encoding.rs index 1cda4f7..c1d3593 100644 --- a/fuzz/fuzz_targets/u32be_encoding.rs +++ b/fuzz/fuzz_targets/u32be_encoding.rs @@ -2,8 +2,8 @@ use libfuzzer_sys::fuzz_target; use ufotofu::local_nb::consumer::TestConsumer; -use willow_data_model::encoding::unsigned_int::U32BE; -use willow_data_model_fuzz::encode::encoding_roundtrip; +use willow_data_model::encoding::U32BE; +use willow_fuzz::encode::encoding_roundtrip; fuzz_target!(|data: (u32, TestConsumer)| { let (n, mut consumer) = data; diff --git a/fuzz/fuzz_targets/u32be_encoding_random.rs b/fuzz/fuzz_targets/u32be_encoding_random.rs index f0f4924..64cd90a 100644 --- a/fuzz/fuzz_targets/u32be_encoding_random.rs +++ b/fuzz/fuzz_targets/u32be_encoding_random.rs @@ -1,8 +1,8 @@ #![no_main] use libfuzzer_sys::fuzz_target; -use willow_data_model::encoding::unsigned_int::U32BE; -use willow_data_model_fuzz::encode::encoding_random; +use willow_data_model::encoding::U32BE; +use willow_fuzz::encode::encoding_random; fuzz_target!(|data: &[u8]| { smol::block_on(async { diff --git a/fuzz/fuzz_targets/u64be_encoding.rs b/fuzz/fuzz_targets/u64be_encoding.rs index 2a7781b..c499cb8 100644 --- a/fuzz/fuzz_targets/u64be_encoding.rs +++ b/fuzz/fuzz_targets/u64be_encoding.rs @@ -2,8 +2,8 @@ use libfuzzer_sys::fuzz_target; use ufotofu::local_nb::consumer::TestConsumer; -use willow_data_model::encoding::unsigned_int::U64BE; -use willow_data_model_fuzz::encode::encoding_roundtrip; +use willow_data_model::encoding::U64BE; +use willow_fuzz::encode::encoding_roundtrip; fuzz_target!(|data: (u64, TestConsumer)| { let (n, mut consumer) = data; diff --git a/fuzz/fuzz_targets/u64be_encoding_random.rs b/fuzz/fuzz_targets/u64be_encoding_random.rs index 7e8acf4..896a2fb 100644 --- a/fuzz/fuzz_targets/u64be_encoding_random.rs +++ b/fuzz/fuzz_targets/u64be_encoding_random.rs @@ -1,8 +1,8 @@ #![no_main] use libfuzzer_sys::fuzz_target; -use willow_data_model::encoding::unsigned_int::U64BE; -use willow_data_model_fuzz::encode::encoding_random; +use willow_data_model::encoding::U64BE; +use willow_fuzz::encode::encoding_random; fuzz_target!(|data: &[u8]| { smol::block_on(async { diff --git a/fuzz/fuzz_targets/u8be_encoding.rs b/fuzz/fuzz_targets/u8be_encoding.rs index d0b9f03..41a5dfa 100644 --- a/fuzz/fuzz_targets/u8be_encoding.rs +++ b/fuzz/fuzz_targets/u8be_encoding.rs @@ -2,8 +2,8 @@ use libfuzzer_sys::fuzz_target; use ufotofu::local_nb::consumer::TestConsumer; -use willow_data_model::encoding::unsigned_int::U8BE; -use willow_data_model_fuzz::encode::encoding_roundtrip; +use willow_data_model::encoding::U8BE; +use willow_fuzz::encode::encoding_roundtrip; fuzz_target!(|data: (u8, TestConsumer)| { let (n, mut consumer) = data; diff --git a/fuzz/fuzz_targets/u8be_encoding_random.rs b/fuzz/fuzz_targets/u8be_encoding_random.rs index 8082ac1..b563eaa 100644 --- a/fuzz/fuzz_targets/u8be_encoding_random.rs +++ b/fuzz/fuzz_targets/u8be_encoding_random.rs @@ -1,8 +1,8 @@ #![no_main] use libfuzzer_sys::fuzz_target; -use willow_data_model::encoding::unsigned_int::U8BE; -use willow_data_model_fuzz::encode::encoding_random; +use willow_data_model::encoding::U8BE; +use willow_fuzz::encode::encoding_random; fuzz_target!(|data: &[u8]| { smol::block_on(async { diff --git a/fuzz/src/encode.rs b/fuzz/src/encode.rs index 43d3072..a830a0e 100644 --- a/fuzz/src/encode.rs +++ b/fuzz/src/encode.rs @@ -8,8 +8,7 @@ use ufotofu::{ }; use willow_data_model::encoding::{ - error::DecodeError, - parameters::{Decodable, Encodable, RelativeDecodable, RelativeEncodable}, + DecodeError, {Decodable, Encodable, RelativeDecodable, RelativeEncodable}, }; pub async fn encoding_roundtrip(item: T, consumer: &mut TestConsumer) diff --git a/fuzz/src/path.rs b/fuzz/src/path.rs index 42ed29f..2aa8bee 100644 --- a/fuzz/src/path.rs +++ b/fuzz/src/path.rs @@ -2,7 +2,7 @@ use std::hash::{DefaultHasher, Hash, Hasher}; use std::rc::Rc; use libfuzzer_sys::arbitrary::{self, Arbitrary, Error as ArbitraryError, Unstructured}; -use willow_data_model::path::{Component, InvalidPathError, Path}; +use willow_data_model::{Component, InvalidPathError, Path}; /* * A known-good, simple implementation of paths. Used in testing to compare the behaviour of the optimised imlpementation against it. diff --git a/fuzz/src/placeholder_params.rs b/fuzz/src/placeholder_params.rs index 212eef6..6330c2c 100644 --- a/fuzz/src/placeholder_params.rs +++ b/fuzz/src/placeholder_params.rs @@ -1,14 +1,11 @@ use arbitrary::Arbitrary; use ufotofu::local_nb::{BulkConsumer, BulkProducer}; use ufotofu::sync::{BulkConsumer as BulkConsumerSync, BulkProducer as BulkProducerSync}; -use willow_data_model::{ - encoding::{ - error::DecodeError, - parameters::{Decodable, Encodable}, - parameters_sync::{Decodable as DecodableSync, Encodable as EncodableSync}, - }, - parameters::PayloadDigest, +use willow_data_model::encoding::{ + sync::{Decodable as DecodableSync, Encodable as EncodableSync}, + Decodable, DecodeError, Encodable, }; +use willow_data_model::PayloadDigest; #[derive(Arbitrary, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Default)] pub struct FakePayloadDigest([u8; 32]); diff --git a/fuzz/src/silly_sigs.rs b/fuzz/src/silly_sigs.rs index 0f0354d..e2f6aee 100644 --- a/fuzz/src/silly_sigs.rs +++ b/fuzz/src/silly_sigs.rs @@ -1,7 +1,7 @@ use arbitrary::Arbitrary; use meadowcap::IsCommunal; use signature::{Error as SignatureError, Signer, Verifier}; -use willow_data_model::parameters::{NamespaceId, SubspaceId}; +use willow_data_model::{NamespaceId, SubspaceId}; /// A silly, trivial, insecure public key for fuzz testing. #[derive(PartialEq, Eq, Debug, Arbitrary, Clone, Default, PartialOrd, Ord)] @@ -83,12 +83,12 @@ pub mod encoding { #[syncify_replace(use ufotofu::sync::{BulkConsumer, BulkProducer};)] use ufotofu::local_nb::{BulkConsumer, BulkProducer}; - use willow_data_model::encoding::error::DecodeError; - #[syncify_replace(use willow_data_model::encoding::parameters_sync::{Encodable, Decodable};)] - use willow_data_model::encoding::parameters::{Decodable, Encodable}; + use willow_data_model::encoding::DecodeError; + #[syncify_replace(use willow_data_model::encoding::sync::{Encodable, Decodable};)] + use willow_data_model::encoding::{Decodable, Encodable}; - #[syncify_replace(use willow_data_model::encoding::bytes::encoding_sync::produce_byte;)] - use willow_data_model::encoding::bytes::encoding::produce_byte; + #[syncify_replace(use willow_data_model::encoding::sync::produce_byte;)] + use willow_data_model::encoding::produce_byte; impl Encodable for SillyPublicKey { async fn encode(&self, consumer: &mut Consumer) -> Result<(), Consumer::Error> diff --git a/meadowcap/src/communal_capability.rs b/meadowcap/src/communal_capability.rs index 81d903f..b257e01 100644 --- a/meadowcap/src/communal_capability.rs +++ b/meadowcap/src/communal_capability.rs @@ -1,9 +1,9 @@ use signature::{Signer, Verifier}; use ufotofu::{sync::consumer::IntoVec, sync::Consumer}; use willow_data_model::{ - encoding::parameters_sync::{Encodable, RelativeEncodable}, - grouping::area::Area, - parameters::{NamespaceId, SubspaceId}, + encoding::sync::{Encodable, RelativeEncodable}, + grouping::Area, + NamespaceId, SubspaceId, }; use crate::{AccessMode, Delegation, FailedDelegationError, InvalidDelegationError, IsCommunal}; diff --git a/meadowcap/src/lib.rs b/meadowcap/src/lib.rs index ff58021..c12743e 100644 --- a/meadowcap/src/lib.rs +++ b/meadowcap/src/lib.rs @@ -1,4 +1,4 @@ -use willow_data_model::{grouping::area::Area, parameters::SubspaceId}; +use willow_data_model::{grouping::Area, SubspaceId}; /// Maps namespace public keys to booleans, determining whether that namespace of a particular [`willow_data_model::NamespaceId`] is [communal](https://willowprotocol.org/specs/meadowcap/index.html#communal_namespace) or [owned](https://willowprotocol.org/specs/meadowcap/index.html#owned_namespace). pub trait IsCommunal { @@ -136,8 +136,17 @@ pub enum InvalidDelegationError< }, } -pub mod communal_capability; -pub mod mc_authorisation_token; -pub mod mc_capability; -pub mod owned_capability; -pub mod subspace_capability; +mod communal_capability; +pub use communal_capability::*; + +mod mc_authorisation_token; +pub use mc_authorisation_token::*; + +mod mc_capability; +pub use mc_capability::*; + +mod owned_capability; +pub use owned_capability::*; + +mod mc_subspace_capability; +pub use mc_subspace_capability::*; diff --git a/meadowcap/src/mc_authorisation_token.rs b/meadowcap/src/mc_authorisation_token.rs index cb4e3dc..b3de612 100644 --- a/meadowcap/src/mc_authorisation_token.rs +++ b/meadowcap/src/mc_authorisation_token.rs @@ -1,8 +1,7 @@ use signature::Verifier; use ufotofu::sync::consumer::IntoVec; use willow_data_model::{ - encoding::parameters_sync::Encodable, - parameters::{IsAuthorisedWrite, NamespaceId, PayloadDigest, SubspaceId}, + encoding::sync::Encodable, Entry, IsAuthorisedWrite, NamespaceId, PayloadDigest, SubspaceId, }; use crate::{mc_capability::McCapability, AccessMode, IsCommunal}; @@ -67,14 +66,7 @@ where { fn is_authorised_write( &self, - entry: &willow_data_model::entry::Entry< - MCL, - MCC, - MPL, - NamespacePublicKey, - UserPublicKey, - PD, - >, + entry: &Entry, ) -> bool { match self.capability.access_mode() { AccessMode::Read => return false, diff --git a/meadowcap/src/mc_capability.rs b/meadowcap/src/mc_capability.rs index 217c72e..b076ffb 100644 --- a/meadowcap/src/mc_capability.rs +++ b/meadowcap/src/mc_capability.rs @@ -4,10 +4,7 @@ use either::Either; use signature::{Error as SignatureError, Signer, Verifier}; use ufotofu::sync::consumer::IntoVec; use willow_data_model::{ - encoding::parameters_sync::Encodable, - entry::Entry, - grouping::area::Area, - parameters::{NamespaceId, PayloadDigest, SubspaceId}, + encoding::sync::Encodable, grouping::Area, Entry, NamespaceId, PayloadDigest, SubspaceId, }; use crate::{ @@ -295,25 +292,20 @@ pub(super) mod encoding { #[syncify_replace(use ufotofu::sync::{BulkConsumer, BulkProducer};)] use ufotofu::local_nb::{BulkConsumer, BulkProducer}; - #[syncify_replace(use willow_data_model::encoding::parameters_sync::{Encodable, Decodable, RelativeDecodable, RelativeEncodable};)] - use willow_data_model::encoding::parameters::{ - Decodable, Encodable, RelativeDecodable, RelativeEncodable, - }; + #[syncify_replace(use willow_data_model::encoding::sync::{Encodable, Decodable, RelativeDecodable, RelativeEncodable};)] + use willow_data_model::encoding::{Decodable, Encodable, RelativeDecodable, RelativeEncodable}; use willow_data_model::encoding::{ - bytes::is_bitflagged, compact_width::CompactWidth, error::DecodeError, - parameters_sync::Encodable as EncodableSync, + is_bitflagged, sync::Encodable as EncodableSync, CompactWidth, DecodeError, }; - #[syncify_replace(use willow_data_model::encoding::bytes::encoding_sync::produce_byte;)] - use willow_data_model::encoding::bytes::encoding::produce_byte; + #[syncify_replace(use willow_data_model::encoding::sync::produce_byte;)] + use willow_data_model::encoding::produce_byte; #[syncify_replace( - use willow_data_model::encoding::compact_width::encoding_sync::{encode_compact_width_be, decode_compact_width_be}; + use willow_data_model::encoding::sync::{encode_compact_width_be, decode_compact_width_be}; )] - use willow_data_model::encoding::compact_width::encoding::{ - decode_compact_width_be, encode_compact_width_be, - }; + use willow_data_model::encoding::{decode_compact_width_be, encode_compact_width_be}; impl< const MCL: usize, diff --git a/meadowcap/src/subspace_capability.rs b/meadowcap/src/mc_subspace_capability.rs similarity index 85% rename from meadowcap/src/subspace_capability.rs rename to meadowcap/src/mc_subspace_capability.rs index 2b2c635..ffa07fa 100644 --- a/meadowcap/src/subspace_capability.rs +++ b/meadowcap/src/mc_subspace_capability.rs @@ -1,12 +1,43 @@ use signature::{Error as SignatureError, Signer, Verifier}; use ufotofu::sync::{consumer::IntoVec, Consumer}; -use willow_data_model::{ - encoding::parameters_sync::Encodable, - parameters::{NamespaceId, SubspaceId}, -}; +use willow_data_model::encoding::sync::Encodable; +use willow_data_model::NamespaceId; +use willow_data_model::SubspaceId; use crate::IsCommunal; +#[cfg(feature = "dev")] +use arbitrary::{Arbitrary, Error as ArbitraryError}; + +/// A delegation of read access for arbitrary SubspaceIds to a user. +#[derive(Clone, Debug, PartialEq, Eq, Arbitrary)] +pub struct SubspaceDelegation +where + UserPublicKey: SubspaceId, +{ + user: UserPublicKey, + signature: UserSignature, +} + +impl SubspaceDelegation +where + UserPublicKey: SubspaceId, +{ + pub fn new(user: UserPublicKey, signature: UserSignature) -> Self { + Self { user, signature } + } + + /// The user delegated to. + pub fn user(&self) -> &UserPublicKey { + &self.user + } + + /// The signature of the user who created this delegation. + pub fn signature(&self) -> &UserSignature { + &self.signature + } +} + /// A capability that certifies read access to arbitrary [SubspaceIds](https://willowprotocol.org/specs/data-model/index.html#SubspaceId) at some unspecified non-empty [`willow_data_model::Path`]. /// /// [Definition](https://willowprotocol.org/specs/pai/index.html#subspace_capability) @@ -25,7 +56,7 @@ pub struct McSubspaceCapability< namespace_key: NamespacePublicKey, user_key: UserPublicKey, initial_authorisation: NamespaceSignature, - delegations: Vec<(UserPublicKey, UserSignature)>, + delegations: Vec>, } impl @@ -100,7 +131,7 @@ where // We can unwrap here because we know delegations isn't empty. let last_delegation = self.delegations.last().unwrap(); - &last_delegation.0 + last_delegation.user() } /// The [namespace](https://willowprotocol.org/specs/data-model/index.html#namespace) for which this capability grants access. @@ -129,7 +160,7 @@ where let mut new_delegations = self.delegations.clone(); - new_delegations.push((new_user.clone(), signature)); + new_delegations.push(SubspaceDelegation::new(new_user.clone(), signature)); Ok(Self { namespace_key: self.namespace_key.clone(), @@ -142,10 +173,10 @@ where /// Append an existing delegation to an existing capability, or return an error if the delegation is invalid. pub fn append_existing_delegation( &mut self, - delegation: (UserPublicKey, UserSignature), + delegation: SubspaceDelegation, ) -> Result<(), SignatureError> { - let new_user = &delegation.0; - let new_sig = &delegation.1; + let new_user = &delegation.user(); + let new_sig = &delegation.signature(); let handover = self.handover(new_user); @@ -159,7 +190,9 @@ where } /// Return a slice of all [`Delegation`]s made to this capability. - pub fn delegations(&self) -> impl Iterator { + pub fn delegations( + &self, + ) -> impl Iterator> { self.delegations.iter() } @@ -181,7 +214,7 @@ where // We can unwrap here because we know that self.delegations is not empty. let last_delegation = self.delegations.last().unwrap(); - let prev_signature = &last_delegation.1; + let prev_signature = &last_delegation.signature(); // We can safely unwrap all these encodings as IntoVec's error is the never type. prev_signature.encode(&mut consumer).unwrap(); new_user.encode(&mut consumer).unwrap(); @@ -200,23 +233,20 @@ pub(super) mod encoding { #[syncify_replace(use ufotofu::sync::{BulkConsumer, BulkProducer};)] use ufotofu::local_nb::{BulkConsumer, BulkProducer}; - #[syncify_replace(use willow_data_model::encoding::parameters_sync::{Encodable, Decodable};)] - use willow_data_model::encoding::parameters::{Decodable, Encodable}; + #[syncify_replace(use willow_data_model::encoding::sync::{Encodable, Decodable};)] + use willow_data_model::encoding::{Decodable, Encodable}; use willow_data_model::encoding::{ - compact_width::CompactWidth, error::DecodeError, - parameters_sync::Encodable as EncodableSync, + sync::Encodable as EncodableSync, CompactWidth, DecodeError, }; - #[syncify_replace(use willow_data_model::encoding::bytes::encoding_sync::produce_byte;)] - use willow_data_model::encoding::bytes::encoding::produce_byte; + #[syncify_replace(use willow_data_model::encoding::sync::produce_byte;)] + use willow_data_model::encoding::produce_byte; #[syncify_replace( - use willow_data_model::encoding::compact_width::encoding_sync::{encode_compact_width_be, decode_compact_width_be}; + use willow_data_model::encoding::sync::{encode_compact_width_be, decode_compact_width_be}; )] - use willow_data_model::encoding::compact_width::encoding::{ - decode_compact_width_be, encode_compact_width_be, - }; + use willow_data_model::encoding::{decode_compact_width_be, encode_compact_width_be}; impl Encodable for McSubspaceCapability< @@ -263,8 +293,8 @@ pub(super) mod encoding { } for delegation in self.delegations.iter() { - Encodable::encode(&delegation.0, consumer).await?; - Encodable::encode(&delegation.1, consumer).await?; + Encodable::encode(delegation.user(), consumer).await?; + Encodable::encode(delegation.signature(), consumer).await?; } Ok(()) @@ -327,9 +357,10 @@ pub(super) mod encoding { for _ in 0..delegations_to_decode { let user = UserPublicKey::decode(producer).await?; let signature = UserSignature::decode(producer).await?; + let delegation = SubspaceDelegation::new(user, signature); base_cap - .append_existing_delegation((user, signature)) + .append_existing_delegation(delegation) .map_err(|_| DecodeError::InvalidInput)?; } @@ -338,9 +369,6 @@ pub(super) mod encoding { } } -#[cfg(feature = "dev")] -use arbitrary::{Arbitrary, Error as ArbitraryError}; - #[cfg(feature = "dev")] impl<'a, NamespacePublicKey, NamespaceSignature, UserPublicKey, UserSignature> Arbitrary<'a> for McSubspaceCapability diff --git a/meadowcap/src/owned_capability.rs b/meadowcap/src/owned_capability.rs index 1bbcc24..4c0d231 100644 --- a/meadowcap/src/owned_capability.rs +++ b/meadowcap/src/owned_capability.rs @@ -1,10 +1,9 @@ use signature::{Error as SignatureError, Signer, Verifier}; use ufotofu::{sync::consumer::IntoVec, sync::Consumer}; use willow_data_model::{ - encoding::parameters_sync::{Encodable, RelativeEncodable}, - grouping::area::{Area, AreaSubspace}, - parameters::{NamespaceId, SubspaceId}, - path::Path, + encoding::sync::{Encodable, RelativeEncodable}, + grouping::{Area, AreaSubspace}, + NamespaceId, Path, SubspaceId, }; use crate::{AccessMode, Delegation, FailedDelegationError, InvalidDelegationError, IsCommunal};