nymaddr

package
v0.0.0-...-30b4a77 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2016 License: BSD-3-Clause Imports: 13 Imported by: 0

Documentation

Overview

Package nymaddr implements nym address generation and decoding.

Index

Constants

View Source
const (
	// KeySize is the size in bytes of a key for curve25519.
	KeySize = 32
)

Variables

View Source
var (
	// ErrNoMix is returned if no mix could be found.
	ErrNoMix = errors.New("nymaddr: no mix found")
	// ErrNoKey is returned if a private key was unavailable.
	ErrNoKey = errors.New("nymaddr: private key not found")
	// ErrExpired is returned if a nymaddr has already expired.
	ErrExpired = errors.New("nymaddr: expired")
	// ErrHMAC is returned if a nym-header HMAC verification failed.
	ErrHMAC = errors.New("nymaddr: HMAC mismatch")
	// ErrBadKey is returned if a header key is not reproduceable.
	ErrBadKey = errors.New("nymaddr: bad key in header")
)
View Source
var Rand = rand.Reader

Rand is the random source of this package.

Functions

This section is empty.

Types

type Address

type Address struct {
	MixAddress  []byte // The address of the mix which will handle messages for this Nym
	Expire      int64  // The time when the address should not be used anymore
	SingleUse   bool   // If the address may be used more than once
	TokenPubKey []byte // The token receive key of the mix
	MixPubKey   []byte // Public key of the mix
	AddressKey  []byte // Random, single use key used for this address
	PrivateData []byte // Encrypted private part
}

Address contains a NymAddress.

func ParseAddress

func ParseAddress(address []byte) (*Address, error)

ParseAddress parses an address.

func (*Address) GetMixData

func (ad *Address) GetMixData(keysLookup KeyFunc) (*AddressPrivate, error)

GetMixData decrypts the private portion of a nymaddress.

type AddressPrivate

type AddressPrivate struct {
	System         int32  // The system number. should be 0
	Address        []byte // The final address to deliver to
	Expire         int64  // The time when the address should not be used anymore
	SingleUse      bool   // If the address may be used more than once
	MinDelay       int32  // Minimum delay in the mix
	MaxDelay       int32  // Maximum delay in the mix
	Nonce          []byte // Random data, size KeySize
	ReceiverPubKey []byte // The pubkey of the receiver
	EncNym         []byte // The encrypted Nym
	HMACHead       []byte // The HMAC of the header (nonce, receiverpubkey, encnym)
}

AddressPrivate is the private/encrypted part of a nymaddress.

func (AddressPrivate) GetHeader

func (ap AddressPrivate) GetHeader() (header, secret []byte, err error)

GetHeader returns the header for a relay message and a secret for encryption.

func (AddressPrivate) GetUnique

func (ap AddressPrivate) GetUnique() []byte

GetUnique returns a unique value of the nymaddress IF the nymaddress is single use, nil otherwise.

type AddressTemplate

type AddressTemplate struct {
	Secret []byte // The local secret for address creation, must be random and long-lived

	System        int32               // The system number. should be 0
	MixCandidates mixaddr.AddressList // A list of mixes

	Expire    int64 // The time when the address should not be used anymore
	SingleUse bool  // If the address may be used more than once
	MinDelay  int32 // Minimum delay in the mix
	MaxDelay  int32 // Maximum delay in the mix
}

AddressTemplate contains parameters for address creation.

func (AddressTemplate) GetPrivate

func (tmp AddressTemplate) GetPrivate(header, MailboxAddress []byte) (nym, secret []byte, err error)

GetPrivate gets the shared secret from a header.

func (AddressTemplate) NewAddress

func (tmp AddressTemplate) NewAddress(MailboxAddress, Nym []byte) ([]byte, error)

NewAddress generates a new nymaddress for nym/address from AddressTemplate. Only the first KeySize bytes of Nym are used, so use a hash of the true nym here.

type KeyFunc

type KeyFunc func(*[KeySize]byte) *[KeySize]byte

KeyFunc is a function that returns a private key for a public key, or nil.

type RelayHeader

type RelayHeader struct {
	SenderKey      []byte // Pubkey of the sender (mix), per message
	Nonce          []byte // Random data, size KeySize
	ReceiverPubKey []byte // The pubkey of the receiver
	EncNym         []byte // The encrypted Nym
	HMACHead       []byte // The HMAC of the header (nonce, receiverpubkey, encnym)
}

RelayHeader is the header of a relayed (post-mix) message.

Jump to

Keyboard shortcuts

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