orchestrator

package
v0.1.0-testnet Latest Latest
Warning

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

Go to latest
Published: Jun 10, 2022 License: MPL-2.0 Imports: 14 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrAlreadyInitialized = errors.New("card is already initialized with a pin")
View Source
var ErrCardNotPairedToCard = errors.New("card not paired with any other card")
View Source
var ErrInitFailed = errors.New("card failed initialized check after init command accepted")
View Source
var ErrNoSession error = errors.New("No connected session with id found")
View Source
var ErrRemoteNotPaired error = errors.New("no remote card paired")
View Source
var ErrorRequestNotRecognized = errors.New("Unrecognized request sent to session")

Functions

This section is empty.

Types

type DepositConfirmation

type DepositConfirmation struct {
	Phonon           *model.Phonon
	ConfirmedOnChain bool
	ConfirmedOnCard  bool
}

Phonon Deposit and Redeem higher level methods

type PhononTerminal

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

func NewPhononTerminal

func NewPhononTerminal() *PhononTerminal

NewPhononTerminal returns a new reference to the global phonon terminal singleton.

func (*PhononTerminal) AddSession

func (t *PhononTerminal) AddSession(sess *Session)

func (*PhononTerminal) GenerateMock

func (t *PhononTerminal) GenerateMock() (string, error)

// basic multi-session management //

func (*PhononTerminal) ListSessions

func (t *PhononTerminal) ListSessions() []*Session

func (*PhononTerminal) RefreshSessions

func (t *PhononTerminal) RefreshSessions() ([]*Session, error)

func (*PhononTerminal) RemoveSession

func (t *PhononTerminal) RemoveSession(sessID string)

func (*PhononTerminal) SessionFromID

func (t *PhononTerminal) SessionFromID(id string) *Session

type Session

type Session struct {
	RemoteCard model.CounterpartyPhononCard

	Cert             *cert.CardCertificate
	ElementUsageMtex sync.Mutex
	// contains filtered or unexported fields
}

The session struct handles a local connection with a card Keeps a client side cache of the card state to make interaction with the card through this API more convenient

func NewSession

func NewSession(storage model.PhononCard) (s *Session, err error)

Creates a new card session, automatically connecting if the card is already initialized with a PIN The next step is to run VerifyPIN to gain access to the secure commands on the card

func (*Session) CardPair

func (s *Session) CardPair(initPairingData []byte) ([]byte, error)

func (*Session) CardPair2

func (s *Session) CardPair2(cardPairData []byte) (cardPair2Data []byte, err error)

func (*Session) ChangePIN

func (s *Session) ChangePIN(pin string) error

func (*Session) Connect

func (s *Session) Connect() error

Connect opens a secure channel with a card.

func (*Session) ConnectToCounterparty

func (s *Session) ConnectToCounterparty(cardID string) error

func (*Session) ConnectToLocalProvider

func (s *Session) ConnectToLocalProvider() error

func (*Session) ConnectToRemoteProvider

func (s *Session) ConnectToRemoteProvider(RemoteURL string) error

func (*Session) CreatePhonon

func (s *Session) CreatePhonon() (keyIndex uint16, pubkey model.PhononPubKey, err error)

func (*Session) DestroyPhonon

func (s *Session) DestroyPhonon(keyIndex uint16) (privKey *ecdsa.PrivateKey, err error)

func (*Session) FinalizeCardPair

func (s *Session) FinalizeCardPair(cardPair2Data []byte) error

func (*Session) FinalizeDepositPhonon

func (s *Session) FinalizeDepositPhonon(dc DepositConfirmation) error

func (*Session) FinalizeDepositPhonons

func (s *Session) FinalizeDepositPhonons(confirmations []DepositConfirmation) ([]DepositConfirmation, error)

func (*Session) GenerateInvoice

func (s *Session) GenerateInvoice() ([]byte, error)

func (*Session) GetCertificate

func (s *Session) GetCertificate() (*cert.CardCertificate, error)

func (*Session) GetName

func (s *Session) GetName() string

func (*Session) GetPhononPubKey

func (s *Session) GetPhononPubKey(keyIndex uint16, crv model.CurveType) (pubkey model.PhononPubKey, err error)

func (*Session) IdentifyCard

func (s *Session) IdentifyCard(nonce []byte) (cardPubKey *ecdsa.PublicKey, cardSig *util.ECDSASignature, err error)

func (*Session) Init

func (s *Session) Init(pin string) error

Initializes the card with a PIN Also creates a secure channel and verifies the PIN that was just set

func (*Session) InitCardPairing

func (s *Session) InitCardPairing(receiverCert cert.CardCertificate) ([]byte, error)

func (*Session) InitDepositPhonons

func (s *Session) InitDepositPhonons(currencyType model.CurrencyType, denoms []*model.Denomination) (phonons []*model.Phonon, err error)

InitDepositPhonons takes a currencyType and a map of denominations to quantity, Creates the required phonons, deposits them using the configured service for the asset and upon success sets their descriptors

func (*Session) IsInitialized

func (s *Session) IsInitialized() bool

func (*Session) IsPairedToCard

func (s *Session) IsPairedToCard() bool

func (*Session) IsUnlocked

func (s *Session) IsUnlocked() bool

func (*Session) ListPhonons

func (s *Session) ListPhonons(currencyType model.CurrencyType, lessThanValue uint64, greaterThanValue uint64) ([]*model.Phonon, error)

func (*Session) PairWithRemoteCard

func (s *Session) PairWithRemoteCard(remoteCard model.CounterpartyPhononCard) error

func (*Session) ReceiveInvoice

func (s *Session) ReceiveInvoice(invoiceData []byte) error

func (*Session) ReceivePhonons

func (s *Session) ReceivePhonons(phononTransferPacket []byte) error

func (*Session) RedeemPhonon

func (s *Session) RedeemPhonon(p *model.Phonon, redeemAddress string) (transactionData string, privKeyString string, err error)

RedeemPhonon takes a phonon and a redemptionAddress as an asset specific address string (usually hex encoded) and submits a transaction to the asset's chain in order to transfer it to another address In case the on chain transfer fails, returns the private key as a fallback so that access to the asset is not lost

func (*Session) SendPhonons

func (s *Session) SendPhonons(keyIndices []uint16) error

func (*Session) SetDescriptor

func (s *Session) SetDescriptor(p *model.Phonon) error

func (*Session) SetPaired

func (s *Session) SetPaired(status bool)

func (*Session) VerifyPIN

func (s *Session) VerifyPIN(pin string) error

Jump to

Keyboard shortcuts

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