def encrypt(self, s, mac=16):
        """Encrypt a message for private viewing by the holder of the
        Private Key
        """
        # nonce is essentially a secret on the encrypter's side
        # this is a secret exponent < 2^256
        nonce = randrange(1, self.curve().p())
        tmp = BasePoint * nonce
        nonce_point = PubKey(tmp.curve(), tmp.x(), tmp.y())
        tmp = self * nonce
        shared_secret = PubKey(tmp.curve(), tmp.x(), tmp.y())

        # derive a key for making a cipher and checksum using the
        # nonce point and shared secret
        key = nonce_point.kdf(shared_secret)

        # encode the nonce point into the message as the beginning
        header = nonce_point.sec()

        # encrypt the actual message using the AES cipher
        cipher = AES.new(key[:32])
        # because we're using AES block mode, we need multiples of 16
        s = s + '\x00' * (16 - len(s) % 16)
        message = cipher.encrypt(s)

        # add a checksum for validation
        checksum_maker = hmac.new(key[32:], digestmod=hashlib.sha256)
        checksum_maker.update(message)
        checksum = checksum_maker.digest()[:mac]
        return header + message + checksum
dataset/ETHPy150Open coinmessage/coinmessage/coinmessage/encrypt.py/PubKey.encrypt/original