sphinx

package
v0.0.0-...-a3f0f6a Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2020 License: MIT Imports: 9 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type H

type H struct {
	Ge  []byte
	Ri  [routingInfoSize]byte
	Rim [hmacSize]byte
}
type Header struct {
	GroupElement   ecdsa.PublicKey
	RoutingInfo    [routingInfoSize]byte
	RoutingInfoMac [hmacSize]byte
}

func (*Header) GobDecode

func (h *Header) GobDecode(raw []byte) error

func (*Header) GobEncode

func (h *Header) GobEncode() ([]byte, error)

func (*Header) Mac

func (h *Header) Mac(key scrypto.Hash256) []byte

returns HMAC-SHA-256 of the header

type P

type P struct {
	V  byte
	H  []byte
	P  [payloadSize]byte
	Pm [hmacSize]byte
}

Packet encoding auxiliar data structure and logic

type Packet

type Packet struct {
	Version byte
	*Header

	// packet payload has a fixed size and is obfuscated at each hop
	Payload [payloadSize]byte
}

func NewPacket

func NewPacket(sessionKey *ecdsa.PrivateKey, circuitPubKeys []ecdsa.PublicKey,
	finalAddr []byte, relayAddrs [][]byte, payload [payloadSize]byte) (*Packet, error)

NewPacket creates a new packet to be forwarded to the first relay in the secure circuit. It takes an ephemeral session key, the destination information (address and payload) and relay information (public keys and addresses) and constructs a cryptographically secure onion packet. The packet is then encoded and sent over the wire to the first relay. This is the entry point function for an initiator to construct a onion circuit.

func (*Packet) GobDecode

func (p *Packet) GobDecode(raw []byte) error

func (*Packet) GobEncode

func (p *Packet) GobEncode() ([]byte, error)

func (*Packet) IsLast

func (p *Packet) IsLast() bool

checks if packet is last in the path. this is verified by inspecting the hash of the routing information of the packet's header. if the hash is all zeroes, then the current relayer is an exit relay.

type RelayerCtx

type RelayerCtx struct {
	// contains filtered or unexported fields
}

func NewRelayerCtx

func NewRelayerCtx(privKey *ecdsa.PrivateKey) *RelayerCtx

func (*RelayerCtx) ListProcessedPackets

func (r *RelayerCtx) ListProcessedPackets() [][32]byte

returns list tags of each of the processed packets by the current relay context

func (*RelayerCtx) ProcessPacket

func (r *RelayerCtx) ProcessPacket(packet *Packet) ([addrSize]byte, *Packet, error)

processes packet in a given relayer context

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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