Documentation ¶
Index ¶
- Constants
- Variables
- func NormalizePoCBytes(vb []byte, bl int) []byte
- func PoCValue2Bytes(v PoCValue, bl int) []byte
- func RecordSize(bl int) int
- type Hash
- type PoCValue
- func Bytes2PoCValue(vb []byte, bl int) PoCValue
- func CutBigInt(bi *big.Int, bl int) PoCValue
- func CutHash(hash Hash, bl int) PoCValue
- func F(x, xp PoCValue, bl int, pubKeyHash Hash) PoCValue
- func FB(x, xp []byte, bl int, pubKeyHash Hash) PoCValue
- func FlipValue(v PoCValue, bl int) PoCValue
- func P(x PoCValue, bl int, pubKeyHash Hash) PoCValue
- func PB(x []byte, bl int, pubKeyHash Hash) PoCValue
Constants ¶
const (
// PoCPrefixLen represents the byte length of PoCPrefix.
PoCPrefixLen = 4
)
Variables ¶
var ErrInvalidHashLength = errors.New("invalid length for hash")
ErrInvalidHashLength indicates the length of hash is invalid.
var ( // PoCPrefix is the prefix for PoC Calculation. PoCPrefix = []byte("MASS") )
Functions ¶
func NormalizePoCBytes ¶
NormalizePoCBytes sets vb and returns vb according to its bitLength, upper bits would be set to zero.
func PoCValue2Bytes ¶
PoCValue2Bytes encodes a PoCValue to bytes, size depending on its bitLength.
func RecordSize ¶
RecordSize returns the size of a bitLength record, in byte unit.
Types ¶
type Hash ¶
type Hash [32]byte
Hash represents a 32-byte hash value.
func DecodeStringToHash ¶
DecodeStringToHash decodes a string value to Hash, the length of string value must be 64.
func DoubleSHA256 ¶
DoubleSHA256 represents the standard double sha256.
func MASSDoubleSHA256 ¶
MASSDoubleSHA256 represents the unique MASS double sha256.
func PubKeyHash ¶
PubKeyHash returns the hash of pubKey.
func PubKeyItfHash ¶
func PubKeyItfHash(pubKey interfaces.PublicKey) Hash
type PoCValue ¶
type PoCValue uint64
PoCValue represents the value type of PoC Record.
func Bytes2PoCValue ¶
Bytes2PoCValue decodes a PoCValue from bytes, size depending on its bitLength.
func CutHash ¶
CutHash cuts the least significant 8 bytes of Hash, decoding it as little endian uint64, and masking result to bitLength value.
func F ¶
F calculates MASSSHA256(PoCPrefix || PubKeyHash || X || XP).CutByBitLength(bitLength), it takes in (x, xp) as PoCValue.
func FB ¶
FB calculates MASSSHA256(PoCPrefix || PubKeyHash || X || XP).CutByBitLength(bitLength), it takes in (x, xp) as Byte Slice.
Directories ¶
Path | Synopsis |
---|---|
Package crypto collects common cryptographic constants.
|
Package crypto collects common cryptographic constants. |
hash
Package hash provides interfaces for hash functions.
|
Package hash provides interfaces for hash functions. |
sha256
Package sha256 implements the SHA224 and SHA256 hash algorithms as defined in FIPS 180-4.
|
Package sha256 implements the SHA224 and SHA256 hash algorithms as defined in FIPS 180-4. |