def register!(challenges, response)
      challenges = [challenges] unless challenges.is_a? Array
      challenge = challenges.detect do |chg|
        chg == response.client_data.challenge
      end

      raise UnmatchedChallengeError unless challenge

      raise ClientDataTypeError unless response.client_data.registration?

      # Validate public key
      U2F.public_key_pem(response.public_key_raw)

      raise AttestationSignatureError unless response.verify(app_id)

      Registration.new(
        response.key_handle,
        response.public_key,
        response.certificate
      )
    end
def register!(challenges, response)
      challenges = [challenges] unless challenges.is_a? Array
      challenge = challenges.detect do |chg|
        chg == response.client_data.challenge
      end

      raise UnmatchedChallengeError unless challenge

      raise ClientDataTypeError unless response.client_data.registration?

      # Validate public key
      U2F.public_key_pem(response.public_key_raw)

      raise AttestationSignatureError unless response.verify(app_id)

      Registration.new(
        response.key_handle,
        response.public_key,
        response.certificate
      )
    end
Authenticate the response from the U2F device when registering

 * *Args*:
   - +challenges+:: +Array+ of challenge strings
   - +response+:: Response of the U2F device as a +RegisterResponse+ object

 * *Returns*:
   - A +Registration+ object

 * *Raises*:
   - +UnmatchedChallengeError+:: if the challenge in the response doesn't match any of
     the provided ones
   - +ClientDataTypeError+:: if the response is of the wrong type
   - +AttestationSignatureError+:: if the registration failed