mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-25 04:47:18 +00:00
d077483577
* v3 import renamings * tidy * fmt * rev * Update beacon-chain/core/epoch/precompute/reward_penalty_test.go * Update beacon-chain/core/helpers/validators_test.go * Update beacon-chain/db/alias.go * Update beacon-chain/db/alias.go * Update beacon-chain/db/alias.go * Update beacon-chain/db/iface/BUILD.bazel * Update beacon-chain/db/kv/kv.go * Update beacon-chain/db/kv/state.go * Update beacon-chain/rpc/prysm/v1alpha1/validator/attester_test.go * Update beacon-chain/rpc/prysm/v1alpha1/validator/attester_test.go * Update beacon-chain/sync/initial-sync/service.go * fix deps * fix bad replacements * fix bad replacements * change back * gohashtree version * fix deps Co-authored-by: Nishant Das <nishdas93@gmail.com> Co-authored-by: Potuz <potuz@prysmaticlabs.com>
45 lines
1.0 KiB
Go
45 lines
1.0 KiB
Go
package bls
|
|
|
|
import (
|
|
"bytes"
|
|
"encoding/hex"
|
|
"strings"
|
|
"testing"
|
|
|
|
"github.com/ghodss/yaml"
|
|
"github.com/prysmaticlabs/prysm/v3/testing/bls/utils"
|
|
"github.com/prysmaticlabs/prysm/v3/testing/require"
|
|
blst "github.com/supranational/blst/bindings/go"
|
|
)
|
|
|
|
func TestHashToG2(t *testing.T) {
|
|
t.Run("blst", testHashToG2)
|
|
}
|
|
|
|
func testHashToG2(t *testing.T) {
|
|
t.Skip("Hash To G2 needs co-ordinates exposed")
|
|
fNames, fContent := utils.RetrieveFiles("hash_to_G2", t)
|
|
|
|
for i, file := range fNames {
|
|
content := fContent[i]
|
|
t.Run(file, func(t *testing.T) {
|
|
test := &HashToG2Test{}
|
|
require.NoError(t, yaml.Unmarshal(content, test))
|
|
|
|
msgBytes := []byte(test.Input.Message)
|
|
|
|
splitX := strings.Split(test.Output.X, ",")
|
|
outputX, err := hex.DecodeString(splitX[0][2:])
|
|
require.NoError(t, err)
|
|
|
|
point := blst.HashToG2(msgBytes, nil)
|
|
val := point.Compress()
|
|
if !bytes.Equal(val, outputX) {
|
|
t.Fatalf("Retrieved X value does not match output. "+
|
|
"Expected %#v but received %#v for test case %d", outputX, val, i)
|
|
}
|
|
t.Log("Success")
|
|
})
|
|
}
|
|
}
|