core

package module
v0.0.0-...-6560cc6 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2022 License: ISC Imports: 15 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BlockID

func BlockID(fileID string, index int) string

BlockID returns the block id for a public key

func Decrypt

func Decrypt(key []byte, data []byte) ([]byte, error)

Decrypt retuns decrypted plain text

func Encrypt

func Encrypt(key []byte, data []byte) ([]byte, error)

Encrypt returns encrypted cipher text

func FileID

func FileID(publicKey *secp256k1.PublicKey, salt []byte) string

FileID returns the file id for a public key

func GetMnemonic

func GetMnemonic() (string, error)

GetMnemonic returns a randomly generated mnemonic seed

func GetPrivateKeyFromHDKey

func GetPrivateKeyFromHDKey(key *hdkeychain.ExtendedKey) (*secp256k1.PrivateKey, error)

GetPrivateKeyFromHDKey returns the private key for an extended key

func GetPublicKeyFromHDKey

func GetPublicKeyFromHDKey(key *hdkeychain.ExtendedKey) (*secp256k1.PublicKey, error)

GetPublicKeyFromHDKey returns the public key for an extended key

func GetRootFolder

func GetRootFolder(mnemonic string, password string) (string, *hdkeychain.ExtendedKey, error)

GetRootFolder returns a root extended key from mnemonic and password

func GetRootFolderFromKey

func GetRootFolderFromKey(key string) (*hdkeychain.ExtendedKey, error)

GetRootFolderFromKey retuns the root extended key

func KeyID

func KeyID(publicKey *secp256k1.PublicKey) string

KeyID returns the key id for a public key

func NewRootFolder

func NewRootFolder(password string) (string, *hdkeychain.ExtendedKey, error)

NewRootFolder returns a new random root extended key and mnemonic

func OwnershipPrivateKey

func OwnershipPrivateKey(hdkey *hdkeychain.ExtendedKey, version uint32) (*secp256k1.PrivateKey, error)

OwnershipPrivateKey returns the private key for a given version

func OwnershipPublicKey

func OwnershipPublicKey(hdkey *hdkeychain.ExtendedKey, version uint32) (*secp256k1.PublicKey, error)

OwnershipPublicKey returns the public key for a given version

func RandomBytes

func RandomBytes(n int) ([]byte, error)

RandomBytes returns an array of random bytes for a given length

func RecreateFile

func RecreateFile(blocks []Block) []byte

RecreateFile ...

Types

type Block

type Block struct {
	Data    []byte
	Padding int
	Count   int
	// contains filtered or unexported fields
}

Block Object

func CreateBlocks

func CreateBlocks(fileID string, data []byte, size int) []Block

CreateBlocks ...

func (Block) Encrypt

func (b Block) Encrypt(key []byte) (EncryptedBlock, error)

Encrypt ...

type EncryptedBlock

type EncryptedBlock struct {
	ID   string
	Data []byte
}

EncryptedBlock Object

func CreateEncryptedBlocks

func CreateEncryptedBlocks(fileID string, key []byte, data []byte, size int) (encryptedBlocks []EncryptedBlock, err error)

CreateEncryptedBlocks ...

func (EncryptedBlock) Decrypt

func (b EncryptedBlock) Decrypt(key []byte) (Block, error)

Decrypt ...

type File

type File struct {
	Key        *hdkeychain.ExtendedKey
	KeyFile    KeyFile
	MetaBlocks []EncryptedBlock
	FileBlocks []EncryptedBlock
}

File ...

func CreateFile

func CreateFile(parent *hdkeychain.ExtendedKey, index uint32, meta Meta, data []byte, size int, version uint32) (File, error)

CreateFile returns a file object

func CreateFolder

func CreateFolder(parent *hdkeychain.ExtendedKey, index uint32, meta Meta, size int) (File, error)

CreateFolder ...

type KeyFile

type KeyFile struct {
	Version   []byte
	MetaSalt  []byte
	FileSalt  []byte
	EphemKey  []byte
	Signature []byte
	// contains filtered or unexported fields
}

KeyFile ...

func CreateKeyFile

func CreateKeyFile(hdkey *hdkeychain.ExtendedKey, version uint32) (KeyFile, error)

CreateKeyFile returns a new key file for an extended key

func ParseKeyFile

func ParseKeyFile(hdkey *hdkeychain.ExtendedKey, data []byte) (KeyFile, error)

ParseKeyFile returns a parsed key file

func (*KeyFile) Decrypt

func (f *KeyFile) Decrypt() KeyFile

Decrypt returns the decrypted key file

func (*KeyFile) Encrypt

func (f *KeyFile) Encrypt() KeyFile

Encrypt returns the encrypted key file

func (*KeyFile) File

func (f *KeyFile) File() *hdkeychain.ExtendedKey

File returns the file struct

func (*KeyFile) GetVersion

func (f *KeyFile) GetVersion() (uint32, error)

GetVersion returns the version of the key file

func (*KeyFile) ID

func (f *KeyFile) ID() (string, error)

ID returns the key id

func (*KeyFile) Key

func (f *KeyFile) Key() []byte

Key returns the key file encryption key

func (*KeyFile) MissingData

func (f *KeyFile) MissingData() bool

MissingData returns true if fields are missing from key file

func (*KeyFile) PublicKey

func (f *KeyFile) PublicKey() (*secp256k1.PublicKey, error)

PublicKey returns the public key for the key file

func (*KeyFile) Serialise

func (f *KeyFile) Serialise() ([]byte, error)

Serialise returns the marshalled key file

func (*KeyFile) Verify

func (f *KeyFile) Verify() (bool, error)

Verify returns true if the signature is valid

type Meta

type Meta struct {
	Name string   `json:"Name"`
	Type string   `json:"Type"`
	Tags []string `json:"Tags"`
}

Meta ...

func ParseMeta

func ParseMeta(data []byte) (Meta, error)

ParseMeta ...

Jump to

Keyboard shortcuts

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