def authenticate!(challenge, response, registration_public_key, registration_counter)
      # TODO: check that it's the correct key_handle as well
      raise NoMatchingRequestError unless challenge == response.client_data.challenge

      raise ClientDataTypeError unless response.client_data.authentication?

      pem = U2F.public_key_pem(registration_public_key)

      raise AuthenticationFailedError unless response.verify(app_id, pem)

      raise UserNotPresentError unless response.user_present?

      unless response.counter > registration_counter
        raise CounterTooLowError unless response.counter.zero? && registration_counter.zero?
      end
    end
def authenticate!(challenge, response, registration_public_key, registration_counter)
      # TODO: check that it's the correct key_handle as well
      raise NoMatchingRequestError unless challenge == response.client_data.challenge

      raise ClientDataTypeError unless response.client_data.authentication?

      pem = U2F.public_key_pem(registration_public_key)

      raise AuthenticationFailedError unless response.verify(app_id, pem)

      raise UserNotPresentError unless response.user_present?

      unless response.counter > registration_counter
        raise CounterTooLowError unless response.counter.zero? && registration_counter.zero?
      end
    end
Authenticate a response from the U2F device

 * *Args*:
   - +challenge+:: Challenge string
   - +response+:: Response from the U2F device as a +SignResponse+ object
   - +registration_public_key+:: Public key of the registered U2F device as binary string
   - +registration_counter+:: +Integer+ with the current counter value of the registered
     device

 * *Raises*:
   - +NoMatchingRequestError+:: if the challenge in the response doesn't match any of the
     provided ones
   - +ClientDataTypeError+:: if the response is of the wrong type
   - +AuthenticationFailedError+:: if the authentication failed
   - +UserNotPresentError+:: if the user wasn't present during the authentication
   - +CounterTooLowError+:: if there is a counter mismatch between the registered one and
     the one in the response