ad

package
v0.1.19 Latest Latest
Warning

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

Go to latest
Published: Jul 6, 2023 License: Unlicense Imports: 11 Imported by: 0

Documentation

Overview

Package ad is an abstract message type that composes the common elements of all ads - nonce ID, public key (identity), expiry and signature.

The concrete ad types are in subfolders of this package.

Index

Constants

View Source
const (
	Magic = "prad"
	Len   = magic.Len +
		nonce.IDLen +
		crypto.PubKeyLen +
		slice.Uint64Len +
		crypto.SigLen
	TTL = time.Hour
)

Variables

This section is empty.

Functions

func Gen

func Gen() codec.Codec

Types

type Ad struct {

	// ID is a random number generated for each new add that practically guarantees
	// no repeated hash for a message to be signed with the same peer identity key.
	ID nonce.ID

	// Key is the public identity key of the peer.
	Key *crypto.Pub

	// Expiry is the time after which this ad is considered no longer current.
	Expiry time.Time

	// Sig is the signature, which must match the Key above.
	Sig crypto.SigBytes
}

Ad is an abstract message that isn't actually used, but rather is composed into the rest being the common fields to all ads.

func New

func New(id nonce.ID, key *crypto.Prv,
	expiry time.Time) (protoAd *Ad)

New creates a new Ad and signs it with the provided private key.

func (*Ad) Decode

func (x *Ad) Decode(s *splice.Splice) (e error)

Decode unpacks a binary encoded form of the Ad and populates itself.

func (*Ad) Encode

func (x *Ad) Encode(s *splice.Splice) (e error)

Encode the Ad into a splice.Splice for wire or storage.

func (*Ad) Len

func (x *Ad) Len() int

Len is the number of bytes required for the binary encoded form of an Ad.

func (*Ad) Magic

func (x *Ad) Magic() string

Magic is the identifying 4 byte string used to mark the beginning of a message and designate the type.

func (*Ad) Splice

func (x *Ad) Splice(s *splice.Splice)

Splice the Ad into a splice.Splice.

func (*Ad) SpliceNoSig

func (x *Ad) SpliceNoSig(s *splice.Splice)

SpliceNoSig encodes the message but stops at the signature.

func (*Ad) Unwrap

func (x *Ad) Unwrap() interface{}

Unwrap returns nil because there is no onion inside an Ad.

func (*Ad) Validate

func (x *Ad) Validate() bool

Validate returns true if the signature matches the public key.

Directories

Path Synopsis
Package addresses defines the message format that provides the network multi-address of a peer with a given public identity key.
Package addresses defines the message format that provides the network multi-address of a peer with a given public identity key.
Package intro defines a message type that provides information about an introduction point for a hidden service.
Package intro defines a message type that provides information about an introduction point for a hidden service.
Package load provides a message type that provides information about the current load level of a node identified by its public key.
Package load provides a message type that provides information about the current load level of a node identified by its public key.
Package peer provides a message type that provides the base information, identity key and relay rate for an Indra relay.
Package peer provides a message type that provides the base information, identity key and relay rate for an Indra relay.
Package services provides a message type for advertising what kinds of exit services a peer provides to clients, including the port number and the cost per megabyte of data.
Package services provides a message type for advertising what kinds of exit services a peer provides to clients, including the port number and the cost per megabyte of data.

Jump to

Keyboard shortcuts

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