mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2024-12-22 19:50:36 +00:00
32 lines
785 B
Go
32 lines
785 B
Go
package merkle_tree
|
|
|
|
import (
|
|
"encoding/binary"
|
|
|
|
libcommon "github.com/ledgerwatch/erigon-lib/common"
|
|
)
|
|
|
|
// Uint64Root retrieves the root hash of a uint64 value by converting it to a byte array and returning it as a hash.
|
|
func Uint64Root(val uint64) libcommon.Hash {
|
|
var root libcommon.Hash
|
|
binary.LittleEndian.PutUint64(root[:], val)
|
|
return root
|
|
}
|
|
|
|
func SignatureRoot(signature [96]byte) (libcommon.Hash, error) {
|
|
return ArraysRoot([][32]byte{
|
|
libcommon.BytesToHash(signature[0:32]),
|
|
libcommon.BytesToHash(signature[32:64]),
|
|
libcommon.BytesToHash(signature[64:]),
|
|
}, 4)
|
|
}
|
|
|
|
func PublicKeyRoot(key [48]byte) (libcommon.Hash, error) {
|
|
var lastByte [32]byte
|
|
copy(lastByte[:], key[32:])
|
|
return ArraysRoot([][32]byte{
|
|
libcommon.BytesToHash(key[:32]),
|
|
lastByte,
|
|
}, 2)
|
|
}
|