fromBoolean
Factory method to create an attestation instance based on a boolean condition.
This convenience method simplifies attestation selection by allowing callers to specify whether hardware attestation should be used via a boolean parameter. It's particularly useful when attestation requirements are determined dynamically based on device capabilities, security policies, or configuration settings.
The method automatically handles challenge management:
When
valueis true, creates Default attestation with the provided challengeWhen
valueis false, creates None attestation (challenge is ignored)
Common usage patterns:
// Based on device capability detection
val attestation = Attestation.fromBoolean(
value = deviceHasHardwareAttestation(),
challenge = serverChallenge
)
// Based on application security policy
val attestation = Attestation.fromBoolean(
value = requireHighSecurity,
challenge = authChallenge
)
// Based on user preference or admin setting
val attestation = Attestation.fromBoolean(
value = userSettings.enableHardwareAttestation,
challenge = challenge
)Return
Default attestation instance if value is true, None otherwise
Parameters
Cryptographic challenge for attestation verification. Required when value is true, ignored when value is false. Should be cryptographically random and provided by the relying party.