session

package
v0.1.20 Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2023 License: Unlicense Imports: 13 Imported by: 0

Documentation

Overview

Package session provides an onion message type that delivers the two session private keys to be associated with a session, for which the hash of the secrets was used as the payment preimage for starting a session.

Topping up sessions does not require following up with this message as the handler finds the session and adjusts the balance according to the payment.

Index

Constants

View Source
const (
	Magic = "sess"
	Len   = magic.Len + nonce.IDLen + crypto.PrvKeyLen*2
)

Variables

This section is empty.

Functions

func Gen

func Gen() codec.Codec

Gen is a factory function for a Session.

func New

func New(hop byte) (x ont.Onion)

New creates a new Session, including generating new keys for it.

Types

type Session

type Session struct {

	// ID is an identifier only used by the client.
	ID nonce.ID

	// Hop is the position in the circuit this session is used, also private to the client.
	Hop byte

	// Header and Payload are the crypto.Keys based on the two private keys used for
	// the session (and hashed into the preimage).
	Header, Payload *crypto.Keys

	// Onion is the rest of the message, which usually will be some number more
	// Session/Crypt layers.
	ont.Onion
}

Session is the delivery of the two client defined private keys that a relay uses to identify and encrypt/decrypt messages related to a session.

func (*Session) Account

func (x *Session) Account(res *sess.Data, sm *sess.Manager, s *sessions.Data,
	last bool) (skip bool, sd *sessions.Data)

Account for the Session message - in this case, this is the one exception to the rule all messages must have sessions to relay, which is usually what is inside Session Onion fields as well up to the return confirmation layer.

func (*Session) Decode

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

Decode a Session from a provided splice.Splice.

func (*Session) Encode

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

Encode a Session into the next bytes of a splice.Splice.

func (*Session) Handle

func (x *Session) Handle(s *splice.Splice, p ont.Onion, ng ont.Ngin) (e error)

Handle is the relay logic for an engine handling a Session message.

If the relay finds a pending payment it will forward the next part of the onion, otherwise not. This is the only onion that relaying isn't charged for because it establishes the account.

func (*Session) Len

func (x *Session) Len() int

Len returns the length of this Session message.

func (*Session) Magic

func (x *Session) Magic() string

Magic is the identifying 4 byte string indicating a Session message follows.

func (*Session) PreimageHash

func (x *Session) PreimageHash() sha256.Hash

PreimageHash returns the preimage to use in a LN payment to associate to this session.

func (*Session) Unwrap

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

Unwrap returns the onion inside this Session.

func (*Session) Wrap

func (x *Session) Wrap(inner ont.Onion)

Wrap puts another onion inside this Reverse onion.

Jump to

Keyboard shortcuts

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