codename

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: 17 Imported by: 4

Documentation

Index

Constants

View Source
const MaxCodenameLength = 32

MaxCodenameLength is the maximum length, in bytes, that a codename can be.

Variables

This section is empty.

Functions

This section is empty.

Types

type CodeNamePart

type CodeNamePart struct {
	Lang      Language
	Generated string
}

type Identity

type Identity struct {
	PubKey ed25519.PublicKey

	Honorific CodeNamePart
	Adjective CodeNamePart
	Noun      CodeNamePart

	Codename  string
	Color     string
	Extension string

	CodesetVersion uint8
}

Identity is the public object describing all aspects of a channel definition

func ConstructIdentity

func ConstructIdentity(
	pub ed25519.PublicKey, codesetVersion uint8) (Identity, error)

ConstructIdentity creates a codename from an extant identity for a given version

func UnmarshalIdentity

func UnmarshalIdentity(data []byte) (Identity, error)

UnmarshalIdentity created an identity from a marshaled version

func (Identity) Marshal

func (i Identity) Marshal() []byte

Marshal creates an exportable version of the Identity.

type Language

type Language uint8

Language represents possible languages to generate code names from.

const (
	English Language = iota
)

type PrivateIdentity

type PrivateIdentity struct {
	Privkey ed25519.PrivateKey
	Identity
}

PrivateIdentity is a user's private identity on a channel. It contains their public identity and their private key.

func GenerateIdentity

func GenerateIdentity(rng io.Reader) (PrivateIdentity, error)

GenerateIdentity create a new channels identity from scratch and assigns it a codename

func ImportPrivateIdentity

func ImportPrivateIdentity(password string, data []byte) (PrivateIdentity, error)

ImportPrivateIdentity generates a new PrivateIdentity from exported data.

func UnmarshalPrivateIdentity

func UnmarshalPrivateIdentity(data []byte) (PrivateIdentity, error)

UnmarshalPrivateIdentity created a private identity from a marshaled version

func (PrivateIdentity) Export

func (i PrivateIdentity) Export(password string, csprng io.Reader) ([]byte, error)

Export exports the PrivateIdentity into a portable encrypted string that can be used to restore it later.

func (PrivateIdentity) GetDMToken

func (i PrivateIdentity) GetDMToken() uint32

GetDMToken returns the DM Token for this codename identity. TODO: This is not yet stored in the data model, which is why it is computed here and accessed through this function.

func (PrivateIdentity) Marshal

func (i PrivateIdentity) Marshal() []byte

Marshal creates en exportable version of the PrivateIdentity.

Jump to

Keyboard shortcuts

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