store

package
v4.7.2 Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2024 License: BSD-2-Clause, BSD-2-Clause Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const NoRequestFound = "no request found"

Variables

This section is empty.

Functions

This section is empty.

Types

type FingerprintType

type FingerprintType uint
const (
	General  FingerprintType = 1
	Specific FingerprintType = 2
)

type ReceivedRequest

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

func (*ReceivedRequest) GetContact

func (rr *ReceivedRequest) GetContact() contact.Contact

func (*ReceivedRequest) GetRound

func (rr *ReceivedRequest) GetRound() rounds.Round

func (*ReceivedRequest) GetTheirSidHPubKeyA

func (rr *ReceivedRequest) GetTheirSidHPubKeyA() *sidh.PublicKey

type RequestType

type RequestType uint
const (
	Sent    RequestType = 1
	Receive RequestType = 2
)

type SentRequest

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

func (*SentRequest) GetFingerprint

func (sr *SentRequest) GetFingerprint() format.Fingerprint

func (*SentRequest) GetMyPrivKey

func (sr *SentRequest) GetMyPrivKey() *cyclic.Int

func (*SentRequest) GetMyPubKey

func (sr *SentRequest) GetMyPubKey() *cyclic.Int

func (*SentRequest) GetMySIDHPrivKey

func (sr *SentRequest) GetMySIDHPrivKey() *sidh.PrivateKey

func (*SentRequest) GetMySIDHPubKey

func (sr *SentRequest) GetMySIDHPubKey() *sidh.PublicKey

func (*SentRequest) GetPartner

func (sr *SentRequest) GetPartner() *id.ID

func (*SentRequest) GetPartnerHistoricalPubKey

func (sr *SentRequest) GetPartnerHistoricalPubKey() *cyclic.Int

func (*SentRequest) IsReset

func (sr *SentRequest) IsReset() bool

func (*SentRequest) OverwriteSIDHKeys

func (sr *SentRequest) OverwriteSIDHKeys(priv *sidh.PrivateKey,
	pub *sidh.PublicKey)

OverwriteSIDHKeys is used to temporarily overwrite sidh keys to handle e.g., confirmation receivedByID. FIXME: this is a code smell but was the cleanest solution at the time. Business logic should probably handle this better?

type SentRequestHandler

type SentRequestHandler interface {
	Add(sr *SentRequest)
	Delete(sr *SentRequest)
}

SentRequestHandler allows the lower level to assign and remove services

type Store

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

func NewOrLoadStore

func NewOrLoadStore(kv versioned.KV, grp *cyclic.Group, srh SentRequestHandler) (*Store, error)

NewOrLoadStore loads an extant new store. All passed in private keys are added as sentByFingerprints so they can be used to trigger receivedByID. If no store can be found, it creates a new one

func (*Store) AddReceived

func (s *Store) AddReceived(c contact.Contact, key *sidh.PublicKey,
	round rounds.Round) error

func (*Store) AddSent

func (s *Store) AddSent(partner *id.ID, partnerHistoricalPubKey, myPrivKey,
	myPubKey *cyclic.Int, sidHPrivA *sidh.PrivateKey,
	sidHPubA *sidh.PublicKey, fp format.Fingerprint,
	reset bool) (*SentRequest, error)

func (*Store) CheckIfNegotiationIsNew

func (s *Store) CheckIfNegotiationIsNew(partner *id.ID, negotiationFingerprint []byte) (
	newFingerprint bool, position uint)

CheckIfNegotiationIsNew adds a new negotiation fingerprint if it is new. If the partner does not exist, it will add it and the new fingerprint and return newFingerprint = true. If the partner exists and the fingerprint does not exist, add it adds it as the latest fingerprint and returns newFingerprint = true, If the partner exists and the fingerprint exists, return newFingerprint = false in all cases it will return the position of the fingerprint, with the newest always at position 0

func (*Store) DeleteAllRequests

func (s *Store) DeleteAllRequests() error

DeleteAllRequests clears the request map and all associated storage objects containing request data.

func (*Store) DeleteConfirmation

func (s *Store) DeleteConfirmation(partner *id.ID) error

DeleteConfirmation deletes the confirmation for the given partner and fingerprint from storage.

func (*Store) DeleteReceiveRequests

func (s *Store) DeleteReceiveRequests() error

DeleteReceiveRequests deletes all Receive receivedByID from Store.

func (*Store) DeleteReceivedRequest

func (s *Store) DeleteReceivedRequest(partner *id.ID) error

DeleteReceivedRequest deletes the received request for the given partnerID pair.

func (*Store) DeleteRequest

func (s *Store) DeleteRequest(partner *id.ID) error

DeleteRequest deletes a request from Store given a partner ID. If the partner ID exists as a request, then the request will be deleted and the state stored. If the partner does not exist, then an error will be returned.

func (*Store) DeleteSentRequest

func (s *Store) DeleteSentRequest(partner *id.ID) error

DeleteSentRequest deletes the sent request for the given partnerID pair.

func (*Store) DeleteSentRequests

func (s *Store) DeleteSentRequests() error

DeleteSentRequests deletes all Sent receivedByID from Store.

func (*Store) GetAllReceivedRequests

func (s *Store) GetAllReceivedRequests() []*ReceivedRequest

GetAllReceivedRequests returns a slice of all recieved requests.

func (*Store) GetReceivedRequest

func (s *Store) GetReceivedRequest(partner *id.ID) (contact.Contact, error)

GetReceivedRequest returns the contact representing the partner request if it exists. It does not take the lock. It is only meant to return the contact to an external API user.

func (*Store) HandleReceivedRequest

func (s *Store) HandleReceivedRequest(partner *id.ID, handler func(*ReceivedRequest) error) error

HandleReceivedRequest handles the request singly, only a single operator operates on the same request at a time. It will delete the request if no error is returned from the handler

func (*Store) HandleSentRequest

func (s *Store) HandleSentRequest(partner *id.ID, handler func(request *SentRequest) error) error

HandleSentRequest handles the request singly, only a single operator operates on the same request at a time. It will delete the request if no error is returned from the handler

func (*Store) LoadConfirmation

func (s *Store) LoadConfirmation(partner *id.ID) (
	[]byte, []byte, format.Fingerprint, error)

LoadConfirmation loads the confirmation for the given partner and fingerprint from storage.

func (*Store) StoreConfirmation

func (s *Store) StoreConfirmation(partner *id.ID,
	confirmationPayload, mac []byte, fp format.Fingerprint) error

StoreConfirmation saves the confirmation to storage for the given partner and fingerprint.

Jump to

Keyboard shortcuts

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