integrate bls, secp fuzzers

This commit is contained in:
Martin Holst Swende 2023-11-05 18:55:40 +01:00
parent ea0a83a1c7
commit 62a0b20b6c
No known key found for this signature in database
GPG key ID: 683B438C05A5DDF0
2 changed files with 145 additions and 69 deletions

View file

@ -81,112 +81,189 @@ function compile_fuzzer() {
} }
go install github.com/holiman/gofuzz-shim@latest go install github.com/holiman/gofuzz-shim@latest
repo=$GOPATH/src/github.com/ethereum/go-ethereum
# compile_fuzzer github.com/ethereum/go-ethereum/accounts/abi \ # compile_fuzzer github.com/ethereum/go-ethereum/accounts/abi \
# FuzzABI \ # FuzzABI \
# $GOPATH/src/github.com/ethereum/go-ethereum/accounts/abi/abifuzzer_test.go \ # $repo/accounts/abi/abifuzzer_test.go \
# fuzzAbi # fuzzAbi
# #
# # compile_fuzzer github.com/ethereum/go-ethereum/common/bitutil FuzzEncoder fuzzBitutilEncoder # # compile_fuzzer github.com/ethereum/go-ethereum/common/bitutil FuzzEncoder fuzzBitutilEncoder
# compile_fuzzer github.com/ethereum/go-ethereum/common/bitutil \ # compile_fuzzer github.com/ethereum/go-ethereum/common/bitutil \
# FuzzEncoder \ # FuzzEncoder \
# $GOPATH/src/github.com/ethereum/go-ethereum/common/bitutil/compress_test.go \ # $repo/common/bitutil/compress_test.go \
# fuzzBitutilEncoder # fuzzBitutilEncoder
# #
# # compile_fuzzer github.com/ethereum/go-ethereum/common/bitutil FuzzDecoder fuzzBitutilDecoder # # compile_fuzzer github.com/ethereum/go-ethereum/common/bitutil FuzzDecoder fuzzBitutilDecoder
# compile_fuzzer github.com/ethereum/go-ethereum/common/bitutil \ # compile_fuzzer github.com/ethereum/go-ethereum/common/bitutil \
# FuzzDecoder \ # FuzzDecoder \
# $GOPATH/src/github.com/ethereum/go-ethereum/common/bitutil/compress_test.go \ # $repo/common/bitutil/compress_test.go \
# fuzzBitutilDecoder # fuzzBitutilDecoder
# #
# # compile_fuzzer github.com/ethereum/go-ethereum/core/vm/runtime FuzzVmRuntime fuzzVmRuntime # # compile_fuzzer github.com/ethereum/go-ethereum/core/vm/runtime FuzzVmRuntime fuzzVmRuntime
# compile_fuzzer github.com/ethereum/go-ethereum/core/vm/runtime \ # compile_fuzzer github.com/ethereum/go-ethereum/core/vm/runtime \
# FuzzVmRuntime \ # FuzzVmRuntime \
# $GOPATH/src/github.com/ethereum/go-ethereum/core/vm/runtime/runtime_fuzz_test.go \ # $repo/core/vm/runtime/runtime_fuzz_test.go \
# fuzzVmRuntime # fuzzVmRuntime
# #
# # compile_fuzzer github.com/ethereum/go-ethereum/core/vm FuzzPrecompiledContracts fuzzPrecompiledContracts # # compile_fuzzer github.com/ethereum/go-ethereum/core/vm FuzzPrecompiledContracts fuzzPrecompiledContracts
# compile_fuzzer github.com/ethereum/go-ethereum/core/vm \ # compile_fuzzer github.com/ethereum/go-ethereum/core/vm \
# FuzzPrecompiledContracts \ # FuzzPrecompiledContracts \
# $GOPATH/src/github.com/ethereum/go-ethereum/core/vm/contracts_fuzz_test.go \ # $repo/core/vm/contracts_fuzz_test.go \
# fuzzPrecompiledContracts # fuzzPrecompiledContracts
# #
# # compile_fuzzer github.com/ethereum/go-ethereum/core/types FuzzRLP fuzzRlp # # compile_fuzzer github.com/ethereum/go-ethereum/core/types FuzzRLP fuzzRlp
# compile_fuzzer github.com/ethereum/go-ethereum/core/types \ # compile_fuzzer github.com/ethereum/go-ethereum/core/types \
# FuzzRLP \ # FuzzRLP \
# $GOPATH/src/github.com/ethereum/go-ethereum/core/types/rlp_fuzzer_test.go \ # $repo/core/types/rlp_fuzzer_test.go \
# fuzzRlp # fuzzRlp
# #
# #compile_fuzzer github.com/ethereum/go-ethereum/crypto/blake2b Fuzz fuzzBlake2b # #compile_fuzzer github.com/ethereum/go-ethereum/crypto/blake2b Fuzz fuzzBlake2b
# compile_fuzzer github.com/ethereum/go-ethereum/crypto/blake2b \ # compile_fuzzer github.com/ethereum/go-ethereum/crypto/blake2b \
# Fuzz \ # Fuzz \
# $GOPATH/src/github.com/ethereum/go-ethereum/crypto/blake2b/blake2b_f_fuzz_test.go \ # $repo/crypto/blake2b/blake2b_f_fuzz_test.go \
# fuzzBlake2b # fuzzBlake2b
# #
# #compile_fuzzer github.com/ethereum/go-ethereum/accounts/keystore FuzzPassword fuzzKeystore # #compile_fuzzer github.com/ethereum/go-ethereum/accounts/keystore FuzzPassword fuzzKeystore
# compile_fuzzer github.com/ethereum/go-ethereum/accounts/keystore \ # compile_fuzzer github.com/ethereum/go-ethereum/accounts/keystore \
# FuzzPassword \ # FuzzPassword \
# $GOPATH/src/github.com/ethereum/go-ethereum/accounts/keystore/keystore_fuzzing_test.go \ # $repo/accounts/keystore/keystore_fuzzing_test.go \
# fuzzKeystore # fuzzKeystore
# #
# #compile_fuzzer github.com/ethereum/go-ethereum/trie FuzzTrie fuzzTrie
# pkg=$repo/trie/
# compile_fuzzer github.com/ethereum/go-ethereum/trie \
# FuzzTrie \
# $pkg/trie_test.go,$pkg/database_test.go,$pkg/tracer_test.go,$pkg/proof_test.go,$pkg/iterator_test.go,$pkg/sync_test.go \
# fuzzTrie
# #
#compile_fuzzer github.com/ethereum/go-ethereum/trie FuzzTrie fuzzTrie # #compile_fuzzer github.com/ethereum/go-ethereum/trie FuzzStackTrie fuzzStackTrie
pkg=$GOPATH/src/github.com/ethereum/go-ethereum/trie/ # compile_fuzzer github.com/ethereum/go-ethereum/trie \
compile_fuzzer github.com/ethereum/go-ethereum/trie \ # FuzzStackTrie \
FuzzTrie \ # $pkg/stacktrie_fuzzer_test.go,$pkg/iterator_test.go,$pkg/trie_test.go,$pkg/database_test.go,$pkg/tracer_test.go,$pkg/proof_test.go,$pkg/sync_test.go \
$pkg/trie_test.go,$pkg/database_test.go,$pkg/tracer_test.go,$pkg/proof_test.go,$pkg/iterator_test.go,$pkg/sync_test.go \ # fuzzStackTrie
fuzzTrie #
# #compile_fuzzer tests/fuzzers/snap FuzzARange fuzz_account_range
# compile_fuzzer github.com/ethereum/go-ethereum/eth/protocols/snap \
# FuzzARange \
# $repo/eth/protocols/snap/handler_fuzzing_test.go \
# fuzz_account_range
#
# #compile_fuzzer tests/fuzzers/snap FuzzSRange fuzz_storage_range
# compile_fuzzer github.com/ethereum/go-ethereum/eth/protocols/snap \
# FuzzSRange \
# $repo/eth/protocols/snap/handler_fuzzing_test.go \
# fuzz_storage_range
#
# #compile_fuzzer tests/fuzzers/snap FuzzByteCodes fuzz_byte_codes
# compile_fuzzer github.com/ethereum/go-ethereum/eth/protocols/snap \
# FuzzByteCodes \
# $repo/eth/protocols/snap/handler_fuzzing_test.go \
# fuzz_byte_codes
# #compile_fuzzer tests/fuzzers/snap FuzzTrieNodes fuzz_trie_nodes
# compile_fuzzer github.com/ethereum/go-ethereum/eth/protocols/snap \
# FuzzTrieNodes \
# $repo/eth/protocols/snap/handler_fuzzing_test.go \
# fuzz_trie_nodes
#
#
# #compile_fuzzer tests/fuzzers/bn256 FuzzAdd fuzzBn256Add
# compile_fuzzer github.com/ethereum/go-ethereum/tests/fuzzers/bn256 \
# FuzzAdd \
# $repo/tests/fuzzers/bn256/bn256_test.go \
# fuzzBn256Add
#
# #compile_fuzzer tests/fuzzers/bn256 FuzzMul fuzzBn256Mul
# compile_fuzzer github.com/ethereum/go-ethereum/tests/fuzzers/bn256 \
# FuzzMul \
# $repo/tests/fuzzers/bn256/bn256_test.go \
# fuzzBn256Mul
# #compile_fuzzer tests/fuzzers/bn256 FuzzPair fuzzBn256Pair
# compile_fuzzer github.com/ethereum/go-ethereum/tests/fuzzers/bn256 \
# FuzzPair \
# $repo/tests/fuzzers/bn256/bn256_test.go \
# fuzzBn256Pair
#
# #compile_fuzzer tests/fuzzers/txfetcher Fuzz fuzzTxfetcher
# compile_fuzzer github.com/ethereum/go-ethereum/tests/fuzzers/txfetcher \
# Fuzz \
# $repo/tests/fuzzers/txfetcher/txfetcher_test.go \
# fuzzTxfetcher
#
# #compile_fuzzer tests/fuzzers/bls12381 FuzzG1Add fuzz_g1_add
# compile_fuzzer github.com/ethereum/go-ethereum/tests/fuzzers/bls12381 \
# FuzzG1Add \
# $repo/tests/fuzzers/bls12381/bls12381_test.go \
# fuzz_g1_add
#
# #compile_fuzzer tests/fuzzers/bls12381 FuzzG1Mul fuzz_g1_mul
# compile_fuzzer github.com/ethereum/go-ethereum/tests/fuzzers/bls12381 \
# FuzzG1Mul \
# $repo/tests/fuzzers/bls12381/bls12381_test.go \
# fuzz_g1_mul
# #compile_fuzzer tests/fuzzers/bls12381 FuzzG1MultiExp fuzz_g1_multiexp
# compile_fuzzer github.com/ethereum/go-ethereum/tests/fuzzers/bls12381 \
# FuzzG1MultiExp \
# $repo/tests/fuzzers/bls12381/bls12381_test.go \
# fuzz_g1_multiexp
# #compile_fuzzer tests/fuzzers/bls12381 FuzzG2Add fuzz_g2_add
# compile_fuzzer github.com/ethereum/go-ethereum/tests/fuzzers/bls12381 \
# FuzzG2Add \
# $repo/tests/fuzzers/bls12381/bls12381_test.go \
# fuzz_g2_add
# #compile_fuzzer tests/fuzzers/bls12381 FuzzG2Mul fuzz_g2_mul
# compile_fuzzer github.com/ethereum/go-ethereum/tests/fuzzers/bls12381 \
# FuzzG2Mul \
# $repo/tests/fuzzers/bls12381/bls12381_test.go \
# fuzz_g2_mul
# #compile_fuzzer tests/fuzzers/bls12381 FuzzG2MultiExp fuzz_g2_multiexp
# compile_fuzzer github.com/ethereum/go-ethereum/tests/fuzzers/bls12381 \
# FuzzG2MultiExp \
# $repo/tests/fuzzers/bls12381/bls12381_test.go \
# fuzz_g2_multiexp
# #compile_fuzzer tests/fuzzers/bls12381 FuzzPairing fuzz_pairing
# compile_fuzzer github.com/ethereum/go-ethereum/tests/fuzzers/bls12381 \
# FuzzPairing \
# $repo/tests/fuzzers/bls12381/bls12381_test.go \
# fuzz_pairing
# #compile_fuzzer tests/fuzzers/bls12381 FuzzMapG1 fuzz_map_g1
# compile_fuzzer github.com/ethereum/go-ethereum/tests/fuzzers/bls12381 \
# FuzzMapG1 \
# $repo/tests/fuzzers/bls12381/bls12381_test.go \
# fuzz_map_g1
# #compile_fuzzer tests/fuzzers/bls12381 FuzzMapG2 fuzz_map_g2
# compile_fuzzer github.com/ethereum/go-ethereum/tests/fuzzers/bls12381 \
# FuzzMapG2 \
# $repo/tests/fuzzers/bls12381/bls12381_test.go \
# fuzz_map_g2
#
# #compile_fuzzer tests/fuzzers/bls12381 FuzzCrossG1Add fuzz_cross_g1_add
# compile_fuzzer github.com/ethereum/go-ethereum/tests/fuzzers/bls12381 \
# FuzzCrossG1Add \
# $repo/tests/fuzzers/bls12381/bls12381_test.go \
# fuzz_cross_g1_add
# #compile_fuzzer tests/fuzzers/bls12381 FuzzCrossG1MultiExp fuzz_cross_g1_multiexp
# compile_fuzzer github.com/ethereum/go-ethereum/tests/fuzzers/bls12381 \
# FuzzCrossG1MultiExp \
# $repo/tests/fuzzers/bls12381/bls12381_test.go \
# fuzz_cross_g1_multiexp
# #compile_fuzzer tests/fuzzers/bls12381 FuzzCrossG2Add fuzz_cross_g2_add
# compile_fuzzer github.com/ethereum/go-ethereum/tests/fuzzers/bls12381 \
# FuzzCrossG2Add \
# $repo/tests/fuzzers/bls12381/bls12381_test.go \
# fuzz_cross_g2_add
# #compile_fuzzer tests/fuzzers/bls12381 FuzzCrossPairing fuzz_cross_pairing
# compile_fuzzer github.com/ethereum/go-ethereum/tests/fuzzers/bls12381 \
# FuzzCrossPairing \
# $repo/tests/fuzzers/bls12381/bls12381_test.go \
# fuzz_cross_pairing
#
#compile_fuzzer tests/fuzzers/secp256k1 Fuzz fuzzSecp256k1
compile_fuzzer github.com/ethereum/go-ethereum/tests/fuzzers/secp256k1 \
Fuzz \
$repo/tests/fuzzers/secp256k1/secp_test.go \
fuzzSecp256k1
#compile_fuzzer github.com/ethereum/go-ethereum/trie FuzzStackTrie fuzzStackTrie #compile_fuzzer tests/fuzzers/vflux FuzzClientPool fuzzClientPool
compile_fuzzer github.com/ethereum/go-ethereum/trie \
FuzzStackTrie \
$pkg/stacktrie_fuzzer_test.go,$pkg/iterator_test.go,$pkg/trie_test.go,$pkg/database_test.go,$pkg/tracer_test.go,$pkg/proof_test.go,$pkg/sync_test.go \
fuzzStackTrie
#compile_fuzzer tests/fuzzers/snap FuzzARange fuzz_account_range
compile_fuzzer github.com/ethereum/go-ethereum/eth/protocols/snap \
FuzzARange \
$GOPATH/src/github.com/ethereum/go-ethereum/eth/protocols/snap/handler_fuzzing_test.go \
fuzz_account_range
#compile_fuzzer tests/fuzzers/snap FuzzSRange fuzz_storage_range
compile_fuzzer github.com/ethereum/go-ethereum/eth/protocols/snap \
FuzzSRange \
$GOPATH/src/github.com/ethereum/go-ethereum/eth/protocols/snap/handler_fuzzing_test.go \
fuzz_storage_range
#compile_fuzzer tests/fuzzers/snap FuzzByteCodes fuzz_byte_codes
compile_fuzzer github.com/ethereum/go-ethereum/eth/protocols/snap \
FuzzByteCodes \
$GOPATH/src/github.com/ethereum/go-ethereum/eth/protocols/snap/handler_fuzzing_test.go \
fuzz_byte_codes
#compile_fuzzer tests/fuzzers/snap FuzzTrieNodes fuzz_trie_nodes
compile_fuzzer github.com/ethereum/go-ethereum/eth/protocols/snap \
FuzzTrieNodes \
$GOPATH/src/github.com/ethereum/go-ethereum/eth/protocols/snap/handler_fuzzing_test.go \
fuzz_trie_nodes
#compile_fuzzer tests/fuzzers/bn256 FuzzAdd fuzzBn256Add
#compile_fuzzer tests/fuzzers/bn256 FuzzMul fuzzBn256Mul
#compile_fuzzer tests/fuzzers/bn256 FuzzPair fuzzBn256Pair
#compile_fuzzer tests/fuzzers/txfetcher Fuzz fuzzTxfetcher
#compile_fuzzer tests/fuzzers/difficulty Fuzz fuzzDifficulty #compile_fuzzer tests/fuzzers/difficulty Fuzz fuzzDifficulty
#compile_fuzzer tests/fuzzers/les Fuzz fuzzLes #compile_fuzzer tests/fuzzers/les Fuzz fuzzLes
#compile_fuzzer tests/fuzzers/secp256k1 Fuzz fuzzSecp256k1
#compile_fuzzer tests/fuzzers/vflux FuzzClientPool fuzzClientPool
#compile_fuzzer tests/fuzzers/bls12381 FuzzG1Add fuzz_g1_add
#compile_fuzzer tests/fuzzers/bls12381 FuzzG1Mul fuzz_g1_mul
#compile_fuzzer tests/fuzzers/bls12381 FuzzG1MultiExp fuzz_g1_multiexp
#compile_fuzzer tests/fuzzers/bls12381 FuzzG2Add fuzz_g2_add
#compile_fuzzer tests/fuzzers/bls12381 FuzzG2Mul fuzz_g2_mul
#compile_fuzzer tests/fuzzers/bls12381 FuzzG2MultiExp fuzz_g2_multiexp
#compile_fuzzer tests/fuzzers/bls12381 FuzzPairing fuzz_pairing
#compile_fuzzer tests/fuzzers/bls12381 FuzzMapG1 fuzz_map_g1
#compile_fuzzer tests/fuzzers/bls12381 FuzzMapG2 fuzz_map_g2
#compile_fuzzer tests/fuzzers/bls12381 FuzzCrossG1Add fuzz_cross_g1_add
#compile_fuzzer tests/fuzzers/bls12381 FuzzCrossG1MultiExp fuzz_cross_g1_multiexp
#compile_fuzzer tests/fuzzers/bls12381 FuzzCrossG2Add fuzz_cross_g2_add
#compile_fuzzer tests/fuzzers/bls12381 FuzzCrossPairing fuzz_cross_pairing

View file

@ -35,7 +35,7 @@ func Fuzz(f *testing.F) {
}) })
} }
func fuzz(dataP1, dataP2 []byte) int { func fuzz(dataP1, dataP2 []byte) {
var ( var (
curveA = secp256k1.S256() curveA = secp256k1.S256()
curveB = btcec.S256() curveB = btcec.S256()
@ -50,5 +50,4 @@ func fuzz(dataP1, dataP2 []byte) int {
fmt.Printf("%s %s %s %s\n", x1, y1, x2, y2) fmt.Printf("%s %s %s %s\n", x1, y1, x2, y2)
panic(fmt.Sprintf("Addition failed: geth: %s %s btcd: %s %s", resAX, resAY, resBX, resBY)) panic(fmt.Sprintf("Addition failed: geth: %s %s btcd: %s %s", resAX, resAY, resBX, resBY))
} }
return 0
} }