def METHOD_NAME(response, challenge, *, rp_id, origin):
    """
    Validates the challenge and attestation information
    sent from the client during device registration.
    Returns a WebAuthnCredential on success.
    Raises RegistrationRejectedError on failire.
    """
    # NOTE: We re-encode the challenge below, because our
    # response's clientData.challenge is encoded twice:
    # first for the entire clientData payload, and then again
    # for the individual challenge.
    encoded_challenge = _webauthn_b64encode(challenge)
    try:
        _credential = RegistrationCredential.parse_raw(response)
        return pywebauthn.METHOD_NAME(
            credential=_credential,
            expected_challenge=encoded_challenge,
            expected_rp_id=rp_id,
            expected_origin=origin,
            require_user_verification=False,
        )
    except (
        InvalidAuthenticatorDataStructure,
        InvalidRegistrationResponse,
        UnsupportedPublicKeyType,
    ) as e:
        raise RegistrationRejectedError(str(e))