Struct merkle_sigs::Proof [−][src]
pub struct Proof<T> { pub algorithm: &'static Algorithm, pub root_hash: Vec<u8>, pub lemma: Lemma, pub value: T, }
An inclusion proof represent the fact that a value
is a member
of a MerkleTree
with root hash root_hash
, and hash function algorithm
.
Fields
algorithm: &'static Algorithm
The hashing algorithm used in the original MerkleTree
root_hash: Vec<u8>
The hash of the root of the original MerkleTree
lemma: Lemma
The first Lemma
of the Proof
value: T
The value concerned by this Proof
Methods
impl<T> Proof<T>
[src]
impl<T> Proof<T>
pub fn new(
algorithm: &'static Algorithm,
root_hash: Vec<u8>,
lemma: Lemma,
value: T
) -> Proof<T>
[src]
pub fn new(
algorithm: &'static Algorithm,
root_hash: Vec<u8>,
lemma: Lemma,
value: T
) -> Proof<T>
Constructs a new Proof
pub fn validate(&self, root_hash: &[u8]) -> bool
[src]
pub fn validate(&self, root_hash: &[u8]) -> bool
Checks whether this inclusion proof is well-formed,
and whether its root hash matches the given root_hash
.
pub fn index(&self, count: usize) -> usize
[src]
pub fn index(&self, count: usize) -> usize
Returns the index of this proof's value, given the total number of items in the tree.
Panics
Panics if the proof is malformed. Call validate
first.
impl<T> Proof<T>
[src]
impl<T> Proof<T>
pub fn from_protobuf(
algorithm: &'static Algorithm,
proto: ProofProto
) -> Option<Proof<T>> where
T: From<Vec<u8>>,
[src]
pub fn from_protobuf(
algorithm: &'static Algorithm,
proto: ProofProto
) -> Option<Proof<T>> where
T: From<Vec<u8>>,
Constructs a Proof
struct from its Protobuf representation.
pub fn into_protobuf(self) -> ProofProto where
T: Into<Vec<u8>>,
[src]
pub fn into_protobuf(self) -> ProofProto where
T: Into<Vec<u8>>,
Encode this Proof
to its Protobuf representation.
pub fn parse_from_bytes(
bytes: &[u8],
algorithm: &'static Algorithm
) -> Result<Option<Proof<T>>, ProtobufError> where
T: From<Vec<u8>>,
[src]
pub fn parse_from_bytes(
bytes: &[u8],
algorithm: &'static Algorithm
) -> Result<Option<Proof<T>>, ProtobufError> where
T: From<Vec<u8>>,
Parse a Proof
from its Protobuf binary representation.
pub fn write_to_bytes(self) -> Result<Vec<u8>, ProtobufError> where
T: Into<Vec<u8>>,
[src]
pub fn write_to_bytes(self) -> Result<Vec<u8>, ProtobufError> where
T: Into<Vec<u8>>,
Serialize this Proof
with Protobuf.
Trait Implementations
impl<T> Eq for Proof<T> where
T: Eq,
[src]
impl<T> Eq for Proof<T> where
T: Eq,
impl<T> PartialEq<Proof<T>> for Proof<T> where
T: PartialEq<T>,
[src]
impl<T> PartialEq<Proof<T>> for Proof<T> where
T: PartialEq<T>,
fn eq(&self, other: &Proof<T>) -> bool
[src]
fn eq(&self, other: &Proof<T>) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
#[must_use]
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]
fn ne(&self, other: &Rhs) -> bool
This method tests for !=
.
impl<T> Clone for Proof<T> where
T: Clone,
[src]
impl<T> Clone for Proof<T> where
T: Clone,
fn clone(&self) -> Proof<T>
[src]
fn clone(&self) -> Proof<T>
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
impl<T> PartialOrd<Proof<T>> for Proof<T> where
T: Ord,
[src]
impl<T> PartialOrd<Proof<T>> for Proof<T> where
T: Ord,
fn partial_cmp(&self, other: &Proof<T>) -> Option<Ordering>
[src]
fn partial_cmp(&self, other: &Proof<T>) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
#[must_use]
fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]
fn lt(&self, other: &Rhs) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
#[must_use]
fn le(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
#[must_use]
fn gt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]
fn gt(&self, other: &Rhs) -> bool
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
#[must_use]
fn ge(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]
fn ge(&self, other: &Rhs) -> bool
This method tests greater than or equal to (for self
and other
) and is used by the >=
operator. Read more
impl<T> Ord for Proof<T> where
T: Ord,
[src]
impl<T> Ord for Proof<T> where
T: Ord,
fn cmp(&self, other: &Proof<T>) -> Ordering
[src]
fn cmp(&self, other: &Proof<T>) -> Ordering
This method returns an Ordering
between self
and other
. Read more
fn max(self, other: Self) -> Self
1.21.0[src]
fn max(self, other: Self) -> Self
Compares and returns the maximum of two values. Read more
fn min(self, other: Self) -> Self
1.21.0[src]
fn min(self, other: Self) -> Self
Compares and returns the minimum of two values. Read more
impl<T> Hash for Proof<T> where
T: Hash,
[src]
impl<T> Hash for Proof<T> where
T: Hash,
fn hash<H>(&self, state: &mut H) where
H: Hasher,
[src]
fn hash<H>(&self, state: &mut H) where
H: Hasher,
Feeds this value into the given [Hasher
]. Read more
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
Feeds a slice of this type into the given [Hasher
]. Read more
impl<T> Debug for Proof<T> where
T: Debug,
[src]
impl<T> Debug for Proof<T> where
T: Debug,