pub struct MerkleTree { /* private fields */ }Expand description
Append-only Merkle tree mirroring confium_transparency::MerkleTree.
Browser-side consumers typically receive a tree head (root hash + size) from a server and verify inclusion proofs against it. This class also supports building trees locally for testing.
Implementations§
Source§impl MerkleTree
impl MerkleTree
Sourcepub fn new() -> MerkleTree
pub fn new() -> MerkleTree
Construct an empty tree.
Sourcepub fn append(&self, artifact_hash: &[u8]) -> Result<u64, JsValue>
pub fn append(&self, artifact_hash: &[u8]) -> Result<u64, JsValue>
Append a 32-byte artifact hash. Returns the assigned sequence number.
Sourcepub fn consistency_proof(&self, old_size: usize) -> Result<Vec<u8>, JsValue>
pub fn consistency_proof(&self, old_size: usize) -> Result<Vec<u8>, JsValue>
Build a consistency proof (RFC 6962 §2.1.2) for old_size.
Returns a flat array of 32-byte subtree hashes concatenated
(total length = proof.len() * 32).
Sourcepub fn inclusion_proof(&self, sequence: u64) -> Result<InclusionProof, JsValue>
pub fn inclusion_proof(&self, sequence: u64) -> Result<InclusionProof, JsValue>
Build an inclusion proof for sequence.
Trait Implementations§
Source§impl Default for MerkleTree
impl Default for MerkleTree
Source§impl From<MerkleTree> for JsValue
impl From<MerkleTree> for JsValue
Source§fn from(value: MerkleTree) -> Self
fn from(value: MerkleTree) -> Self
Converts to this type from the input type.
Source§impl FromWasmAbi for MerkleTree
impl FromWasmAbi for MerkleTree
Source§impl IntoWasmAbi for MerkleTree
impl IntoWasmAbi for MerkleTree
Source§impl LongRefFromWasmAbi for MerkleTree
impl LongRefFromWasmAbi for MerkleTree
Source§type Abi = WasmPtr<WasmRefCell<MerkleTree>>
type Abi = WasmPtr<WasmRefCell<MerkleTree>>
Same as
RefFromWasmAbi::AbiSource§type Anchor = RcRef<MerkleTree>
type Anchor = RcRef<MerkleTree>
Same as
RefFromWasmAbi::AnchorSource§unsafe fn long_ref_from_abi(js: Self::Abi) -> Self::Anchor
unsafe fn long_ref_from_abi(js: Self::Abi) -> Self::Anchor
Same as
RefFromWasmAbi::ref_from_abiSource§impl OptionFromWasmAbi for MerkleTree
impl OptionFromWasmAbi for MerkleTree
Source§impl OptionIntoWasmAbi for MerkleTree
impl OptionIntoWasmAbi for MerkleTree
Source§impl RefFromWasmAbi for MerkleTree
impl RefFromWasmAbi for MerkleTree
Source§type Abi = WasmPtr<WasmRefCell<MerkleTree>>
type Abi = WasmPtr<WasmRefCell<MerkleTree>>
The Wasm ABI type references to
Self are recovered from.Source§type Anchor = RcRef<MerkleTree>
type Anchor = RcRef<MerkleTree>
The type that holds the reference to
Self for the duration of the
invocation of the function that has an &Self parameter. This is
required to ensure that the lifetimes don’t persist beyond one function
call, and so that they remain anonymous.Source§impl RefMutFromWasmAbi for MerkleTree
impl RefMutFromWasmAbi for MerkleTree
Source§type Abi = WasmPtr<WasmRefCell<MerkleTree>>
type Abi = WasmPtr<WasmRefCell<MerkleTree>>
Same as
RefFromWasmAbi::AbiSource§type Anchor = RcRefMut<MerkleTree>
type Anchor = RcRefMut<MerkleTree>
Same as
RefFromWasmAbi::AnchorSource§unsafe fn ref_mut_from_abi(js: Self::Abi) -> Self::Anchor
unsafe fn ref_mut_from_abi(js: Self::Abi) -> Self::Anchor
Same as
RefFromWasmAbi::ref_from_abiimpl SupportsConstructor for MerkleTree
impl SupportsInstanceProperty for MerkleTree
impl SupportsStaticProperty for MerkleTree
Source§impl TryFromJsValue for MerkleTree
impl TryFromJsValue for MerkleTree
Source§impl VectorFromWasmAbi for MerkleTree
impl VectorFromWasmAbi for MerkleTree
type Abi = <Box<[JsValue]> as FromWasmAbi>::Abi
unsafe fn vector_from_abi(js: Self::Abi) -> Box<[MerkleTree]>
Source§impl VectorIntoWasmAbi for MerkleTree
impl VectorIntoWasmAbi for MerkleTree
type Abi = <Box<[JsValue]> as IntoWasmAbi>::Abi
fn vector_into_abi(vector: Box<[MerkleTree]>) -> Self::Abi
Source§impl WasmDescribeVector for MerkleTree
impl WasmDescribeVector for MerkleTree
Auto Trait Implementations§
impl !Freeze for MerkleTree
impl !RefUnwindSafe for MerkleTree
impl !Sync for MerkleTree
impl Send for MerkleTree
impl Unpin for MerkleTree
impl UnsafeUnpin for MerkleTree
impl UnwindSafe for MerkleTree
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
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<T> ReturnWasmAbi for Twhere
T: IntoWasmAbi,
impl<T> ReturnWasmAbi for Twhere
T: IntoWasmAbi,
Source§type Abi = <T as IntoWasmAbi>::Abi
type Abi = <T as IntoWasmAbi>::Abi
Same as
IntoWasmAbi::AbiSource§fn return_abi(self) -> <T as ReturnWasmAbi>::Abi
fn return_abi(self) -> <T as ReturnWasmAbi>::Abi
Same as
IntoWasmAbi::into_abi, except that it may throw and never
return in the case of Err.