Zeth - Zerocash on Ethereum  0.8
Reference implementation of the Zeth protocol by Clearmatics
Public Member Functions | List of all members
zeth.core.input_hasher.InputHasher Class Reference

Public Member Functions

def __init__ (self, MiMCBase compression_fn, int iv=DEFAULT_IV_UINT256)
 
int hash (self, List[int] values)
 

Detailed Description

Note that this is currently experimental code. Hash a series of field
elements via the Merkle-Damgard construction on a MiMC compression
function. Note that since this function only accepts whole numbers of
scalar field elements, there is no ambiguity w.r.t to padding and we could
technically omit the finalization step. It has been kept for now, to allow
time for further consideration, and in case the form of the hasher changes
(e.g. in case we want to be able to hash arbitrary bit strings in the
future).

Definition at line 16 of file input_hasher.py.

Constructor & Destructor Documentation

◆ __init__()

def zeth.core.input_hasher.InputHasher.__init__ (   self,
MiMCBase  compression_fn,
int   iv = DEFAULT_IV_UINT256 
)

Definition at line 27 of file input_hasher.py.

27  def __init__(self, compression_fn: MiMCBase, iv: int = DEFAULT_IV_UINT256):
28  assert compression_fn.prime < (2 << 256)
29  self._compression_fn = compression_fn
30  self._iv = iv % compression_fn.prime
31 

Member Function Documentation

◆ hash()

int zeth.core.input_hasher.InputHasher.hash (   self,
List[int]  values 
)

Definition at line 32 of file input_hasher.py.

32  def hash(self, values: List[int]) -> int:
33  current = self._iv
34  for m in values:
35  current = self._compression_fn.hash_int(current, m)
36  return self._compression_fn.hash_int(current, len(values))

The documentation for this class was generated from the following file: