contact

package
v0.0.9 Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2023 License: BSD-2-Clause Imports: 13 Imported by: 33

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Equal

func Equal(a, b Contact) bool

Equal determines if the two contacts have the same values.

func ReadContactFromFile

func ReadContactFromFile(contactFileData []byte) ([]byte, []byte, error)

ReadContact reads and unmarshal the contact from file and returns the marshaled ID and DH public key.

Types

type Contact

type Contact struct {
	ID             *id.ID
	DhPubKey       *cyclic.Int
	OwnershipProof []byte
	Facts          fact.FactList
}

Contact implements the Contact interface defined in interface/contact.go, in go, the structure is meant to be edited directly, the functions are for bindings compatibility.

func Unmarshal

func Unmarshal(b []byte) (Contact, error)

Unmarshal decodes the byte slice produced by Contact.Marshal into a Contact.

func (Contact) GetChecksum

func (c Contact) GetChecksum() []byte

GetChecksum generates a 16-byte checksum of the Contact.

func (Contact) GetChecksumVer1

func (c Contact) GetChecksumVer1() []byte

GetChecksum generates a 16-byte checksum of the Contact.

func (Contact) GetFingerprint

func (c Contact) GetFingerprint() string

GetFingerprint creates a 15 character long fingerprint of the contact off of the ID and DH public key.

func (Contact) MakeQR

func (c Contact) MakeQR(size int, level qrcode.RecoveryLevel) ([]byte, error)

MakeQR generates a QR code PNG of the Contact.

func (Contact) Marshal

func (c Contact) Marshal() []byte

Marshal saves the Contact in a compact binary format with base 64 encoding. The data has a header and footer that specify the format version and allow the data to be recognized in a stream of data. The format has the following structure.

+----------------+---------------------------------------------------------------------------------------------------+--------+ | header | contact data | footer | +------+---------+----------+----------+----------+-----------------+----------------+---------+----------+----------+--------+ | Open | | ID | DhPubKey | | OwnershipProof | | Facts | | checksum | Close | | Tag | Version | | size | DhPubKey | size | OwnershipProof | size | FactList | | Tag | | | | 33 bytes | 2 bytes | | 2 bytes | | 2 bytes | | 16 bytes | | +------+---------+----------+----------+----------+-----------------+----------------+---------+----------+----------+--------+ | string | base 64 encoded | string | +----------------+---------------------------------------------------------------------------------------------------+--------+

func (Contact) String

func (c Contact) String() string

String prints a string representation of the Contact for debugging and tests. This functions satisfies the fmt.Stringer interface.

Jump to

Keyboard shortcuts

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