Circuit Control II

Now that we've used the AnonControlClient to see some circuit info, lets use it to assemble circuits with a little more customization!

Aside: Relay Fingerprints and Circuits

Fingerprints All relays have a unique identifier known as a fingerprint. Within the clients, authorities and even on-chain, the fingerprint is a relay's foremost identifier (even ahead of it's IP address). When selecting relays to build a circuit through, the fingerprint is how you specify them.

Example Fingerprint
41B78C1198702625B30FB225AE37AAC0B2FA4ED

Circuits A chain of relays that continually decrypt packets between an Anyone client and its destination (website or hidden service) is called a circuit.

The default onion routing circuit in the Anyone Network is 3 hops- an Entry relay, Middle relay and Exit relay. This model provides a certain level of defence against malicious relays, as a single relay does not have enough information to deanonymize a user.

However, circuits of any length can be constructed, including just one relay. However, if used to visit public websites, one of the relays must be an Exit.

Creating a Random Circuit

We will be introducing the function extendCircuits , which is used to negotiate a new circuit. If no arguments are passed, extendCircuits will select a circuit using the default, randomized selection process, and return a circuit ID number.

const circuitID = await anonControlClient.extendCircuit();
console.log("Randomly created circuit:",circuitID);

This circuit ID can then be used to manage it further, including closing that specific circuit:

await anonControlClient.closeCircuit(circuitID)

Creating a Manual Circuit

The extendCircuit function can also take in an object structured like below, specifying the relays in order by fingerprint:

{
    serverSpecs: [
        "41E262A8DAFB34B7AD5F82280813584101E2A47A",
        "41ADDE21CDCE614FF35DA58CDC15BC7A4A6DFE4D"
    ]
}

Another example could be to take relays from existing objects from the getRelayInfo function:

serverSpecs: [
  circuits[0].relays[0].fingerprint, 
  circuits[1].relays[1].fingerprint, 
  circuits[2].relays[2].fingerprint
]

In the future, the NPM SDK will expose all active relay information, giving you the data to create the algorithms for your privacy! However, for now this exists as a beta feature and users looking to secure can use the default routing algorithm.

Last updated