Beispiel #1
0
 def last_index_as_trytes(self):
     # type: () -> TryteString
     """
     Returns a TryteString representation of the transaction's
     :py:attr:`last_index`.
     """
     # Note that we are padding to 27 *trits*.
     return TryteString.from_trits(trits_from_int(self.last_index, pad=27))
Beispiel #2
0
 def timestamp_as_trytes(self):
     # type: () -> TryteString
     """
     Returns a TryteString representation of the transaction's
     :py:attr:`timestamp`.
     """
     # Note that we are padding to 27 *trits*.
     return TryteString.from_trits(trits_from_int(self.timestamp, pad=27))
Beispiel #3
0
 def value_as_trytes(self):
     # type: () -> TryteString
     """
     Returns a TryteString representation of the transaction's
     :py:attr:`value`.
     """
     # Note that we are padding to 81 *trits*.
     return TryteString.from_trits(trits_from_int(self.value, pad=81))
Beispiel #4
0
 def attachment_timestamp_upper_bound_as_trytes(self):
     # type: () -> TryteString
     """
     Returns a TryteString representation of the transaction's
     :py:attr:`attachment_timestamp_upper_bound`.
     """
     # Note that we are padding to 27 *trits*.
     return TryteString.from_trits(
         trits_from_int(self.attachment_timestamp_upper_bound, pad=27), )
Beispiel #5
0
    def as_trytes(self):
        # type: () -> List[List[int]]
        """
        Converts the TryteString into a sequence of trytes.

        Each tryte is represented as a list with 3 trit values.

        See :py:meth:`as_trits` for more info.

        .. important::
            :py:class:`TryteString` is not a numeric type, so the result
            of this method should not be interpreted as an integer!
        """
        return [trits_from_int(n, pad=3) for n in self.as_integers()]
Beispiel #6
0
    def _create_sponge(self, index):
        # type: (int) -> Kerl
        """
        Prepares the hash sponge for the generator.
        """
        seed = self.seed_as_trits[:]

        sponge = Kerl()
        sponge.absorb(add_trits(seed, trits_from_int(index)))

        # Squeeze all of the trits out of the sponge and re-absorb them.
        # Note that the sponge transforms several times per operation,
        # so this sequence is not as redundant as it looks at first
        # glance.
        sponge.squeeze(seed)
        sponge.reset()
        sponge.absorb(seed)

        return sponge