diff --git a/libsignal/src/main/java/org/session/libsignal/utilities/Validation.kt b/libsignal/src/main/java/org/session/libsignal/utilities/Validation.kt index d0453fc140..fdf9bd386f 100644 --- a/libsignal/src/main/java/org/session/libsignal/utilities/Validation.kt +++ b/libsignal/src/main/java/org/session/libsignal/utilities/Validation.kt @@ -1,11 +1,11 @@ package org.session.libsignal.utilities object PublicKeyValidation { - private val HEX_CHARACTERS = "0123456789ABCDEF".toSet() + private val HEX_CHARACTERS = "0123456789ABCDEFabcdef".toSet() private val INVALID_PREFIXES = setOf(IdPrefix.GROUP, IdPrefix.BLINDED, IdPrefix.BLINDEDV2) fun isValid(candidate: String, isPrefixRequired: Boolean = true): Boolean = hasValidLength(candidate) && isValidHexEncoding(candidate) && (!isPrefixRequired || IdPrefix.fromValue(candidate) != null) fun hasValidPrefix(candidate: String) = IdPrefix.fromValue(candidate) !in INVALID_PREFIXES private fun hasValidLength(candidate: String) = candidate.length == 66 - private fun isValidHexEncoding(candidate: String) = HEX_CHARACTERS.containsAll(candidate.uppercase().toSet()) + private fun isValidHexEncoding(candidate: String) = HEX_CHARACTERS.containsAll(candidate.toSet()) }