go-randomx/commitment.go
DataHoarder a458a18f07
All checks were successful
continuous-integration/drone/push Build is passing
Added CalculateCommitment api for RandomX v2 hashes, added further testing
2024-05-02 03:46:03 +02:00

16 lines
386 B
Go

package randomx
import "golang.org/x/crypto/blake2b"
// CalculateCommitment Calculate a RandomX commitment from a RandomX hash and its input.
func CalculateCommitment(input []byte, hashIn, hashOut *[RANDOMX_HASH_SIZE]byte) {
hasher, err := blake2b.New(RANDOMX_HASH_SIZE, nil)
if err != nil {
panic(err)
}
hasher.Write(input)
hasher.Write(hashIn[:])
hasher.Sum(hashOut[:0])
}