Documentation
¶
Overview ¶
This module contains the utility function that are used for various hashing functionality
This module contains the utility function that are used to encode binary objects to different formats and to convert structs into their binary gob formats
Index ¶
- Constants
- Variables
- func Base58Decode(encodeddata []byte) []byte
- func Base58Encode(payload []byte) []byte
- func CheckSum32(payload []byte) []byte
- func HandleErrorLog(err error, msg string)
- func Hash160(payload []byte) []byte
- func Hash256(payload []byte) []byte
- func HexDecode(src []byte) int
- func HexEncode(number int) []byte
- func KeyGenECDSA() (ecdsa.PrivateKey, []byte)
- func LogInitialize(loglevel logrus.Level)
Constants ¶
const DBfile string = "./tmp/db/blocks/MANIFEST"
TODO: MOVE TO A LOCATION OUTSIDE OF THE REPO DIR
const DBpath string = "./tmp/db/blocks"
const WalletDB = "./tmp/walletstore.data"
const WeavePOS = "samite"
Represents the Proof Of Work weave net
const WeavePOW = "fustian"
Represents the Proof Of Work weave net ID
const WeaverVersion = "v0.5.0"
Represents the Package Version
Variables ¶
var UTXOprefix = []byte("utxo-")
Functions ¶
func Base58Decode ¶
A function to decode a Base58 bytes payload into a regular bytes payload
func Base58Encode ¶
A function to encode a bytes payload into a Base58 bytes payload
func CheckSum32 ¶
A function that generates a 32bit checksum for a given slice of bytes payload. Generated by truncating a double hashed payload.
checksum32 = first 32 bits of [SHA3-256(SHA3-256(payload))]
func HandleErrorLog ¶
A function that logs a given error and message with the fatal log level and an error field
func Hash160 ¶
A function that generates a 160bit hash output for a given slice of bytes payload.
Generated by hashing the payload with 256 bit hash algorithm, then a 224 bit algorithm and finally truncated to 160bits.
This is equivalent in terms of security to the Bitcoin method of using SHA256 followed by RIPEMD160. The RIPEMD160 algorithm was rejected because of its deprecated nature in the Golang crypto library along with the fact that truncated SHA3 algortithms are equally safe as their full length versions Hence the choice to use truncated SHA3-224 over the SHA1 which outputs 20 byte hashes directly.
hash160 = first 160 bits of [SHA3-224(SHA3-256(payload))]
References: https://bitcoin.stackexchange.com/questions/16543/why-was-the-ripemd-160-hash-algorithms-chosen-before-sha-1 https://crypto.stackexchange.com/questions/3153/sha-256-vs-any-256-bits-of-sha-512-which-is-more-secure
func Hash256 ¶
A function that generates a 256 bit hash output for a given slice of bytes payload.
Generated by double hashing the payload with a 256bit hash algorithm.
The choice to use SHA3 instead of SHA2 is governed by the additional safety offered due to Keccak Sponge Algorithm that breaks away from the common design scheme shared between the SHA2 (current standard) and the SHA1 (broken standard). Additionally, SHA3 is resistant to length extension attacks and is likely to be secure for several generations of computing hardware.
hash256 = SHA3-256(SHA3-256(payload))
References: https://crypto.stackexchange.com/questions/68307/what-is-the-difference-between-sha-3-and-sha-256
func KeyGenECDSA ¶
func KeyGenECDSA() (ecdsa.PrivateKey, []byte)
A function that generates a pair of digital signature keys based on the ECDSA algorithm using the secp256r1 elliptic curve.
This method of generating cryptographic key pairs creates a pair with 1 in 10^77 chance of collision.
func LogInitialize ¶
A function that initializes the log level, formatter and output
Types ¶
This section is empty.