mirror of https://github.com/ethereum/go-ethereum
tests/fuzzers: update fuzzers to be based on go-native fuzzing (#28352)
This change modifies the fuzzers to use the native golang fuzzing framework instead of go-fuzzpull/28379/head
parent
da55b23d21
commit
d10a2f6ab7
@ -1,58 +0,0 @@ |
|||||||
//go:build gofuzz
|
|
||||||
// +build gofuzz
|
|
||||||
|
|
||||||
package blake2b |
|
||||||
|
|
||||||
import ( |
|
||||||
"encoding/binary" |
|
||||||
) |
|
||||||
|
|
||||||
func Fuzz(data []byte) int { |
|
||||||
// Make sure the data confirms to the input model
|
|
||||||
if len(data) != 211 { |
|
||||||
return 0 |
|
||||||
} |
|
||||||
// Parse everything and call all the implementations
|
|
||||||
var ( |
|
||||||
rounds = binary.BigEndian.Uint16(data[0:2]) |
|
||||||
|
|
||||||
h [8]uint64 |
|
||||||
m [16]uint64 |
|
||||||
t [2]uint64 |
|
||||||
f uint64 |
|
||||||
) |
|
||||||
for i := 0; i < 8; i++ { |
|
||||||
offset := 2 + i*8 |
|
||||||
h[i] = binary.LittleEndian.Uint64(data[offset : offset+8]) |
|
||||||
} |
|
||||||
for i := 0; i < 16; i++ { |
|
||||||
offset := 66 + i*8 |
|
||||||
m[i] = binary.LittleEndian.Uint64(data[offset : offset+8]) |
|
||||||
} |
|
||||||
t[0] = binary.LittleEndian.Uint64(data[194:202]) |
|
||||||
t[1] = binary.LittleEndian.Uint64(data[202:210]) |
|
||||||
|
|
||||||
if data[210]%2 == 1 { // Avoid spinning the fuzzer to hit 0/1
|
|
||||||
f = 0xFFFFFFFFFFFFFFFF |
|
||||||
} |
|
||||||
// Run the blake2b compression on all instruction sets and cross reference
|
|
||||||
want := h |
|
||||||
fGeneric(&want, &m, t[0], t[1], f, uint64(rounds)) |
|
||||||
|
|
||||||
have := h |
|
||||||
fSSE4(&have, &m, t[0], t[1], f, uint64(rounds)) |
|
||||||
if have != want { |
|
||||||
panic("SSE4 mismatches generic algo") |
|
||||||
} |
|
||||||
have = h |
|
||||||
fAVX(&have, &m, t[0], t[1], f, uint64(rounds)) |
|
||||||
if have != want { |
|
||||||
panic("AVX mismatches generic algo") |
|
||||||
} |
|
||||||
have = h |
|
||||||
fAVX2(&have, &m, t[0], t[1], f, uint64(rounds)) |
|
||||||
if have != want { |
|
||||||
panic("AVX2 mismatches generic algo") |
|
||||||
} |
|
||||||
return 1 |
|
||||||
} |
|
@ -1,170 +0,0 @@ |
|||||||
// Copyright 2020 The go-ethereum Authors
|
|
||||||
// This file is part of the go-ethereum library.
|
|
||||||
//
|
|
||||||
// The go-ethereum library is free software: you can redistribute it and/or modify
|
|
||||||
// it under the terms of the GNU Lesser General Public License as published by
|
|
||||||
// the Free Software Foundation, either version 3 of the License, or
|
|
||||||
// (at your option) any later version.
|
|
||||||
//
|
|
||||||
// The go-ethereum library is distributed in the hope that it will be useful,
|
|
||||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
// GNU Lesser General Public License for more details.
|
|
||||||
//
|
|
||||||
// You should have received a copy of the GNU Lesser General Public License
|
|
||||||
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
package abi |
|
||||||
|
|
||||||
import ( |
|
||||||
"fmt" |
|
||||||
"reflect" |
|
||||||
"strings" |
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/accounts/abi" |
|
||||||
fuzz "github.com/google/gofuzz" |
|
||||||
) |
|
||||||
|
|
||||||
var ( |
|
||||||
names = []string{"_name", "name", "NAME", "name_", "__", "_name_", "n"} |
|
||||||
stateMut = []string{"", "pure", "view", "payable"} |
|
||||||
stateMutabilites = []*string{&stateMut[0], &stateMut[1], &stateMut[2], &stateMut[3]} |
|
||||||
pays = []string{"", "true", "false"} |
|
||||||
payables = []*string{&pays[0], &pays[1]} |
|
||||||
vNames = []string{"a", "b", "c", "d", "e", "f", "g"} |
|
||||||
varNames = append(vNames, names...) |
|
||||||
varTypes = []string{"bool", "address", "bytes", "string", |
|
||||||
"uint8", "int8", "uint8", "int8", "uint16", "int16", |
|
||||||
"uint24", "int24", "uint32", "int32", "uint40", "int40", "uint48", "int48", "uint56", "int56", |
|
||||||
"uint64", "int64", "uint72", "int72", "uint80", "int80", "uint88", "int88", "uint96", "int96", |
|
||||||
"uint104", "int104", "uint112", "int112", "uint120", "int120", "uint128", "int128", "uint136", "int136", |
|
||||||
"uint144", "int144", "uint152", "int152", "uint160", "int160", "uint168", "int168", "uint176", "int176", |
|
||||||
"uint184", "int184", "uint192", "int192", "uint200", "int200", "uint208", "int208", "uint216", "int216", |
|
||||||
"uint224", "int224", "uint232", "int232", "uint240", "int240", "uint248", "int248", "uint256", "int256", |
|
||||||
"bytes1", "bytes2", "bytes3", "bytes4", "bytes5", "bytes6", "bytes7", "bytes8", "bytes9", "bytes10", "bytes11", |
|
||||||
"bytes12", "bytes13", "bytes14", "bytes15", "bytes16", "bytes17", "bytes18", "bytes19", "bytes20", "bytes21", |
|
||||||
"bytes22", "bytes23", "bytes24", "bytes25", "bytes26", "bytes27", "bytes28", "bytes29", "bytes30", "bytes31", |
|
||||||
"bytes32", "bytes"} |
|
||||||
) |
|
||||||
|
|
||||||
func unpackPack(abi abi.ABI, method string, input []byte) ([]interface{}, bool) { |
|
||||||
if out, err := abi.Unpack(method, input); err == nil { |
|
||||||
_, err := abi.Pack(method, out...) |
|
||||||
if err != nil { |
|
||||||
// We have some false positives as we can unpack these type successfully, but not pack them
|
|
||||||
if err.Error() == "abi: cannot use []uint8 as type [0]int8 as argument" || |
|
||||||
err.Error() == "abi: cannot use uint8 as type int8 as argument" { |
|
||||||
return out, false |
|
||||||
} |
|
||||||
panic(err) |
|
||||||
} |
|
||||||
return out, true |
|
||||||
} |
|
||||||
return nil, false |
|
||||||
} |
|
||||||
|
|
||||||
func packUnpack(abi abi.ABI, method string, input *[]interface{}) bool { |
|
||||||
if packed, err := abi.Pack(method, input); err == nil { |
|
||||||
outptr := reflect.New(reflect.TypeOf(input)) |
|
||||||
err := abi.UnpackIntoInterface(outptr.Interface(), method, packed) |
|
||||||
if err != nil { |
|
||||||
panic(err) |
|
||||||
} |
|
||||||
out := outptr.Elem().Interface() |
|
||||||
if !reflect.DeepEqual(input, out) { |
|
||||||
panic(fmt.Sprintf("unpackPack is not equal, \ninput : %x\noutput: %x", input, out)) |
|
||||||
} |
|
||||||
return true |
|
||||||
} |
|
||||||
return false |
|
||||||
} |
|
||||||
|
|
||||||
type args struct { |
|
||||||
name string |
|
||||||
typ string |
|
||||||
} |
|
||||||
|
|
||||||
func createABI(name string, stateMutability, payable *string, inputs []args) (abi.ABI, error) { |
|
||||||
sig := fmt.Sprintf(`[{ "type" : "function", "name" : "%v" `, name) |
|
||||||
if stateMutability != nil { |
|
||||||
sig += fmt.Sprintf(`, "stateMutability": "%v" `, *stateMutability) |
|
||||||
} |
|
||||||
if payable != nil { |
|
||||||
sig += fmt.Sprintf(`, "payable": %v `, *payable) |
|
||||||
} |
|
||||||
if len(inputs) > 0 { |
|
||||||
sig += `, "inputs" : [ {` |
|
||||||
for i, inp := range inputs { |
|
||||||
sig += fmt.Sprintf(`"name" : "%v", "type" : "%v" `, inp.name, inp.typ) |
|
||||||
if i+1 < len(inputs) { |
|
||||||
sig += "," |
|
||||||
} |
|
||||||
} |
|
||||||
sig += "} ]" |
|
||||||
sig += `, "outputs" : [ {` |
|
||||||
for i, inp := range inputs { |
|
||||||
sig += fmt.Sprintf(`"name" : "%v", "type" : "%v" `, inp.name, inp.typ) |
|
||||||
if i+1 < len(inputs) { |
|
||||||
sig += "," |
|
||||||
} |
|
||||||
} |
|
||||||
sig += "} ]" |
|
||||||
} |
|
||||||
sig += `}]` |
|
||||||
|
|
||||||
return abi.JSON(strings.NewReader(sig)) |
|
||||||
} |
|
||||||
|
|
||||||
func runFuzzer(input []byte) int { |
|
||||||
good := false |
|
||||||
fuzzer := fuzz.NewFromGoFuzz(input) |
|
||||||
|
|
||||||
name := names[getUInt(fuzzer)%len(names)] |
|
||||||
stateM := stateMutabilites[getUInt(fuzzer)%len(stateMutabilites)] |
|
||||||
payable := payables[getUInt(fuzzer)%len(payables)] |
|
||||||
maxLen := 5 |
|
||||||
for k := 1; k < maxLen; k++ { |
|
||||||
var arg []args |
|
||||||
for i := k; i > 0; i-- { |
|
||||||
argName := varNames[i] |
|
||||||
argTyp := varTypes[getUInt(fuzzer)%len(varTypes)] |
|
||||||
if getUInt(fuzzer)%10 == 0 { |
|
||||||
argTyp += "[]" |
|
||||||
} else if getUInt(fuzzer)%10 == 0 { |
|
||||||
arrayArgs := getUInt(fuzzer)%30 + 1 |
|
||||||
argTyp += fmt.Sprintf("[%d]", arrayArgs) |
|
||||||
} |
|
||||||
arg = append(arg, args{ |
|
||||||
name: argName, |
|
||||||
typ: argTyp, |
|
||||||
}) |
|
||||||
} |
|
||||||
abi, err := createABI(name, stateM, payable, arg) |
|
||||||
if err != nil { |
|
||||||
continue |
|
||||||
} |
|
||||||
structs, b := unpackPack(abi, name, input) |
|
||||||
c := packUnpack(abi, name, &structs) |
|
||||||
good = good || b || c |
|
||||||
} |
|
||||||
if good { |
|
||||||
return 1 |
|
||||||
} |
|
||||||
return 0 |
|
||||||
} |
|
||||||
|
|
||||||
func Fuzz(input []byte) int { |
|
||||||
return runFuzzer(input) |
|
||||||
} |
|
||||||
|
|
||||||
func getUInt(fuzzer *fuzz.Fuzzer) int { |
|
||||||
var i int |
|
||||||
fuzzer.Fuzz(&i) |
|
||||||
if i < 0 { |
|
||||||
i = -i |
|
||||||
if i < 0 { |
|
||||||
return 0 |
|
||||||
} |
|
||||||
} |
|
||||||
return i |
|
||||||
} |
|
@ -0,0 +1,97 @@ |
|||||||
|
// Copyright 2023 The go-ethereum Authors
|
||||||
|
// This file is part of the go-ethereum library.
|
||||||
|
//
|
||||||
|
// The go-ethereum library is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// The go-ethereum library is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Lesser General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Lesser General Public License
|
||||||
|
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
package bls |
||||||
|
|
||||||
|
import "testing" |
||||||
|
|
||||||
|
func FuzzCrossPairing(f *testing.F) { |
||||||
|
f.Fuzz(func(t *testing.T, data []byte) { |
||||||
|
fuzzCrossPairing(data) |
||||||
|
}) |
||||||
|
} |
||||||
|
|
||||||
|
func FuzzCrossG1Add(f *testing.F) { |
||||||
|
f.Fuzz(func(t *testing.T, data []byte) { |
||||||
|
fuzzCrossG1Add(data) |
||||||
|
}) |
||||||
|
} |
||||||
|
|
||||||
|
func FuzzCrossG2Add(f *testing.F) { |
||||||
|
f.Fuzz(func(t *testing.T, data []byte) { |
||||||
|
fuzzCrossG2Add(data) |
||||||
|
}) |
||||||
|
} |
||||||
|
|
||||||
|
func FuzzCrossG1MultiExp(f *testing.F) { |
||||||
|
f.Fuzz(func(t *testing.T, data []byte) { |
||||||
|
fuzzCrossG1MultiExp(data) |
||||||
|
}) |
||||||
|
} |
||||||
|
|
||||||
|
func FuzzG1Add(f *testing.F) { |
||||||
|
f.Fuzz(func(t *testing.T, data []byte) { |
||||||
|
fuzz(blsG1Add, data) |
||||||
|
}) |
||||||
|
} |
||||||
|
|
||||||
|
func FuzzG1Mul(f *testing.F) { |
||||||
|
f.Fuzz(func(t *testing.T, data []byte) { |
||||||
|
fuzz(blsG1Mul, data) |
||||||
|
}) |
||||||
|
} |
||||||
|
|
||||||
|
func FuzzG1MultiExp(f *testing.F) { |
||||||
|
f.Fuzz(func(t *testing.T, data []byte) { |
||||||
|
fuzz(blsG1MultiExp, data) |
||||||
|
}) |
||||||
|
} |
||||||
|
|
||||||
|
func FuzzG2Add(f *testing.F) { |
||||||
|
f.Fuzz(func(t *testing.T, data []byte) { |
||||||
|
fuzz(blsG2Add, data) |
||||||
|
}) |
||||||
|
} |
||||||
|
|
||||||
|
func FuzzG2Mul(f *testing.F) { |
||||||
|
f.Fuzz(func(t *testing.T, data []byte) { |
||||||
|
fuzz(blsG2Mul, data) |
||||||
|
}) |
||||||
|
} |
||||||
|
|
||||||
|
func FuzzG2MultiExp(f *testing.F) { |
||||||
|
f.Fuzz(func(t *testing.T, data []byte) { |
||||||
|
fuzz(blsG2MultiExp, data) |
||||||
|
}) |
||||||
|
} |
||||||
|
|
||||||
|
func FuzzPairing(f *testing.F) { |
||||||
|
f.Fuzz(func(t *testing.T, data []byte) { |
||||||
|
fuzz(blsPairing, data) |
||||||
|
}) |
||||||
|
} |
||||||
|
|
||||||
|
func FuzzMapG1(f *testing.F) { |
||||||
|
f.Fuzz(func(t *testing.T, data []byte) { |
||||||
|
fuzz(blsMapG1, data) |
||||||
|
}) |
||||||
|
} |
||||||
|
|
||||||
|
func FuzzMapG2(f *testing.F) { |
||||||
|
f.Fuzz(func(t *testing.T, data []byte) { |
||||||
|
fuzz(blsMapG2, data) |
||||||
|
}) |
||||||
|
} |
@ -1 +0,0 @@ |
|||||||
ns©›,²Ô |
|
@ -1,40 +0,0 @@ |
|||||||
// Copyright 2020 The go-ethereum Authors
|
|
||||||
// This file is part of the go-ethereum library.
|
|
||||||
//
|
|
||||||
// The go-ethereum library is free software: you can redistribute it and/or modify
|
|
||||||
// it under the terms of the GNU Lesser General Public License as published by
|
|
||||||
// the Free Software Foundation, either version 3 of the License, or
|
|
||||||
// (at your option) any later version.
|
|
||||||
//
|
|
||||||
// The go-ethereum library is distributed in the hope that it will be useful,
|
|
||||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
// GNU Lesser General Public License for more details.
|
|
||||||
//
|
|
||||||
// You should have received a copy of the GNU Lesser General Public License
|
|
||||||
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
package main |
|
||||||
|
|
||||||
import ( |
|
||||||
"fmt" |
|
||||||
"os" |
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/tests/fuzzers/les" |
|
||||||
) |
|
||||||
|
|
||||||
func main() { |
|
||||||
if len(os.Args) != 2 { |
|
||||||
fmt.Fprintf(os.Stderr, "Usage: debug <file>\n") |
|
||||||
fmt.Fprintf(os.Stderr, "Example\n") |
|
||||||
fmt.Fprintf(os.Stderr, " $ debug ../crashers/4bbef6857c733a87ecf6fd8b9e7238f65eb9862a\n") |
|
||||||
os.Exit(1) |
|
||||||
} |
|
||||||
crasher := os.Args[1] |
|
||||||
data, err := os.ReadFile(crasher) |
|
||||||
if err != nil { |
|
||||||
fmt.Fprintf(os.Stderr, "error loading crasher %v: %v", crasher, err) |
|
||||||
os.Exit(1) |
|
||||||
} |
|
||||||
les.Fuzz(data) |
|
||||||
} |
|
@ -0,0 +1,25 @@ |
|||||||
|
// Copyright 2023 The go-ethereum Authors
|
||||||
|
// This file is part of the go-ethereum library.
|
||||||
|
//
|
||||||
|
// The go-ethereum library is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// The go-ethereum library is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Lesser General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Lesser General Public License
|
||||||
|
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
package les |
||||||
|
|
||||||
|
import "testing" |
||||||
|
|
||||||
|
func Fuzz(f *testing.F) { |
||||||
|
f.Fuzz(func(t *testing.T, data []byte) { |
||||||
|
fuzz(data) |
||||||
|
}) |
||||||
|
} |
@ -1,40 +0,0 @@ |
|||||||
// Copyright 2020 The go-ethereum Authors
|
|
||||||
// This file is part of the go-ethereum library.
|
|
||||||
//
|
|
||||||
// The go-ethereum library is free software: you can redistribute it and/or modify
|
|
||||||
// it under the terms of the GNU Lesser General Public License as published by
|
|
||||||
// the Free Software Foundation, either version 3 of the License, or
|
|
||||||
// (at your option) any later version.
|
|
||||||
//
|
|
||||||
// The go-ethereum library is distributed in the hope that it will be useful,
|
|
||||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
// GNU Lesser General Public License for more details.
|
|
||||||
//
|
|
||||||
// You should have received a copy of the GNU Lesser General Public License
|
|
||||||
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
package main |
|
||||||
|
|
||||||
import ( |
|
||||||
"fmt" |
|
||||||
"os" |
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/tests/fuzzers/rangeproof" |
|
||||||
) |
|
||||||
|
|
||||||
func main() { |
|
||||||
if len(os.Args) != 2 { |
|
||||||
fmt.Fprintf(os.Stderr, "Usage: debug <file>\n") |
|
||||||
fmt.Fprintf(os.Stderr, "Example\n") |
|
||||||
fmt.Fprintf(os.Stderr, " $ debug ../crashers/4bbef6857c733a87ecf6fd8b9e7238f65eb9862a\n") |
|
||||||
os.Exit(1) |
|
||||||
} |
|
||||||
crasher := os.Args[1] |
|
||||||
data, err := os.ReadFile(crasher) |
|
||||||
if err != nil { |
|
||||||
fmt.Fprintf(os.Stderr, "error loading crasher %v: %v", crasher, err) |
|
||||||
os.Exit(1) |
|
||||||
} |
|
||||||
rangeproof.Fuzz(data) |
|
||||||
} |
|
@ -0,0 +1,25 @@ |
|||||||
|
// Copyright 2023 The go-ethereum Authors
|
||||||
|
// This file is part of the go-ethereum library.
|
||||||
|
//
|
||||||
|
// The go-ethereum library is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// The go-ethereum library is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Lesser General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Lesser General Public License
|
||||||
|
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
package rangeproof |
||||||
|
|
||||||
|
import "testing" |
||||||
|
|
||||||
|
func Fuzz(f *testing.F) { |
||||||
|
f.Fuzz(func(t *testing.T, data []byte) { |
||||||
|
fuzz(data) |
||||||
|
}) |
||||||
|
} |
@ -0,0 +1,25 @@ |
|||||||
|
// Copyright 2023 The go-ethereum Authors
|
||||||
|
// This file is part of the go-ethereum library.
|
||||||
|
//
|
||||||
|
// The go-ethereum library is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// The go-ethereum library is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Lesser General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Lesser General Public License
|
||||||
|
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
package rlp |
||||||
|
|
||||||
|
import "testing" |
||||||
|
|
||||||
|
func Fuzz(f *testing.F) { |
||||||
|
f.Fuzz(func(t *testing.T, data []byte) { |
||||||
|
fuzz(data) |
||||||
|
}) |
||||||
|
} |
@ -1,50 +0,0 @@ |
|||||||
// Copyright 2021 The go-ethereum Authors
|
|
||||||
// This file is part of the go-ethereum library.
|
|
||||||
//
|
|
||||||
// The go-ethereum library is free software: you can redistribute it and/or modify
|
|
||||||
// it under the terms of the GNU Lesser General Public License as published by
|
|
||||||
// the Free Software Foundation, either version 3 of the License, or
|
|
||||||
// (at your option) any later version.
|
|
||||||
//
|
|
||||||
// The go-ethereum library is distributed in the hope that it will be useful,
|
|
||||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
// GNU Lesser General Public License for more details.
|
|
||||||
//
|
|
||||||
// You should have received a copy of the GNU Lesser General Public License
|
|
||||||
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
// build +gofuzz
|
|
||||||
|
|
||||||
package secp256k1 |
|
||||||
|
|
||||||
import ( |
|
||||||
"fmt" |
|
||||||
|
|
||||||
"github.com/btcsuite/btcd/btcec/v2" |
|
||||||
"github.com/ethereum/go-ethereum/crypto/secp256k1" |
|
||||||
fuzz "github.com/google/gofuzz" |
|
||||||
) |
|
||||||
|
|
||||||
func Fuzz(input []byte) int { |
|
||||||
var ( |
|
||||||
fuzzer = fuzz.NewFromGoFuzz(input) |
|
||||||
curveA = secp256k1.S256() |
|
||||||
curveB = btcec.S256() |
|
||||||
dataP1 []byte |
|
||||||
dataP2 []byte |
|
||||||
) |
|
||||||
// first point
|
|
||||||
fuzzer.Fuzz(&dataP1) |
|
||||||
x1, y1 := curveB.ScalarBaseMult(dataP1) |
|
||||||
// second point
|
|
||||||
fuzzer.Fuzz(&dataP2) |
|
||||||
x2, y2 := curveB.ScalarBaseMult(dataP2) |
|
||||||
resAX, resAY := curveA.Add(x1, y1, x2, y2) |
|
||||||
resBX, resBY := curveB.Add(x1, y1, x2, y2) |
|
||||||
if resAX.Cmp(resBX) != 0 || resAY.Cmp(resBY) != 0 { |
|
||||||
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)) |
|
||||||
} |
|
||||||
return 0 |
|
||||||
} |
|
@ -0,0 +1,25 @@ |
|||||||
|
// Copyright 2023 The go-ethereum Authors
|
||||||
|
// This file is part of the go-ethereum library.
|
||||||
|
//
|
||||||
|
// The go-ethereum library is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// The go-ethereum library is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Lesser General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Lesser General Public License
|
||||||
|
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
package stacktrie |
||||||
|
|
||||||
|
import "testing" |
||||||
|
|
||||||
|
func Fuzz(f *testing.F) { |
||||||
|
f.Fuzz(func(t *testing.T, data []byte) { |
||||||
|
fuzz(data) |
||||||
|
}) |
||||||
|
} |
@ -1 +0,0 @@ |
|||||||
asdlfkjasf23oiejfasdfadkfqlkjfasdlkfjalwk4jfalsdkfjawlefkjsadlfkjasldkfjwalefkjasdlfkjM |
|
@ -0,0 +1,25 @@ |
|||||||
|
// Copyright 2023 The go-ethereum Authors
|
||||||
|
// This file is part of the go-ethereum library.
|
||||||
|
//
|
||||||
|
// The go-ethereum library is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// The go-ethereum library is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Lesser General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Lesser General Public License
|
||||||
|
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
package trie |
||||||
|
|
||||||
|
import "testing" |
||||||
|
|
||||||
|
func Fuzz(f *testing.F) { |
||||||
|
f.Fuzz(func(t *testing.T, data []byte) { |
||||||
|
fuzz(data) |
||||||
|
}) |
||||||
|
} |
@ -0,0 +1,25 @@ |
|||||||
|
// Copyright 2023 The go-ethereum Authors
|
||||||
|
// This file is part of the go-ethereum library.
|
||||||
|
//
|
||||||
|
// The go-ethereum library is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// The go-ethereum library is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Lesser General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Lesser General Public License
|
||||||
|
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
package txfetcher |
||||||
|
|
||||||
|
import "testing" |
||||||
|
|
||||||
|
func Fuzz(f *testing.F) { |
||||||
|
f.Fuzz(func(t *testing.T, data []byte) { |
||||||
|
fuzz(data) |
||||||
|
}) |
||||||
|
} |
@ -0,0 +1,25 @@ |
|||||||
|
// Copyright 2023 The go-ethereum Authors
|
||||||
|
// This file is part of the go-ethereum library.
|
||||||
|
//
|
||||||
|
// The go-ethereum library is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// The go-ethereum library is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Lesser General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Lesser General Public License
|
||||||
|
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
package vflux |
||||||
|
|
||||||
|
import "testing" |
||||||
|
|
||||||
|
func FuzzClientPool(f *testing.F) { |
||||||
|
f.Fuzz(func(t *testing.T, data []byte) { |
||||||
|
fuzzClientPool(data) |
||||||
|
}) |
||||||
|
} |
Loading…
Reference in new issue