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
@spec liability_to_node( non_neg_integer(), non_neg_integer(), ProofOfReserves.Liability.t() ) :: ProofOfReserves.MerkleSumTree.Node.t()
liability_to_node converts a liability to a node in the Merkle Sum Tree.
parse_liabilities parses the liabilities from a stream
@spec serialize_liabilities(non_neg_integer(), [ [ProofOfReserves.MerkleSumTree.Node.t()] ]) :: String.t()
serialize_liabilities serializes the liabilities into a string
@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.
@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
@spec split_liability_below_threshold( ProofOfReserves.Liability.t(), non_neg_integer() ) :: [ ProofOfReserves.Liability.t() ]
@spec sum_liabilities([ProofOfReserves.Liability.t()]) :: non_neg_integer()
sum_liabilities calculates the sum of a list of liabilities.