Normalize user input (case, optional prefixes) and validate it as a base32-encoded Ed25519 public key.
(&self)
| 114 | /// Normalize user input (case, optional prefixes) and validate it as a |
| 115 | /// base32-encoded Ed25519 public key. |
| 116 | fn normalize_and_validate(&self) -> CliResult<String> { |
| 117 | let input = self.public_key.trim(); |
| 118 | |
| 119 | if input.starts_with(DID_ATOMIC_PREFIX) { |
| 120 | return Err(CliError::InvalidArgument { |
| 121 | message: format!( |
| 122 | "'{input}' is a did:atomic: identifier. A did:atomic: value is a \ |
| 123 | fingerprint of the public key (base32 of blake3(pubkey)), not the \ |
| 124 | key itself, so it cannot be used for lookup. Provide the raw \ |
| 125 | base32 public key instead (52 chars, A-Z2-7)." |
| 126 | ), |
| 127 | }); |
| 128 | } |
| 129 | |
| 130 | let normalized = input.to_ascii_uppercase(); |
| 131 | |
| 132 | let key = PublicKey::from_base32(&normalized).map_err(|e| CliError::InvalidArgument { |
| 133 | message: format!("Invalid public key: {e}"), |
| 134 | })?; |
| 135 | |
| 136 | Ok(key.to_base32()) |
| 137 | } |
| 138 | |
| 139 | /// Map a remote error, giving a clear message for the common 404 case. |
| 140 | fn map_remote_error(&self, e: RemoteError, canonical: &str) -> CliError { |