pub struct Challenge {
pub sealed: Hash,
pub key: [u8; 32],
pub ranges: Vec<Range>,
pub plain: bool,
}Expand description
What a remover asks a prover to answer of a sealed blob, or of a content’s own bytes.
Fields§
§sealed: HashThe sealed blob’s sealed hash, or for a plain challenge the content’s hash.
key: [u8; 32]The key of the hash, fresh for each challenge.
ranges: Vec<Range>The ranges of the bytes to hash, in order.
plain: boolWhether it asks for the content’s own bytes, as an original holds them, rather than a sealed blob’s.
Implementations§
Source§impl Challenge
impl Challenge
Sourcepub fn random_plain(
content: Hash,
len: u64,
rng: &mut (impl CryptoRng + ?Sized),
) -> Self
pub fn random_plain( content: Hash, len: u64, rng: &mut (impl CryptoRng + ?Sized), ) -> Self
A plain challenge of a content of len bytes, as Challenge::random draws one.
Sourcepub fn is_fair(&self) -> bool
pub fn is_fair(&self) -> bool
Whether a prover reads it: no more than MOST_RANGES ranges, each of 1 to
MOST_RANGE_LEN bytes, none ending past the largest offset; none only for a plain
challenge, of an empty content.
Sourcepub fn answer(
&self,
read: impl FnMut(u64, &mut [u8]) -> Result<()>,
) -> Result<[u8; 32]>
pub fn answer( &self, read: impl FnMut(u64, &mut [u8]) -> Result<()>, ) -> Result<[u8; 32]>
The answer to the challenge, from the bytes as read reads each range, into a buffer
of the range’s length: the BLAKE3 hash, keyed with the challenge’s key, of the context,
which a plain challenge’s differs from, the hash it names, and each range’s offset,
length and bytes.
§Errors
Returns what read returns, as when the blob ends before a range does.