6.1. Common Random Permutation¶
-
class
aleph.crypto.crp.
CommonRandomPermutation
(public_keys_hex, hashing_function=None)¶ This class represents common random permutation defined in the whitepaper.
- Parameters
public_keys (list) – list of all public keys in hex format
hashing_function (function) – hashing function used for generating common random permutations – assumed to take input and output a bytestring if None hashing_function is provided then it uses sha3_hash i.e. hashlib.sha512
-
add_to_cache
(level, permutation)¶ Adds an element to cache and shrinks the size of cache if the size becomes > 2*cache_size
- Parameters
level (int) – level for which permutation is cached
permutation (list) – permutation of the set n to be cached
-
index_of
(item, level)¶ Outputs the position in the permutation crp[level] of item.
- Parameters
item (int) – the number whose position we seek
level (int) – the level of the permutation of interest
- Returns
the position of item in the permutation at this level