utils

package
v0.0.0-...-4ca2c20 Latest Latest
Warning

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

Go to latest
Published: Jan 9, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConvUint64

func ConvUint64(val any) (uint64, error)

func Decrypt

func Decrypt(priv *ecdsa.PrivateKey, pubkey *ecdsa.PublicKey, ciphertext []byte) ([]byte, error)

Decrypt gets a hashed shared point X as secret, then sym decrypts the ciphertext using sm4 (CTR mode)

func Encrypt

func Encrypt(priv *ecdsa.PrivateKey, pubkey *ecdsa.PublicKey, plaintext []byte) ([]byte, error)

Encrypt gets a hashed shared point X as secret, then sym encrypts the plaintext using sm4 (CTR mode) The resulting ciphertext length is BlockSize+len(plaintext), because IV is randomly generated and included at the beginning of ciphertext

func GetSessionID

func GetSessionID(id1 [32]byte, id2 [32]byte) [32]byte

GetSessionID by sha256(smaller, bigger)

func ParseHexNodeID

func ParseHexNodeID(in string) ([32]byte, error)

Parse hex string without trim "0x" to node ID

func ParseNodeID

func ParseNodeID(in string) ([32]byte, error)

Parse hex string trimed "0x" to node ID

func RandomBytes

func RandomBytes(len int) []byte

func ToHttpAddress

func ToHttpAddress(addr string) string

Types

type TinyEasyMap

type TinyEasyMap struct {
	// contains filtered or unexported fields
}

func NewEasyMap

func NewEasyMap(m map[string]any) TinyEasyMap

func (TinyEasyMap) Get

func (m TinyEasyMap) Get(key string) (any, error)

func (TinyEasyMap) GetString

func (m TinyEasyMap) GetString(key string) (string, error)

func (TinyEasyMap) GetUint64

func (m TinyEasyMap) GetUint64(key string) (uint64, error)

Jump to

Keyboard shortcuts

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