Struct yggdrasil_keys::NodeIdentity[][src]

pub struct NodeIdentity {
    pub signing_keys: Keypair,
}
Expand description

Represents a node in the yggdrasil network.

The keys in here are as used in the reference implementation yggdrasil-go. In a previous version of this crate, it was based on the YS001: Yggdrasil Core Specification, but that spec has not been updated for the new v0.4 release of yggdrasil-go release yet, so for compatibility with the new version, we’re basing this on the reference implementation instead.

Fields

signing_keys: Keypair

ed25519 key pair, used as the node identity and for address generation

Implementations

This prefix is taken from yggdrasil-go, it’s the one currently used in the yggdrasil network, namely 200::/7.

Generates node identity using the supplied CSPRNG

use rand::thread_rng;
use std::net::Ipv6Addr;
use yggdrasil_keys::NodeIdentity;

let node = NodeIdentity::new(&mut thread_rng());
let address : Ipv6Addr = node.into();

Parses hexadecimally encoded keypairs.

Arguments:

  • sec_hex: Either 32 hex encoded bytes for the secret key, or 64 hex encoded bytes for the keypair
  • pub_hex: Optionally, 32 hex encoded bytes for the public key

These arguments work like this:

  • You have to supply the secret key.
  • You can supply the public key, but you don’t have to. If it’s missing, one will be generated from the secret key.
  • If you pass a keypair to the sec_hex argument, and additionally a public key to the pub_hex argument, the two keys will be compared. If they differ, the function returns an error.

Hex-encode the secret and public keys into a String each

Hex-encode the keypair into a combined String

The “strength” of a given NodeIdentity is the number of leading one bits set in the inverted public key.

Calculate the address for this NodeIdentity with the given IP prefix.

Calculate the /64 subnet for this NodeIdentity with the given IP prefix.

Calculate the address for this NodeIdentity with the default IP prefix.

Calculate the /64 subnet for this NodeIdentity with the default IP prefix.

Trait Implementations

Performs the conversion.

Performs the conversion.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

Should always be Self

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.