-
Notifications
You must be signed in to change notification settings - Fork 129
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Move ./lib/runtime/sig_verifier.go
to ./lib/crypto
package
#1930
Comments
Can I take this |
Go for it! |
@EclesioMeloJunior |
@kevinliao852, sorry for the delay!
type SigVerifyFunc func(pubkey, sig, msg []byte) (bool, error)
// lib/crypto/secp256k1
func BatchSignVerify(pubkey, sig, msg []byte) (bool, error) {
result := secp256k1.VerifySignature(pubkey, msg, sig)
return result, nil
}
// lib/crypto/sr25519
func BatchSignVerify(pubkey, sig, msg []byte) (bool, error) {
pubKey, err := NewPublicKey(pubkey)
if err != nil {
return false, fmt.Errorf("failed to fetch sr25519 public key: %s", err)
}
return pubKey.Verify(msg, sig)
}
// lib/crypto/ed25519
...
ok, err := sign.VerifyFunc(sign.PubKey, sign.Sign, sign.Msg)
if err != nil || !ok {
log.Error("[ext_crypto_start_batch_verify_version_1]", "error", err)
sv.Invalid()
return
}
// instead of use the `crypto.Secp256k1Type`
signature := runtime.Signature{
PubKey: pub.Encode(),
Sign: signature,
Msg: hash[:],
KeyTypeID: crypto.Secp256k1Type,
}
// use the `secp256k1.BatchSignVerify`
signature := crytpo.Signature{
PubKey: pub.Encode(),
Sign: signature,
Msg: hash[:],
VerifyFunc: secp256k1.BatchSignVerify,
} this way you can move the batch signature verification to |
Issue summary
./lib/runtime/sig_verifier.go
placed at theruntime
package does not depend on runtime stuff, and it just acts like a worker that verifies batch signatures in a concurrently way../lib/crypto
package as make more sense to that file be there.Other information and links
The text was updated successfully, but these errors were encountered: