Esempio n. 1
0
    def unmask(self: mask, argument: data) -> data:
        """
        Unmask a data object that has previously been masked with this mask.

        >>> d = data.hash('abc')
        >>> m = mask.hash('abc')
        >>> m.unmask(m(d)) == d
        True
        """
        return data(oblivious.mul(oblivious.inv(self), argument))
Esempio n. 2
0
    def __mul__(self: mask, argument: data) -> data:
        """
        Mask a data object with this mask and return the masked data object.

        >>> d = data.hash('abc')
        >>> m = mask.hash('abc')
        >>> (m * d).hex()
        'f47c8267b28ac5100e0e97b36190e16d4533b367262557a5aa7d97b811344d15'
        """
        return data(oblivious.mul(self, argument))
Esempio n. 3
0
    def __truediv__(self: data, argument: mask) -> data:
        """
        Unmask this data object (assuming it has previously been masked with the
        supplied mask).

        >>> d = data.hash('abc')
        >>> m = mask.hash('abc')
        >>> ((m(d)) / m) == d
        True
        """
        return data(oblivious.mul(oblivious.inv(argument), self))