pub struct SecuredLinkedList { /* private fields */ }
Expand description

Chain of BLS keys where every key is proven (signed) by its parent key, except the first one.

CRDT

The operations that mutate the chain (insert and merge) are commutative, associative and idempotent. This means the chain is a CRDT.

Forks

It’s possible to insert multiple keys that all have the same parent key. This is called a “fork”. The chain implements automatic fork resolution which means that even in the presence of forks the chain presents the blocks in a well-defined unique and deterministic order.

Block order

Block are ordered primarily according to their parent-child relation (parents always precede children) and forks are resolved by additionally ordering the sibling blocks according to the Ord relation of their public key. That is, “lower” keys precede “higher” keys.

Implementations

Creates a new chain consisting of only one block.

Insert new key into the chain. parent_key must exists in the chain and must validate signature, otherwise error is returned.

Merges two chains into one.

This succeeds only if the root key of one of the chain is present in the other one. Otherwise it returns Error::InvalidOperation

Creates a sub-chain from given from and to keys. Returns Error::KeyNotFound if the given keys are not present in the chain.

Creates a minimal sub-chain of self that contains all required_keys. Returns Error::KeyNotFound if some of required_keys is not present in self.

Note: “minimal” means it contains the fewest number of blocks of all such sub-chains.

Returns a sub-chain of self truncated to the last count keys. NOTE: a chain must have at least 1 block, so if count is 0 it is treated the same as if it was 1.

Returns the smallest super-chain of self that would be trusted by a peer that trust trusted_key. Ensures that the last key of the resuling chain is the same as the last key of self.

Returns Error::KeyNotFound if any of trusted_key, self.root_key() or self.last_key() is not present in super_chain.

Returns Error::InvalidOperation if trusted_key is not reachable from self.last_key().

Iterator over all the keys in the chain in order.

Returns the root key of this chain. This is the first key in the chain and is the only key that doesn’t have a parent key.

Returns the last key of this chain.

Returns the parent key of the last key or the root key if this chain has only one key.

Returns whether key is present in this chain.

Verify every BLS key in this chain is proven (signed) by its parent key, except the first one.

Given a collection of keys that are already trusted, returns whether this chain is also trusted. A chain is considered trusted only if at least one of the trusted_keys is on its main branch.

Explanation

Consider this chain that contains fork:

A->B->C
   |
   +->D

Now if the only trusted key is D, then there is no way to prove the chain is trusted, because this chain would be indistinguishable in terms of trust from any other chain with the same general “shape”, say:

W->X->Y->Z
   |
   +->D

So an adversary is easily able to forge any such chain.

When the trusted key is on the main branch, on the other hand:

D->E->F
   |
   +->G

Then such chain is impossible to forge because the adversary would have to have access to the secret key corresponding to D in order to validly sign E. Thus such chain can be safely considered trusted.

Compare the two keys by their position in the chain. The key that is higher (closer to the last key) is considered Greater. If exactly one of the keys is not in the chain, the other one is implicitly considered Greater. If none are in the chain, they are considered Equal.

Returns the number of blocks in the chain. This is always >= 1.

Returns the number of block on the main branch of the chain - that is - the ones reachable from the last block.

NOTE: this is a O(n) operation.

Returns the index of the given key. Returns None if not present.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Deserialize this value from the given Serde deserializer. Read more

Feeds this value into the given Hasher. Read more

Feeds a slice of this type into the given Hasher. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Converts self into T using Into<T>. Read more

Causes self to use its Binary implementation when Debug-formatted.

Causes self to use its Display implementation when Debug-formatted. Read more

Causes self to use its LowerExp implementation when Debug-formatted. Read more

Causes self to use its LowerHex implementation when Debug-formatted. Read more

Causes self to use its Octal implementation when Debug-formatted.

Causes self to use its Pointer implementation when Debug-formatted. Read more

Causes self to use its UpperExp implementation when Debug-formatted. Read more

Causes self to use its UpperHex implementation when Debug-formatted. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Pipes by value. This is generally the method you want to use. Read more

Borrows self and passes that borrow into the pipe function. Read more

Mutably borrows self and passes that borrow into the pipe function. Read more

Borrows self, then passes self.borrow() into the pipe function. Read more

Mutably borrows self, then passes self.borrow_mut() into the pipe function. Read more

Borrows self, then passes self.as_ref() into the pipe function.

Mutably borrows self, then passes self.as_mut() into the pipe function. Read more

Borrows self, then passes self.deref() into the pipe function.

Mutably borrows self, then passes self.deref_mut() into the pipe function. Read more

Immutable access to a value. Read more

Mutable access to a value. Read more

Immutable access to the Borrow<B> of a value. Read more

Mutable access to the BorrowMut<B> of a value. Read more

Immutable access to the AsRef<R> view of a value. Read more

Mutable access to the AsMut<R> view of a value. Read more

Immutable access to the Deref::Target of a value. Read more

Mutable access to the Deref::Target of a value. Read more

Calls .tap() only in debug builds, and is erased in release builds.

Calls .tap_mut() only in debug builds, and is erased in release builds. Read more

Calls .tap_borrow() only in debug builds, and is erased in release builds. Read more

Calls .tap_borrow_mut() only in debug builds, and is erased in release builds. Read more

Calls .tap_ref() only in debug builds, and is erased in release builds. Read more

Calls .tap_ref_mut() only in debug builds, and is erased in release builds. Read more

Calls .tap_deref() only in debug builds, and is erased in release builds. Read more

Calls .tap_deref_mut() only in debug builds, and is erased in release builds. Read more

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

Uses borrowed data to replace owned data, usually by cloning. Read more

Attempts to convert self into T using TryInto<T>. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.