1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
use crate::Node;
use crate::Signature;

/// A merkle proof for an index, created by the `.proof()` method.
#[derive(Debug, PartialEq, Clone)]
pub struct Proof {
    /// The index to which this proof corresponds.
    pub index: usize,
    /// Nodes that verify the index you passed.
    pub nodes: Vec<Node>,
    /// An `ed25519` signature, guaranteeing the integrity of the nodes.
    pub signature: Option<Signature>,
}

impl Proof {
    /// Access the `index` field from the proof.
    pub fn index(&self) -> usize {
        self.index
    }

    /// Access the `nodes` field from the proof.
    pub fn nodes(&self) -> &[Node] {
        &self.nodes
    }

    /// Access the `signature` field from the proof.
    pub fn signature(&self) -> Option<&Signature> {
        self.signature.as_ref()
    }
}