func (digest *Digest) Scan(state fmt.ScanState, verb rune) error {
	token, err := state.Token(true, func(c rune) bool {
		if c >= '0' && c <= '9' {
			return true
		}
		if c >= 'A' && c <= 'F' {
			return true
		}
		if c >= 'a' && c <= 'f' {
			return true
		}
		return false
	})
	if nil != err {
		return err
	}
	buffer := make([]byte, hex.DecodedLen(len(token)))
	byteCount, err := hex.Decode(buffer, token)
	if nil != err {
		return err
	}
	for i, v := range buffer[:byteCount] {
		digest[Length-1-i] = v
	}
	return nil
}
Scan - convert a big endian hex representation to a digest for use by the format package scan routines
package blockdigest
import (
	"encoding/hex"
	"fmt"
	"math/big"
	"github.com/bitmark-inc/bitmarkd/chain"
	"github.com/bitmark-inc/bitmarkd/difficulty"
	"github.com/bitmark-inc/bitmarkd/fault"
	"github.com/bitmark-inc/go-argon2"
	"github.com/bitmark-inc/logger"
)
const Length = 32
const (
	digestMode        = argon2.ModeArgon2d
	digestMemory      = 1 << 17  
	digestParallelism = 1
	digestIterations  = 4
	digestVersion     = argon2.Version13
)
type Digest [Length]byte
func NewDigest(record []byte) Digest {
	context := &argon2.Context{
		Iterations:  digestIterations,
		Memory:      digestMemory,
		Parallelism: digestParallelism,
		HashLen:     Length,
		Mode:        digestMode,
		Version:     digestVersion,
	}
	hash, err := argon2.Hash(context, record, record)
	logger.PanicIfError("block.NewDigest", err)
	var digest Digest
	copy(digest[:], hash)
	return digest
}
func (digest Digest) Cmp(difficulty *big.Int) int {
	bigEndian := reversed(digest)
	result := new(big.Int)
	return result.SetBytes(bigEndian[:]).Cmp(difficulty)
}
func (digest Digest) IsEmpty() bool {
	return digest == Digest{}
}
func (digest Digest) IsValidByDifficulty(diff *difficulty.Difficulty, chainName string) bool {
	if chainName == chain.Local {
		return true
	}
	reversedDigest := reversed(digest)
	bigEndian := new(big.Int)
	bigEndian.SetBytes(reversedDigest[:])
	return bigEndian.Cmp(diff.BigInt()) <= 0
}
func (digest Digest) SmallerDigestThan(target Digest) bool {
	for i := len(digest) - 1; i >= 0; i-- {
		if digest[i] < target[i] {
			return true
		}
	}
	return false
}
func reversed(digest Digest) []byte {
	result := make([]byte, Length)
	for i := 0; i < Length; i += 1 {
		result[i] = digest[Length-1-i]
	}
	return result
}
func (digest Digest) String() string {
	return hex.EncodeToString(reversed(digest))
}
func (digest Digest) GoString() string {
	return "<Argon2d:" + hex.EncodeToString(reversed(digest)) + ">"
}