badger

package module
v0.0.0-...-535f907 Latest Latest
Warning

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

Go to latest
Published: Aug 4, 2024 License: MIT Imports: 20 Imported by: 0

README

badger

Documentation

Index

Constants

View Source
const (
	VoucherVersionId = 1
)

Variables

This section is empty.

Functions

func GenerateId

func GenerateId() (string, error)

func GenerateTLS

func GenerateTLS() (serverTLSConf *tls.Config, err error)

func Hash

func Hash(raw []byte) ([]byte, error)

func LoadTLS

func LoadTLS(key, cert string, doGenOnFail bool) (*tls.Config, error)

func MarshalPublicKey

func MarshalPublicKey(x *big.Int, y *big.Int) []byte

func NewVoucher

func NewVoucher(badge Badge, expiration time.Duration) (string, error)

func RawIsHashMatch

func RawIsHashMatch(raw []byte, hashed []byte) error

func ToFormattedString

func ToFormattedString(badge Badge) string

func UnmarshalPublicKey

func UnmarshalPublicKey(publicKey []byte) ecdsa.PublicKey

func ValidateVoucher

func ValidateVoucher(publicKey string, voucher string) bool

func Verify

func Verify(phs PubHashSig) bool

Types

type Badge

type Badge interface {
	Id() string
	Nickname() string

	Sign(data *string) (PubHashSig, error)

	GenerateVoucher(expiration time.Duration) (string, error)
	ValidateVoucher(voucher string) bool

	PublicKey() string
	EncodeIdentity() EncodedIdentity
	EncodeIdentityString() string
}

func DecodeIdentity

func DecodeIdentity(eid EncodedIdentity) (Badge, error)

func DecodeIdentityString

func DecodeIdentityString(encodedId string) (Badge, error)

func New

func New(nickname string) (Badge, error)

type EncodedIdentity

type EncodedIdentity struct {
	Id         string `json:id`
	Nickname   string `json:nickname`
	PublicKey  string `json:public_key`
	PrivateKey string `json:private_key`
}

type PubHashSig

type PubHashSig struct {
	PubKey []byte
	Hash   []byte
	Sig    []byte
}

type VoucherBody

type VoucherBody struct {
	Issuer     string
	Issued     time.Time
	Expiration time.Time
}

type VoucherHeader

type VoucherHeader struct {
	Version int
}

type VoucherInfo

type VoucherInfo struct {
	Hash []byte
	Sig  []byte
}

Jump to

Keyboard shortcuts

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