ChainSafe / go-schnorrkel

🍵 Schnorr Signatures over Ristretto255 in pure Go

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

can not verify from polkadot-js

quan-xie opened this issue · comments

package main

import (
	"fmt"

	sr25519 "github.com/ChainSafe/go-schnorrkel"
)

var SigningContext = []byte("substrate")

func main() {
	pub, err := sr25519.NewPublicKeyFromHex("0x18b39373cd7c48d3c17478b4cade579ab9a6d67d795803a167b085696ea97622")
	if err != nil {
		panic(err)
	}
	sig, err := sr25519.NewSignatureFromHex("0x429140a10fc99055153fe08a6cd630d69b8f6723d16ea2e0ca4960d14f53095ec5e3a065e4b4473c927f35883ca39401fa9fe6c0beaf5f836e13076cbb47fa8a")
	if err != nil {
		panic(err)
	}
	msg := []byte("this is a message")
	ok, err := pub.Verify(sig, sr25519.NewSigningContext([]byte("substrate"), msg))
	if err != nil {
		fmt.Println(err)
		return
	}
	fmt.Println(ok)
}

have no error but also false

@quan-xie is this still a problem? If not, can you explain what the problem was? Did you need to use a different signing context, like polkadot maybe?

solve it just like this”<Bytes>this is a message</Bytes>" @danforbes