MCPcopy
hub / github.com/pyca/cryptography / _compute_mu

Method _compute_mu

tests/hazmat/primitives/test_mldsa.py:172–177  ·  view source on GitHub ↗
(pub_raw: bytes, data: bytes, ctx: bytes = b"")

Source from the content-addressed store, hash-verified

170
171 @staticmethod
172 def _compute_mu(pub_raw: bytes, data: bytes, ctx: bytes = b"") -> bytes:
173 # FIPS 204: mu = SHAKE256(SHAKE256(pk, 64) || M', 64) where for pure
174 # ML-DSA M' = 0x00 || len(ctx) || ctx || M.
175 tr = hashlib.shake_256(pub_raw).digest(64)
176 m_prime = b"\x00" + bytes([len(ctx)]) + ctx + data
177 return hashlib.shake_256(tr + m_prime).digest(64)
178
179 @pytest.mark.parametrize("variant", ML_DSA_VARIANTS)
180 def test_sign_verify_mu(self, variant, backend):

Calls 1

digestMethod · 0.45

Tested by

no test coverage detected