|
|
|
@ -14,8 +14,8 @@ public extension ECKeyPair {
|
|
|
|
|
// Check that it's a valid hexadecimal encoding
|
|
|
|
|
let allowedCharacters = CharacterSet(charactersIn: "0123456789ABCDEF")
|
|
|
|
|
guard candidate.uppercased().unicodeScalars.allSatisfy({ allowedCharacters.contains($0) }) else { return false }
|
|
|
|
|
// Check that it has either length 33 and a leading "05" or length 32
|
|
|
|
|
guard (candidate.count == 33 && candidate.hasPrefix("05")) || candidate.count == 32 else { return false }
|
|
|
|
|
// Check that it has either length 66 and a leading "05" or length 64
|
|
|
|
|
guard (candidate.count == 66 && candidate.hasPrefix("05")) || candidate.count == 64 else { return false }
|
|
|
|
|
// It appears to be a valid public key
|
|
|
|
|
return true
|
|
|
|
|
}
|
|
|
|
|