crypto

package
v0.0.0-...-6d5dda5 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2024 License: Apache-2.0 Imports: 17 Imported by: 2

Documentation

Index

Constants

View Source
const (
	VIDEO_CODEC = 0x72 // VIDEO_CODEC is separate from SDS_CODEC in order to identify the videos
	SDS_CODEC   = 0x66 // codec of legacy file hash is cid.RAW. New file hash uses SDS_CODEC.

	VALID_CID_VERSION = 1
	VALID_MH_TYPE     = 27
	VALID_MH_LENGTH   = 20
)

Variables

This section is empty.

Functions

func CalcCRC32

func CalcCRC32(data []byte) uint32

func CalcCRC32OfSlices

func CalcCRC32OfSlices(data [][]byte) uint32

func CalcFileCRC32

func CalcFileCRC32(filePath string) (uint32, error)

func CalcFileHash

func CalcFileHash(filePath, encryptionTag string, codec byte) (string, error)

func CalcFileHashFromSlices

func CalcFileHashFromSlices(files []string, encryptionTag string) string

func CalcFileKeccak

func CalcFileKeccak(filePath string) (mh.Multihash, error)

func CalcFileMD5

func CalcFileMD5(filePath string) ([]byte, error)

func CalcHash

func CalcHash(data []byte) string

func CalcHashBytes

func CalcHashBytes(data []byte) []byte

func CalcKeccakOfSplitFiles

func CalcKeccakOfSplitFiles(files []string) []byte

func CalcMD5OfSplitFiles

func CalcMD5OfSplitFiles(filePath []string) ([]byte, error)

func CalcSliceHash

func CalcSliceHash(data []byte, fileHash string, sliceNumber uint64) (string, error)

func FromECDSAPub

func FromECDSAPub(pub *ecdsa.PublicKey) []byte

func GetCodecFromFileHash

func GetCodecFromFileHash(hash string) (uint64, error)

func IsVideoStream

func IsVideoStream(hash string) bool

func Keccak256

func Keccak256(data ...[]byte) []byte

Keccak256 calculates and returns the Keccak256 hash of the input data.

func S256

func S256() elliptic.Curve

S256 returns an instance of the secp256k1 curve.

func ToECDSAUnsafe

func ToECDSAUnsafe(d []byte) *ecdsa.PrivateKey

ToECDSAUnsafe blindly converts a binary blob to a private key. It should almost never be used unless you are sure the input is valid and want to avoid hitting errors due to bad origin encoding (0 prefixes cut off).

func UnmarshalPubkey

func UnmarshalPubkey(pub []byte) (*ecdsa.PublicKey, error)

UnmarshalPubkey converts bytes to a secp256k1 public key.

func ValidateHash

func ValidateHash(hash string) bool

ValidateHash only validate the hash format, does NOT verify if the hash is created by certain content

Types

This section is empty.

Directories

Path Synopsis
common
Package common contains various helper functions.
Package common contains various helper functions.
common/hexutil
Package hexutil implements hex encoding with 0x prefix.
Package hexutil implements hex encoding with 0x prefix.
secp256k1
Package secp256k1 wraps the bitcoin secp256k1 C library.
Package secp256k1 wraps the bitcoin secp256k1 C library.
Package math provides integer math utilities.
Package math provides integer math utilities.
rlp
Package rlp implements the RLP serialization format.
Package rlp implements the RLP serialization format.
internal/rlpstruct
Package rlpstruct implements struct processing for RLP encoding/decoding.
Package rlpstruct implements struct processing for RLP encoding/decoding.
Package sha3 implements the SHA-3 fixed-output-length hash functions and the SHAKE variable-output-length hash functions defined by FIPS-202.
Package sha3 implements the SHA-3 fixed-output-length hash functions and the SHAKE variable-output-length hash functions defined by FIPS-202.

Jump to

Keyboard shortcuts

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