address

package
v0.5.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 27, 2024 License: LGPL-3.0 Imports: 1 Imported by: 21

Documentation

Overview

Package address contains the types used by yggdrasil to represent IPv6 addresses or prefixes, as well as functions for working with these types. Of particular importance are the functions used to derive addresses or subnets from a NodeID, or to get the NodeID and bitmask of the bits visible from an address, which is needed for DHT searches.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetPrefix

func GetPrefix() [1]byte

GetPrefix returns the address prefix used by yggdrasil. The current implementation requires this to be a multiple of 8 bits + 7 bits. The 8th bit of the last byte is used to signal nodes (0) or /64 prefixes (1). Nodes that configure this differently will be unable to communicate with each other using IP packets, though routing and the DHT machinery *should* still work.

Types

type Address

type Address [16]byte

Address represents an IPv6 address in the yggdrasil address range.

func AddrForKey added in v0.4.0

func AddrForKey(publicKey ed25519.PublicKey) *Address

AddrForKey takes an ed25519.PublicKey as an argument and returns an *Address. This function returns nil if the key length is not ed25519.PublicKeySize. This address begins with the contents of GetPrefix(), with the last bit set to 0 to indicate an address. The following 8 bits are set to the number of leading 1 bits in the bitwise inverse of the public key. The bitwise inverse of the key, excluding the leading 1 bits and the first leading 0 bit, is truncated to the appropriate length and makes up the remainder of the address.

func (*Address) GetKey added in v0.4.0

func (a *Address) GetKey() ed25519.PublicKey

GetKet returns the partial ed25519.PublicKey for the Address. This is used for key lookup.

func (*Address) IsValid

func (a *Address) IsValid() bool

IsValid returns true if an address falls within the range used by nodes in the network.

type Subnet

type Subnet [8]byte

Subnet represents an IPv6 /64 subnet in the yggdrasil subnet range.

func SubnetForKey added in v0.4.0

func SubnetForKey(publicKey ed25519.PublicKey) *Subnet

SubnetForKey takes an ed25519.PublicKey as an argument and returns a *Subnet. This function returns nil if the key length is not ed25519.PublicKeySize. The subnet begins with the address prefix, with the last bit set to 1 to indicate a prefix. The following 8 bits are set to the number of leading 1 bits in the bitwise inverse of the key. The bitwise inverse of the key, excluding the leading 1 bits and the first leading 0 bit, is truncated to the appropriate length and makes up the remainder of the subnet.

func (*Subnet) GetKey added in v0.4.0

func (s *Subnet) GetKey() ed25519.PublicKey

GetKet returns the partial ed25519.PublicKey for the Subnet. This is used for key lookup.

func (*Subnet) IsValid

func (s *Subnet) IsValid() bool

IsValid returns true if a prefix falls within the range usable by the network.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL