encrypt

package
v0.8.0-beta.2 Latest Latest
Warning

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

Go to latest
Published: May 14, 2018 License: ISC, ISC Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PublicKeySize   = ed25519.PublicKeySize
	PrivateKeySize  = ed25519.PrivateKeySize
	PublicKeyOffset = PrivateKeySize - PublicKeySize
)

Variables

View Source
var (
	ErrInvalidPrivateKey      = fault.InvalidError("invalid private key")
	ErrKeyLength              = fault.InvalidError("key length is invalid")
	ErrNotFoundIdentity       = fault.NotFoundError("identity name not found")
	ErrUnableToRegenerateKeys = fault.InvalidError("unable to regenerate keys")
	ErrWrongPassword          = fault.InvalidError("wrong password")
)
View Source
var (
	ErrUnmarshalTextFail = fault.ProcessError("unmarshal text failed")
)

Functions

func MakeKeyPair

func MakeKeyPair(privateKeyStr string, password string, test bool) (*EncryptedKeyPair, *PrivateKeyConfig, error)

create a new public/private keypair note: private key string must be either:

  • 64 bytes = [32 byte private key][32 byte public key]
  • 32 bytes = [32 byte private key]
  • "SEED:<base58 encoded seed>"

func PublicKeyFromIdentity

func PublicKeyFromIdentity(name string, identities []IdentityType) (*keypair.KeyPair, error)

func VerifyPassword

func VerifyPassword(password string, identity *IdentityType) (*keypair.KeyPair, error)

Types

type EncryptedKeyPair

type EncryptedKeyPair struct {
	PublicKey           string
	EncryptedPrivateKey string
	EncryptedSeed       string
}

return of makeKeyPair

type IdentityType

type IdentityType struct {
	Name               string           `libucl:"name" json:"name"`
	Description        string           `libucl:"description" json:"description"`
	Public_key         string           `libucl:"public_key" json:"public_key"`
	Private_key        string           `libucl:"private_key" json:"private_key"`
	Seed               string           `libucl:"seed" json:"seed"`
	Private_key_config PrivateKeyConfig `libucl:"private_key_config" json:"private_key_config"`
}

full access to data (includes private data)

type PrivateKeyConfig

type PrivateKeyConfig struct {
	Salt string `libucl:"salt" json:"salt"`
}

type Salt

type Salt [saltSize]byte

func MakeSalt

func MakeSalt() (*Salt, error)

func (Salt) Bytes

func (salt Salt) Bytes() []byte

convert a binary salt to byte slice

func (*Salt) MarshalText

func (salt *Salt) MarshalText() []byte

convert salt to little endian hex text

***** possibly use NewEncoder and byte buffer to save copy

func (Salt) String

func (salt Salt) String() string

convert a binary salt to little endian hex string for use by the fmt package (for %s)

func (*Salt) UnmarshalText

func (salt *Salt) UnmarshalText(s []byte) error

convert little endian hex text into a salt

Jump to

Keyboard shortcuts

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