utils

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2025 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MiB           = 1024 * 1024
	SEGMENT_SIZE  = 32 * MiB
	FRAGMENT_SIZE = 8 * MiB
	FRAGMENTS_NUM = 4
	PARITY_NUM    = 8
)
View Source
const (
	ARCHIVER_FORMAT_ZIP   = "zip"
	ARCHIVER_FORMAT_TAR   = "tar"
	ARCHIVER_FORMAT_TARGZ = "tar.gz"

	UNNAMED_FILENAME = "Unnamed"
)
View Source
const (
	MAINNET_FORMAT = 11331
	TESTNET_FORMAT = 11330
)

Variables

This section is empty.

Functions

func AesDecrypt

func AesDecrypt(data, key, nonce []byte) ([]byte, error)

func AesEncrypt

func AesEncrypt(data, key, nonce []byte) ([]byte, error)

func CalcSHA256

func CalcSHA256(data []byte) (string, error)

func CalcSha256Hash

func CalcSha256Hash(datas ...[]byte) []byte

func CopyFile

func CopyFile(src, dist string) error

func EncodePubkey

func EncodePubkey(pubkey []byte, format uint16) string

func EncryptFile

func EncryptFile(fpath string, key, nonce []byte) (string, error)

func FillRandData

func FillRandData(data []byte) error

func FillZeroData

func FillZeroData(data []byte) error

func GetAESKeyEncryptedWithECDH

func GetAESKeyEncryptedWithECDH(sk *ecies.PrivateKey, pubkey []byte) ([]byte, []byte, error)

func GetDataHash

func GetDataHash(data ...any) []byte

func GetRandomBytes

func GetRandomBytes() ([]byte, error)

func ParsingPublickey

func ParsingPublickey(address string) ([]byte, error)

func RSRestore

func RSRestore(outpath string, shardspath []string) error

func ReedSolomon

func ReedSolomon(file string, saveDir string) ([]string, error)

func ReedSolomonWithHandle

func ReedSolomonWithHandle(file []byte, handle func([]byte) error) error

func Remove0x

func Remove0x(hex string) string

func SignWithSecp256k1PrivateKey

func SignWithSecp256k1PrivateKey(sk *ecdsa.PrivateKey, data []byte) ([]byte, error)

func SignedSR25519WithMnemonic

func SignedSR25519WithMnemonic(mnemonic string, msg string) ([]byte, error)

func VerifySR25519WithPublickey

func VerifySR25519WithPublickey(msg, sign, pubkey []byte) (bool, error)

func VerifySecp256k1Sign

func VerifySecp256k1Sign(pubkey, data, sign []byte) bool

func WriteFile

func WriteFile(fpath string, data []byte) error

Types

type Archiver

type Archiver interface {
	Archive(files []string, dest string) error
	Unarchive(src, dest string) error
	Extract(src string, target string, dest string) error
	Close() error
}

func NewArchiver

func NewArchiver(archiveFormat string) (Archiver, error)

Jump to

Keyboard shortcuts

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