model

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: 3

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidDenomination = errors.New("value cannot be represented as a phonon denomination")

Functions

func PhononPubKeyToECDSA

func PhononPubKeyToECDSA(pubKey PhononPubKey) (*ecdsa.PublicKey, error)

Convenience function to easily convert PhononPublicKeys to their underyling concrete type when possible

Types

type CounterpartyPhononCard

type CounterpartyPhononCard interface {
	GetCertificate() (*cert.CardCertificate, error)
	CardPair(initPairingData []byte) (cardPairData []byte, err error)
	CardPair2(cardPairData []byte) (cardPairData2 []byte, err error)
	FinalizeCardPair(cardPair2Data []byte) error
	ReceivePhonons(phononTransfer []byte) error
	GenerateInvoice() (invoiceData []byte, err error)
	ReceiveInvoice(invoiceData []byte) error
	VerifyPaired() error
	PairingStatus() RemotePairingStatus
	ConnectToCard(string) error
}

type CurrencyType

type CurrencyType uint16
const (
	Unspecified CurrencyType = 0x0000
	Bitcoin     CurrencyType = 0x0001
	Ethereum    CurrencyType = 0x0002
	Native      CurrencyType = 0x0003
)

func (CurrencyType) String

func (i CurrencyType) String() string

type CurveType

type CurveType uint8
const (
	Secp256k1 CurveType = iota
	NativeCurve
	Unknown = 0xFF
)

func (CurveType) String

func (i CurveType) String() string

type Denomination

type Denomination struct {
	Base     uint8
	Exponent uint8
}

func NewDenomination

func NewDenomination(i *big.Int) (Denomination, error)

NewDenomination takes an integer input and attempts to store it as a compressible value representing currency base units Precision is limited to significant digits no greater than the value 255, along with exponentiation up to 255 digits

func (*Denomination) MarshalJSON

func (d *Denomination) MarshalJSON() ([]byte, error)

Marshal denominations as strings

func (Denomination) String

func (d Denomination) String() string

func (*Denomination) UnmarshalJSON

func (d *Denomination) UnmarshalJSON(b []byte) error

Unmarshal Denominations from string to internal representation

func (Denomination) Value

func (d Denomination) Value() *big.Int

type ECCPubKey

type ECCPubKey struct {
	PubKey *ecdsa.PublicKey
}

func (*ECCPubKey) Bytes

func (pubKey *ECCPubKey) Bytes() []byte

func (*ECCPubKey) Decode

func (pubKey *ECCPubKey) Decode(data []byte) (pk PhononPubKey, err error)

func (*ECCPubKey) Equal

func (pubKey *ECCPubKey) Equal(x PhononPubKey) bool

func (*ECCPubKey) String

func (pubKey *ECCPubKey) String() string

type NativePubKey

type NativePubKey struct {
	Hash []byte
}

func (*NativePubKey) Bytes

func (nat *NativePubKey) Bytes() []byte

func (*NativePubKey) Decode

func (nat *NativePubKey) Decode(data []byte) (pk PhononPubKey, err error)

func (*NativePubKey) Equal

func (nat *NativePubKey) Equal(x PhononPubKey) bool

func (*NativePubKey) String

func (nat *NativePubKey) String() string

type Phonon

type Phonon struct {
	KeyIndex              uint16
	PubKey                PhononPubKey
	CurveType             CurveType
	SchemaVersion         uint8
	ExtendedSchemaVersion uint8
	Denomination          Denomination
	CurrencyType          CurrencyType
	ChainID               int
	ExtendedTLV           tlv.TLVList
	Address               string //chain specific attribute not stored on card
	AddressType           uint8  //chain specific address type identifier
}

func (*Phonon) MarshalJSON

func (p *Phonon) MarshalJSON() ([]byte, error)

func (*Phonon) String

func (p *Phonon) String() string

func (*Phonon) UnmarshalJSON

func (p *Phonon) UnmarshalJSON(b []byte) error

Unmarshals a PhononUserView into an internal phonon representation

type PhononCard

type PhononCard interface {
	Select() (instanceUID []byte, cardPubKey *ecdsa.PublicKey, cardInitialized bool, err error)
	Pair() (*cert.CardCertificate, error)
	OpenSecureChannel() error
	OpenSecureConnection() error
	Init(pin string) error
	IdentifyCard(nonce []byte) (cardPubKey *ecdsa.PublicKey, cardSig *util.ECDSASignature, err error)
	VerifyPIN(pin string) error
	ChangePIN(pin string) error
	CreatePhonon(curveType CurveType) (keyIndex uint16, pubKey PhononPubKey, err error)
	SetDescriptor(phonon *Phonon) error
	ListPhonons(currencyType CurrencyType, lessThanValue uint64, greaterThanValue uint64, continuation bool) ([]*Phonon, error)
	GetPhononPubKey(keyIndex uint16, crv CurveType) (pubkey PhononPubKey, err error)
	DestroyPhonon(keyIndex uint16) (privKey *ecdsa.PrivateKey, err error)
	SendPhonons(keyIndices []uint16, extendedRequest bool) (transferPhononPackets []byte, err error)
	ReceivePhonons(phononTransfer []byte) error
	SetReceiveList(phononPubKeys []*ecdsa.PublicKey) error
	TransactionAck(keyIndices []uint16) error
	InitCardPairing(receiverCertificate cert.CardCertificate) (initPairingData []byte, err error)
	CardPair(initPairingData []byte) (cardPairData []byte, err error)
	CardPair2(cardPairData []byte) (cardPair2Data []byte, err error)
	FinalizeCardPair(cardPair2Data []byte) (err error)
	InstallCertificate(signKeyFunc func([]byte) ([]byte, error)) (err error)
	GenerateInvoice() (invoiceData []byte, err error)
	ReceiveInvoice(invoiceData []byte) (err error)
	SetFriendlyName(name string) error
	GetFriendlyName() (string, error)
	GetAvailableMemory() (persistentMem int, onResetMem int, onDeselectMem int, err error)
	MineNativePhonon(difficulty uint8) (keyIndex uint16, hash []byte, err error)
}

type PhononJSON

type PhononJSON struct {
	KeyIndex              uint16
	PubKey                string //pubkey as hexstring
	Address               string //Chain specific address as hexstring
	AddressType           uint8
	SchemaVersion         uint8
	ExtendedSchemaVersion uint8
	Denomination          Denomination
	CurrencyType          int
	ChainID               int
	CurveType             uint8
}

Phonon data structured for display to the user and use in frontends

type PhononPubKey

type PhononPubKey interface {
	Decode([]byte) (PhononPubKey, error)
	String() string
	Bytes() []byte
	Equal(PhononPubKey) bool
}

func NewPhononPubKey

func NewPhononPubKey(rawPubKey []byte, crv CurveType) (pubKey PhononPubKey, err error)

NewPhononPubKey parses raw public key data into the assigned PhononPubKey interface based on the given CurveType

type RemotePairingStatus

type RemotePairingStatus int
const (
	StatusUnconnected RemotePairingStatus = iota
	StatusConnectedToBridge
	StatusConnectedToCard
	StatusCardPair1Complete
	StatusCardPair2Complete
	StatusPaired
)

type RequestCardPair1

type RequestCardPair1 struct {
	Ret     chan ResponseCardPair1
	Payload []byte
}

func (*RequestCardPair1) GetName

func (*RequestCardPair1) GetName() string

type RequestCertificate

type RequestCertificate struct {
	Ret chan ResponseCertificate
}

func (*RequestCertificate) GetName

func (*RequestCertificate) GetName() string

type RequestFinalizeCardPair

type RequestFinalizeCardPair struct {
	Ret     chan ResponseFinalizeCardPair
	Payload []byte
}

func (*RequestFinalizeCardPair) GetName

func (*RequestFinalizeCardPair) GetName() string

type RequestGetName

type RequestGetName struct {
	Ret chan ResponseGetName
}

func (*RequestGetName) GetName

func (*RequestGetName) GetName() string

type RequestIdentifyCard

type RequestIdentifyCard struct {
	Ret   chan ResponseIdentifyCard
	Nonce []byte
}

func (*RequestIdentifyCard) GetName

func (*RequestIdentifyCard) GetName() string

type RequestPairWithRemote

type RequestPairWithRemote struct {
	Ret  chan ResponsePairWithRemote
	Card CounterpartyPhononCard
}

func (*RequestPairWithRemote) GetName

func (*RequestPairWithRemote) GetName() string

type RequestReceivePhonons

type RequestReceivePhonons struct {
	Ret     chan ResponseReceivePhonons
	Payload []byte
}

func (*RequestReceivePhonons) GetName

func (*RequestReceivePhonons) GetName() string

type RequestSetPaired

type RequestSetPaired struct {
	Ret    chan ResponseSetPaired
	Status bool
}

func (*RequestSetPaired) GetName

func (*RequestSetPaired) GetName() string

type RequestSetRemote

type RequestSetRemote struct {
	Ret  chan ResponseSetRemote
	Card CounterpartyPhononCard
}

func (*RequestSetRemote) GetName

func (*RequestSetRemote) GetName() string

type ResponseCardPair1

type ResponseCardPair1 struct {
	Err     error
	Payload []byte
}

type ResponseCertificate

type ResponseCertificate struct {
	Err     error
	Payload *cert.CardCertificate
}

type ResponseFinalizeCardPair

type ResponseFinalizeCardPair struct {
	Err error
}

type ResponseGetName

type ResponseGetName struct {
	Err  error
	Name string
}

type ResponseIdentifyCard

type ResponseIdentifyCard struct {
	PubKey *ecdsa.PublicKey
	Sig    *util.ECDSASignature
	Err    error
}

type ResponsePairWithRemote

type ResponsePairWithRemote struct {
	Err error
}

type ResponseReceivePhonons

type ResponseReceivePhonons struct {
	Err error
}

type ResponseSetPaired

type ResponseSetPaired struct {
	Err error
}

type ResponseSetRemote

type ResponseSetRemote struct {
	Err error
}

type SessionRequest

type SessionRequest interface {
	GetName() string
}

Jump to

Keyboard shortcuts

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