1 Star 0 Fork 0

刘昭 / cntest

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
secp_fuzzer.go 1.55 KB
一键复制 编辑 原始数据 按行查看 历史
刘昭 提交于 2022-01-25 17:35 . go mod tidy
// 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"
"gitee.com/liu-zhao234568/cntest/crypto/secp256k1"
"github.com/btcsuite/btcd/btcec"
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
}
1
https://gitee.com/liu-zhao234568/cntest.git
git@gitee.com:liu-zhao234568/cntest.git
liu-zhao234568
cntest
cntest
v1.0.0

搜索帮助

53164aa7 5694891 3bd8fe86 5694891