def register_response(challenge, error = false)
      if error
        JSON.dump(errorCode: 4)
      else
        client_data_json = client_data(::U2F::ClientData::REGISTRATION_TYP, challenge)
        JSON.dump(
          registrationData: reg_registration_data(client_data_json),
          clientData: ::U2F.urlsafe_encode64(client_data_json)
        )
      end
    end
def register_response(challenge, error = false)
      if error
        JSON.dump(errorCode: 4)
      else
        client_data_json = client_data(::U2F::ClientData::REGISTRATION_TYP, challenge)
        JSON.dump(
          registrationData: reg_registration_data(client_data_json),
          clientData: ::U2F.urlsafe_encode64(client_data_json)
        )
      end
    end
Initialize a new FakeU2F device for use in tests.

 app_id  - The appId/origin this is being tested against.
 options - A Hash of optional parameters (optional).
           :counter      - The initial counter for this device.
           :key_handle   - The raw key-handle this device should use.
           :cert_subject - The subject field for the certificate generated
                           for this device.

 Returns nothing.
 A registerResponse hash as returned by the u2f.register JavaScript API.

 challenge - The challenge to sign.
 error     - Boolean. Whether to return an error response (optional).

 Returns a JSON encoded Hash String.