is_valid_hidden_service_address_v3

Function is_valid_hidden_service_address_v3 

Source
pub fn is_valid_hidden_service_address_v3(s: &str) -> bool
Expand description

Validates a v3 hidden service address.

V3 hidden service addresses are 56 lowercase base32 characters (a-z, 2-7). The .onion suffix is optional.

§Format

V3 addresses encode: base32(PUBKEY | CHECKSUM | VERSION)

  • PUBKEY: 32-byte Ed25519 public key
  • CHECKSUM: 2-byte truncated SHA3-256 hash
  • VERSION: 1-byte version (0x03)

Note: This function only validates the format (length and character set), not the cryptographic checksum.

§Arguments

  • s - The string to validate

§Returns

true if the string is a valid v3 hidden service address format.

§Example

use stem_rs::util::is_valid_hidden_service_address_v3;

let v3_addr = "a".repeat(56);
assert!(is_valid_hidden_service_address_v3(&v3_addr));
assert!(is_valid_hidden_service_address_v3(&format!("{}.onion", v3_addr)));

// Invalid - wrong length
assert!(!is_valid_hidden_service_address_v3(&"a".repeat(55)));
// Invalid - uppercase not allowed
assert!(!is_valid_hidden_service_address_v3(&"A".repeat(56)));