View Source ProofOfReserves.Liabilities (proof_of_reserves v0.1.0)

Liabilities is a module that is used to calculate a Proof of Liabilities.

Summary

Functions

dummy_liability returns a dummy liability

liability_to_node converts a liability to a node in the Merkle Sum Tree.

parse_liabilities parses the liabilities from a stream

serialize_liabilities serializes the liabilities into a string

split_liabilities_to_power_of_two divides the liabilities until a power of two is reached. note: This logic attempts to use splitting to get to a power of two. but if we can't get there, we add zero-amount liabilities. It may be simpler to just add zero-amount liabilities until we reach the next power of two.

split_liability divides a liability into 2 liabilities whose amounts sum to the amount of the original liability. This function should never be called with amount <= 1 sat

sum_liabilities calculates the sum of a list of liabilities.

Functions

@spec dummy_liability() :: ProofOfReserves.Liability.t()

dummy_liability returns a dummy liability

Link to this function

fake_liability_account_subkey()

View Source
Link to this function

liability_to_node(block_height, leaf_idx, liability)

View Source

liability_to_node converts a liability to a node in the Merkle Sum Tree.

Link to this function

parse_liabilities(stream)

View Source

parse_liabilities parses the liabilities from a stream

Link to this function

serialize_liabilities(block_height, tree)

View Source
@spec serialize_liabilities(non_neg_integer(), [
  [ProofOfReserves.MerkleSumTree.Node.t()]
]) :: String.t()

serialize_liabilities serializes the liabilities into a string

Link to this function

split_liabilities_to_power_of_two(liabilities)

View Source
@spec split_liabilities_to_power_of_two([ProofOfReserves.Liability.t()]) :: [
  ProofOfReserves.Liability.t()
]

split_liabilities_to_power_of_two divides the liabilities until a power of two is reached. note: This logic attempts to use splitting to get to a power of two. but if we can't get there, we add zero-amount liabilities. It may be simpler to just add zero-amount liabilities until we reach the next power of two.

Link to this function

split_liability(liability)

View Source
@spec split_liability(ProofOfReserves.Liability.t()) :: [
  ProofOfReserves.Liability.t()
]

split_liability divides a liability into 2 liabilities whose amounts sum to the amount of the original liability. This function should never be called with amount <= 1 sat

Link to this function

split_liability_below_threshold(liability, threshold)

View Source
@spec split_liability_below_threshold(
  ProofOfReserves.Liability.t(),
  non_neg_integer()
) :: [
  ProofOfReserves.Liability.t()
]
Link to this function

sum_liabilities(liabilities)

View Source
@spec sum_liabilities([ProofOfReserves.Liability.t()]) :: non_neg_integer()

sum_liabilities calculates the sum of a list of liabilities.