sub

package
v1.2.2 Latest Latest
Warning

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

Go to latest
Published: Jan 4, 2022 License: AGPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SubAddressLen = 32
	SubAddrPrefix = "NJ"
)

Variables

View Source
var (
	ErrInvalidAddr = fmt.Errorf("invalid sub address")
)

Functions

func GenerateAesKey

func GenerateAesKey(peerAddr SubAddr, key ed25519.PrivateKey) ([]byte, error)

func PrivateKeyToCurve25519

func PrivateKeyToCurve25519(curve25519Private *[32]byte, privateKey *[64]byte)

func PublicKeyToCurve25519

func PublicKeyToCurve25519(curve25519Public *[32]byte, publicKey *[32]byte) bool

func SubAddrToPub

func SubAddrToPub(a SubAddr) (ed25519.PublicKey, error)

func VerifyBySub

func VerifyBySub(msg, sig []byte, addr SubAddr) bool

Types

type SubAddr

type SubAddr [SubAddressLen]byte

func HexToSubAddr

func HexToSubAddr(s string) (addr SubAddr, err error)

func PubKeyToSubAddr

func PubKeyToSubAddr(p ed25519.PublicKey) (addr SubAddr)

func (*SubAddr) Hex

func (a *SubAddr) Hex() string

func (*SubAddr) MarshalText

func (a *SubAddr) MarshalText() ([]byte, error)

func (*SubAddr) String

func (a *SubAddr) String() string

func (*SubAddr) UnmarshalJSON

func (a *SubAddr) UnmarshalJSON(data []byte) error

type SubKey

type SubKey struct {
	ID      uuid.UUID
	Light   bool
	Address SubAddr
	// contains filtered or unexported fields
}

func DecryptSubKey

func DecryptSubKey(keyJson []byte, auth string) (*SubKey, error)

func LoadSubKeyFromJsonStr

func LoadSubKeyFromJsonStr(str, auth string) (*SubKey, error)

func NewLightSubKey

func NewLightSubKey(light bool) (*SubKey, error)

func NewSubKey

func NewSubKey() (*SubKey, error)

func (*SubKey) Addr

func (k *SubKey) Addr() string

func (*SubKey) Encrypt

func (k *SubKey) Encrypt(auth string) ([]byte, error)

func (*SubKey) GetPrivate

func (k *SubKey) GetPrivate() []byte

func (*SubKey) IDStr

func (k *SubKey) IDStr() string

func (*SubKey) IsOpen

func (k *SubKey) IsOpen() bool

func (*SubKey) PriLen

func (k *SubKey) PriLen() int

func (*SubKey) SharedKey

func (k *SubKey) SharedKey(peer string) ([]byte, error)

func (*SubKey) SignData

func (k *SubKey) SignData(v []byte) []byte

func (*SubKey) StoreString

func (k *SubKey) StoreString(auth string) string

Jump to

Keyboard shortcuts

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