def generate_response(self, request):
        if not self._digest_offset_extractor:
            return self.generate_simple_response(request)

        # extract the digest embedded in request
        offset = self._digest_offset_extractor(request)
        req_digest = buffer(request, offset, 32)

        # calculate a digest of the request digest
        key = self.select_own_key()
        digest_key = _hmac(key, req_digest)

        # prepare response
        response = generate_random_bytes(self.packet_bytes - 32)

        # calculate response digest and append it to the response
        digest = _hmac(digest_key, response)
        return response + digest
dataset/ETHPy150Open arkadini/twimp/twimp/crypto/handshake.py/CryptoHandshaker.generate_response/original