Zeth - Zerocash on Ethereum  0.8
Reference implementation of the Zeth protocol by Clearmatics
Classes | Functions
zeth.core.mimc Namespace Reference

Classes

class  MiMC17Base
 
class  MiMCAltBN128
 
class  MiMCBase
 
class  MiMCBLS12_377
 

Functions

List[int] generate_round_constants (str seed_str, int num_rounds)
 
ITreeHash get_tree_hash_for_pairing (str pairing_name)
 

Function Documentation

◆ generate_round_constants()

List[int] zeth.core.mimc.generate_round_constants ( str  seed_str,
int  num_rounds 
)
Return the first `num_rounds` round constants. Not called directly here,
but used to precompute (in particular for the mimc_permutation gadget).

Definition at line 121 of file mimc.py.

121 def generate_round_constants(seed_str: str, num_rounds: int) -> List[int]:
122  """
123  Return the first `num_rounds` round constants. Not called directly here,
124  but used to precompute (in particular for the mimc_permutation gadget).
125  """
126  seed = _keccak_256(_str_to_bytes(seed_str))
127  rc = seed
128 
129  rcs = [0]
130  for _ in range(1, num_rounds):
131  rc = _update_round_constant(rc)
132  rcs.append(rc)
133 
134  assert len(rcs) == num_rounds
135  return rcs
136 
137 

◆ get_tree_hash_for_pairing()

ITreeHash zeth.core.mimc.get_tree_hash_for_pairing ( str  pairing_name)
Select an appropriate hash for a given pairing. Note that these must match
the selection logic in `libzeth/circuits/circuit_types.hpp`.

Definition at line 138 of file mimc.py.

138 def get_tree_hash_for_pairing(pairing_name: str) -> ITreeHash:
139  """
140  Select an appropriate hash for a given pairing. Note that these must match
141  the selection logic in `libzeth/circuits/circuit_types.hpp`.
142  """
143  if pairing_name == "alt-bn128":
144  return MiMCAltBN128()
145  if pairing_name == "bls12-377":
146  return MiMCBLS12_377()
147  raise Exception(f"no tree hash for pairing: {pairing_name}")
148 
149 
Here is the caller graph for this function:
zeth.core.mimc.generate_round_constants
List[int] generate_round_constants(str seed_str, int num_rounds)
Definition: mimc.py:121
zeth.core.mimc.get_tree_hash_for_pairing
ITreeHash get_tree_hash_for_pairing(str pairing_name)
Definition: mimc.py:138