HiddenServiceDescriptorV2

Struct HiddenServiceDescriptorV2 

Source
pub struct HiddenServiceDescriptorV2 {
    pub descriptor_id: String,
    pub version: u32,
    pub permanent_key: Option<String>,
    pub secret_id_part: String,
    pub published: DateTime<Utc>,
    pub protocol_versions: Vec<u32>,
    pub introduction_points_encoded: Option<String>,
    pub introduction_points_content: Option<Vec<u8>>,
    pub signature: String,
    /* private fields */
}
Expand description

Version 2 hidden service descriptor.

A v2 hidden service descriptor contains all the information needed for clients to connect to a hidden service using the v2 protocol. This includes the service’s public key, publication time, supported protocol versions, and encrypted introduction points.

§Deprecation Notice

Version 2 hidden services are deprecated and being phased out by the Tor Project. New services should use version 3 descriptors (HiddenServiceDescriptorV3) which provide stronger cryptography.

§Structure

The descriptor contains:

  • descriptor_id: Unique identifier (base32 hash of service key and time)
  • permanent_key: RSA-1024 public key of the hidden service
  • secret_id_part: Hash component for descriptor ID validation
  • published: When this descriptor was created
  • protocol_versions: Supported rendezvous protocol versions (typically 2,3)
  • introduction_points_*: Encrypted or encoded introduction point data
  • signature: RSA signature over the descriptor

§Introduction Points

Introduction points may be encrypted if the service uses client authorization. Use introduction_points() to decode them when unencrypted.

§Example

use stem_rs::descriptor::hidden::HiddenServiceDescriptorV2;
use stem_rs::descriptor::Descriptor;

let content = std::fs::read_to_string("descriptor.txt")?;
let desc = HiddenServiceDescriptorV2::parse(&content)?;

println!("Descriptor ID: {}", desc.descriptor_id);
println!("Published: {}", desc.published);
println!("Protocol versions: {:?}", desc.protocol_versions);

// Get introduction points (if not encrypted)
if let Ok(points) = desc.introduction_points() {
    for point in points {
        println!("Intro point: {} at {}:{}",
                 point.identifier, point.address, point.port);
    }
}

§Security

  • The permanent_key is the long-term identity of the service
  • The signature should be verified against permanent_key
  • Introduction points may be encrypted for client authorization

Fields§

§descriptor_id: String

Unique identifier for this descriptor (base32-encoded hash).

§version: u32

Hidden service descriptor version (always 2 for this type).

§permanent_key: Option<String>

RSA-1024 public key of the hidden service (PEM format).

§secret_id_part: String

Hash of time period, cookie, and replica for descriptor ID validation.

§published: DateTime<Utc>

UTC timestamp when this descriptor was published.

§protocol_versions: Vec<u32>

List of supported rendezvous protocol versions (typically [2, 3]).

§introduction_points_encoded: Option<String>

Raw base64-encoded introduction points blob (MESSAGE block).

§introduction_points_content: Option<Vec<u8>>

Decoded introduction points content (may be encrypted).

§signature: String

RSA signature over the descriptor content (PEM format).

Implementations§

Source§

impl HiddenServiceDescriptorV2

Source

pub fn introduction_points(&self) -> Result<Vec<IntroductionPointV2>, Error>

Decodes and parses the introduction points from this descriptor.

Introduction points are act as intermediaries between clients and the hidden service. This method decodes the base64-encoded introduction points blob and parses each introduction point.

§Returns

A vector of IntroductionPointV2 on success, or an empty vector if no introduction points are present.

§Errors

Returns Error::Parse if:

  • The introduction points content is not valid UTF-8
  • The content is encrypted (starts with something other than “introduction-point “)
  • Individual introduction points fail to parse
§Example
let desc = HiddenServiceDescriptorV2::parse(content)?;
leo_points = desc.introduction_points()?;

for point in intro_points {
    println!("Relay: {} at {}:{}",
             point.identifier, point.address, point.port);
}
§Security

If the hidden service uses client authorization, the introduction points will be encrypted and this method will return an error. Decryption requires the client’s authorization cookie.

Trait Implementations§

Source§

impl Clone for HiddenServiceDescriptorV2

Source§

fn clone(&self) -> HiddenServiceDescriptorV2

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for HiddenServiceDescriptorV2

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Descriptor for HiddenServiceDescriptorV2

Source§

fn parse(content: &str) -> Result<Self, Error>

Parses a descriptor from its string content. Read more
Source§

fn to_descriptor_string(&self) -> String

Serializes the descriptor to its canonical string format. Read more
Source§

fn digest( &self, hash: DigestHash, encoding: DigestEncoding, ) -> Result<String, Error>

Computes the cryptographic digest of the descriptor. Read more
Source§

fn raw_content(&self) -> &[u8]

Returns the raw bytes of the original descriptor content. Read more
Source§

fn unrecognized_lines(&self) -> &[String]

Returns lines from the descriptor that were not recognized. Read more
Source§

impl Display for HiddenServiceDescriptorV2

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl FromStr for HiddenServiceDescriptorV2

Source§

type Err = Error

The associated error which can be returned from parsing.
Source§

fn from_str(s: &str) -> Result<Self, Self::Err>

Parses a string s to return a value of this type. Read more
Source§

impl PartialEq for HiddenServiceDescriptorV2

Source§

fn eq(&self, other: &HiddenServiceDescriptorV2) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for HiddenServiceDescriptorV2

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.