optional sigverify

This commit is contained in:
Leopold Schabel 2022-01-03 20:18:09 +01:00
parent e12d715bc7
commit e63101dc6d
2 changed files with 12 additions and 4 deletions

View File

@ -11,6 +11,10 @@ import (
"sort"
)
var (
flagSigverify = flag.Bool("sigverify", false, "Verify signatures")
)
// pkcon install libpcap-devel
// readPCAP reads a PCAP file and returns a channel of packets.
@ -52,10 +56,12 @@ func main() {
continue
}
ok := tpu.VerifyTxSig(tx)
if !ok {
fmt.Printf("bad signature on %s", tx.Signatures[0])
continue
if *flagSigverify {
ok := tpu.VerifyTxSig(tx)
if !ok {
fmt.Printf("bad signature on %s\n", tx.Signatures[0])
continue
}
}
signers := tpu.ExtractSigners(tx)

View File

@ -3,6 +3,7 @@ package tpu
import (
"crypto/ed25519"
"errors"
"fmt"
"github.com/gagliardetto/binary"
"github.com/gagliardetto/solana-go"
)
@ -35,6 +36,7 @@ func VerifyTxSig(tx *solana.Transaction) (ok bool) {
for i, sig := range tx.Signatures {
if !ed25519.Verify(signers[i][:], msg, sig[:]) {
fmt.Printf("invalid signature by %s\n", signers[i].String())
return false
}
}