def squeeze(self, trits):
# type: (MutableSequence[int]) -> None
"""
Squeeze trits from the sponge.
:param trits:
Sequence that the squeezed trits will be copied to.
Note: this object will be modified!
"""
#
# Squeeze is kind of like the opposite of absorb; it copies trits
# from internal state to the ``trits`` parameter, one hash at a
# time, and transforming internal state in between hashes.
#
# However, only the first hash of the state is "public", so we
# can simplify the implementation somewhat.
#
# Ensure that ``trits`` can hold at least one hash worth of trits.
trits.extend([0] * max(0, HASH_LENGTH - len(trits)))
# Copy exactly one hash.
trits[0:HASH_LENGTH] = self._state[0:HASH_LENGTH]
# One hash worth of trits copied; now transform.
self._transform()
评论列表
文章目录