pub struct NsAvidmGf2Scheme;Expand description
Dummy struct for namespaced AvidmGf2 scheme
Implementations§
Source§impl NsAvidmGf2Scheme
impl NsAvidmGf2Scheme
Sourcepub fn setup(
recovery_threshold: usize,
total_weights: usize,
) -> Result<NsAvidmGf2Param, VidError>
pub fn setup( recovery_threshold: usize, total_weights: usize, ) -> Result<NsAvidmGf2Param, VidError>
Setup an instance for AVID-M scheme
Sourcepub fn commit(
param: &NsAvidmGf2Param,
payload: &[u8],
ns_table: impl IntoIterator<Item = Range<usize>>,
) -> Result<(NsAvidmGf2Commit, NsAvidmGf2Common), VidError>
pub fn commit( param: &NsAvidmGf2Param, payload: &[u8], ns_table: impl IntoIterator<Item = Range<usize>>, ) -> Result<(NsAvidmGf2Commit, NsAvidmGf2Common), VidError>
Commit to a payload given namespace table. WARN: it assumes that the namespace table is well formed, i.e. ranges are non-overlapping and cover the whole payload.
Sourcepub fn aggregate_commit(
ns_commits: &[AvidmGf2Commit],
) -> Result<NsAvidmGf2Commit, VidError>
pub fn aggregate_commit( ns_commits: &[AvidmGf2Commit], ) -> Result<NsAvidmGf2Commit, VidError>
Aggregate per-namespace commitments into the top-level namespaced commitment (the Merkle root over the namespace commits).
Lets a caller that has already computed each namespace’s commit (e.g. via
Self::ns_disperse_one) form the block commitment without re-encoding.
Sourcepub fn is_consistent(
commit: &NsAvidmGf2Commit,
common: &NsAvidmGf2Common,
) -> bool
pub fn is_consistent( commit: &NsAvidmGf2Commit, common: &NsAvidmGf2Common, ) -> bool
Check whether the namespaced commitment is consistent with the common data
Sourcepub fn ns_disperse(
param: &NsAvidmGf2Param,
distribution: &[u32],
payload: &[u8],
ns_table: impl IntoIterator<Item = Range<usize>>,
) -> Result<(NsAvidmGf2Commit, NsAvidmGf2Common, Vec<NsAvidmGf2Share>), VidError>
pub fn ns_disperse( param: &NsAvidmGf2Param, distribution: &[u32], payload: &[u8], ns_table: impl IntoIterator<Item = Range<usize>>, ) -> Result<(NsAvidmGf2Commit, NsAvidmGf2Common, Vec<NsAvidmGf2Share>), VidError>
Disperse a payload according to a distribution table and a namespace table. WARN: it assumes that the namespace table is well formed, i.e. ranges are non-overlapping and cover the whole payload.
Sourcepub fn ns_disperse_one(
param: &NsAvidmGf2Param,
distribution: &[u32],
ns_payload: &[u8],
ns_index: usize,
) -> Result<NsDispersal, VidError>
pub fn ns_disperse_one( param: &NsAvidmGf2Param, distribution: &[u32], ns_payload: &[u8], ns_index: usize, ) -> Result<NsDispersal, VidError>
Disperse a single namespace’s slice of the payload.
ns_payload is the namespace’s bytes and ns_index its position in the
namespace table.
Verify a namespaced share given already-verified common data.
Besides each namespace’s Merkle proofs, this checks that each
namespace’s shards have the size its ns_lens entry disperses to. The
commitment binds ns_commits but not ns_lens, so without this a
share could declare any payload length and have it believed. With it,
each declared length is pinned to within 2 * recovery_threshold
bytes of the one the shards were built from.
That window is per namespace, and the disperser chooses how many
namespaces there are, so the misdeclared total adds up: a payload split
into namespaces shorter than a window can declare each as a single
byte and still verify. This rejects gross forgeries early, such as a
shrunken one-namespace block or an absurd length; it does not bound
the total. Exact binding needs a verifier that knows the payload’s
namespace table, or a commitment that covers ns_lens.
§Safety Contract
Caller MUST ensure is_consistent(commit, common) returned true
before calling this. Without that check, a malicious common could
make an invalid share appear valid.
Verify a namespaced share
Sourcepub fn recover(
common: &NsAvidmGf2Common,
shares: &[NsAvidmGf2Share],
) -> Result<Vec<u8>, VidError>
pub fn recover( common: &NsAvidmGf2Common, shares: &[NsAvidmGf2Share], ) -> Result<Vec<u8>, VidError>
Recover the entire payload from enough share
Sourcepub fn ns_recover(
common: &NsAvidmGf2Common,
ns_index: usize,
shares: &[NsAvidmGf2Share],
) -> Result<Vec<u8>, VidError>
pub fn ns_recover( common: &NsAvidmGf2Common, ns_index: usize, shares: &[NsAvidmGf2Share], ) -> Result<Vec<u8>, VidError>
Recover the payload for a given namespace.
Given namespace ID should be valid for all shares, i.e. ns_commits and content have
at least ns_index elements for all shares.
Sourcefn ns_len_matches_shards(
param: &NsAvidmGf2Param,
ns_len: usize,
content: &AvidmGf2Share,
) -> bool
fn ns_len_matches_shards( param: &NsAvidmGf2Param, ns_len: usize, content: &AvidmGf2Share, ) -> bool
Whether content’s shards have the size an ns_len-byte namespace
disperses to under param.
Source§impl NsAvidmGf2Scheme
impl NsAvidmGf2Scheme
Sourcepub fn namespace_proof(
common: &NsAvidmGf2Common,
payload: &[u8],
ns_index: usize,
) -> Result<NsProof, VidError>
pub fn namespace_proof( common: &NsAvidmGf2Common, payload: &[u8], ns_index: usize, ) -> Result<NsProof, VidError>
Generate a proof of inclusion for a namespace payload.
Sourcepub fn verify_namespace_proof(
commit: &NsAvidmGf2Commit,
common: &NsAvidmGf2Common,
proof: &NsProof,
) -> Result<Result<(), ()>, VidError>
pub fn verify_namespace_proof( commit: &NsAvidmGf2Commit, common: &NsAvidmGf2Common, proof: &NsProof, ) -> Result<Result<(), ()>, VidError>
Verify a namespace proof against a namespaced VID commitment.
Auto Trait Implementations§
impl Freeze for NsAvidmGf2Scheme
impl RefUnwindSafe for NsAvidmGf2Scheme
impl Send for NsAvidmGf2Scheme
impl Sync for NsAvidmGf2Scheme
impl Unpin for NsAvidmGf2Scheme
impl UnsafeUnpin for NsAvidmGf2Scheme
impl UnwindSafe for NsAvidmGf2Scheme
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more