Skip to content
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

Merge crypto into erigon-lib/crypto #12515

Merged
merged 8 commits into from
Oct 29, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions consensus/clique/clique.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,10 @@ import (
"github.com/goccy/go-json"
lru "github.com/hashicorp/golang-lru/arc/v2"

"github.com/erigontech/erigon/turbo/services"

"github.com/erigontech/erigon-lib/chain"
libcommon "github.com/erigontech/erigon-lib/common"
"github.com/erigontech/erigon-lib/common/hexutil"
"github.com/erigontech/erigon-lib/crypto/cryptopool"
"github.com/erigontech/erigon-lib/kv"
"github.com/erigontech/erigon-lib/kv/dbutils"
"github.com/erigontech/erigon-lib/log/v3"
Expand All @@ -51,10 +50,10 @@ import (
"github.com/erigontech/erigon/core/types/accounts"
"github.com/erigontech/erigon/core/vm/evmtypes"
"github.com/erigontech/erigon/crypto"
"github.com/erigontech/erigon/crypto/cryptopool"
"github.com/erigontech/erigon/params"
"github.com/erigontech/erigon/rlp"
"github.com/erigontech/erigon/rpc"
"github.com/erigontech/erigon/turbo/services"
)

const (
Expand Down
3 changes: 2 additions & 1 deletion core/snaptype/block_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,15 @@ import (
"github.com/erigontech/erigon-lib/common"
"github.com/erigontech/erigon-lib/common/background"
"github.com/erigontech/erigon-lib/common/dbg"
"github.com/erigontech/erigon-lib/crypto/cryptopool"
"github.com/erigontech/erigon-lib/downloader/snaptype"
"github.com/erigontech/erigon-lib/log/v3"
"github.com/erigontech/erigon-lib/recsplit"
"github.com/erigontech/erigon-lib/seg"
types2 "github.com/erigontech/erigon-lib/types"

"github.com/erigontech/erigon/core/types"
"github.com/erigontech/erigon/crypto"
"github.com/erigontech/erigon/crypto/cryptopool"
"github.com/erigontech/erigon/rlp"
)

Expand Down
2 changes: 1 addition & 1 deletion core/types/bloom9.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ import (
"unsafe"

"github.com/erigontech/erigon-lib/common/hexutility"
"github.com/erigontech/erigon-lib/crypto/cryptopool"

"github.com/erigontech/erigon/crypto"
"github.com/erigontech/erigon/crypto/cryptopool"
)

type bytesBacked interface {
Expand Down
5 changes: 3 additions & 2 deletions core/types/hashing.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,12 @@ import (
"fmt"
"io"

libcommon "github.com/erigontech/erigon-lib/common"
"github.com/protolambda/ztyp/codec"

libcommon "github.com/erigontech/erigon-lib/common"
"github.com/erigontech/erigon-lib/crypto/cryptopool"

"github.com/erigontech/erigon/crypto"
"github.com/erigontech/erigon/crypto/cryptopool"
"github.com/erigontech/erigon/rlp"
"github.com/erigontech/erigon/turbo/rlphacks"
"github.com/erigontech/erigon/turbo/trie"
Expand Down
4 changes: 2 additions & 2 deletions core/vm/contracts.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,13 @@ import (
libcommon "github.com/erigontech/erigon-lib/common"
libcrypto "github.com/erigontech/erigon-lib/crypto"
"github.com/erigontech/erigon-lib/crypto/blake2b"
"github.com/erigontech/erigon-lib/crypto/bn256"
libkzg "github.com/erigontech/erigon-lib/crypto/kzg"
"github.com/erigontech/erigon-lib/crypto/secp256r1"

"github.com/erigontech/erigon/common"
"github.com/erigontech/erigon/common/math"
"github.com/erigontech/erigon/crypto"
"github.com/erigontech/erigon/crypto/bn256"
"github.com/erigontech/erigon/crypto/secp256r1"
"github.com/erigontech/erigon/params"

//lint:ignore SA1019 Needed for precompile
Expand Down
2 changes: 1 addition & 1 deletion crypto/crypto.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ import (

libcommon "github.com/erigontech/erigon-lib/common"
"github.com/erigontech/erigon-lib/common/hexutil"
"github.com/erigontech/erigon-lib/crypto/cryptopool"

"github.com/erigontech/erigon/common/math"
"github.com/erigontech/erigon/crypto/cryptopool"
"github.com/erigontech/erigon/rlp"
)

Expand Down
38 changes: 0 additions & 38 deletions crypto/cryptopool/buf_pool.go

This file was deleted.

4 changes: 2 additions & 2 deletions erigon-lib/common/address.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,11 @@ func (a *Address) checksumHex() []byte {
buf := a.hex()

// compute checksum
sha := cryptopool.GetLegacyKeccak256()
sha := cryptopool.NewLegacyKeccak256()
//nolint:errcheck
sha.Write(buf[2:])
hash := sha.Sum(nil)
cryptopool.ReturnLegacyKeccak256(sha)
cryptopool.ReturnToPoolKeccak256(sha)

for i := 2; i < len(buf); i++ {
hashByte := hash[(i-2)/2]
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
package bn256

import (
bn256cf "github.com/erigontech/erigon/crypto/bn256/cloudflare"
bn256cf "github.com/erigontech/erigon-lib/crypto/bn256/cloudflare"
)

// G1 is an abstract cyclic group. The zero value is suitable for use as the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
// Package bn256 implements the Optimal Ate pairing over a 256-bit Barreto-Naehrig curve.
package bn256

import bn256 "github.com/erigontech/erigon/crypto/bn256/google"
import bn256 "github.com/erigontech/erigon-lib/crypto/bn256/google"

// G1 is an abstract cyclic group. The zero value is suitable for use as the
// output of an operation, but cannot be used as an input.
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
5 changes: 3 additions & 2 deletions erigon-lib/crypto/cryptopool/buf_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,16 @@ import (
"golang.org/x/crypto/sha3"
)

// pool holds LegacyKeccak hashers.
var pool = sync.Pool{
New: func() interface{} {
return sha3.NewLegacyKeccak256()
},
}

func GetLegacyKeccak256() hash.Hash {
func NewLegacyKeccak256() hash.Hash {
h := pool.Get().(hash.Hash)
h.Reset()
return h
}
func ReturnLegacyKeccak256(h hash.Hash) { pool.Put(h) }
func ReturnToPoolKeccak256(h hash.Hash) { pool.Put(h) }
File renamed without changes.
File renamed without changes.
3 changes: 2 additions & 1 deletion polygon/bor/bor.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,10 @@ import (
libcommon "github.com/erigontech/erigon-lib/common"
"github.com/erigontech/erigon-lib/common/dbg"
"github.com/erigontech/erigon-lib/common/length"
"github.com/erigontech/erigon-lib/crypto/cryptopool"
"github.com/erigontech/erigon-lib/kv"
"github.com/erigontech/erigon-lib/log/v3"

"github.com/erigontech/erigon/consensus"
"github.com/erigontech/erigon/consensus/misc"
"github.com/erigontech/erigon/core/rawdb"
Expand All @@ -53,7 +55,6 @@ import (
"github.com/erigontech/erigon/core/types/accounts"
"github.com/erigontech/erigon/core/vm/evmtypes"
"github.com/erigontech/erigon/crypto"
"github.com/erigontech/erigon/crypto/cryptopool"
"github.com/erigontech/erigon/eth/ethconfig/estimate"
"github.com/erigontech/erigon/params"
"github.com/erigontech/erigon/polygon/bor/borcfg"
Expand Down
5 changes: 3 additions & 2 deletions tests/fuzzers/bn256/bn256_fuzz.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ import (
"math/big"

"github.com/consensys/gnark-crypto/ecc/bn254"
cloudflare "github.com/erigontech/erigon/crypto/bn256/cloudflare"
google "github.com/erigontech/erigon/crypto/bn256/google"

cloudflare "github.com/erigontech/erigon-lib/crypto/bn256/cloudflare"
google "github.com/erigontech/erigon-lib/crypto/bn256/google"
)

func getG1Points(input io.Reader) (*cloudflare.G1, *google.G1, *bn254.G1Affine) {
Expand Down
3 changes: 2 additions & 1 deletion turbo/jsonrpc/eth_block.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,18 @@ import (
"github.com/erigontech/erigon-lib/common"
"github.com/erigontech/erigon-lib/common/hexutil"
"github.com/erigontech/erigon-lib/common/hexutility"
"github.com/erigontech/erigon-lib/crypto/cryptopool"
"github.com/erigontech/erigon-lib/kv"
"github.com/erigontech/erigon-lib/kv/rawdbv3"
"github.com/erigontech/erigon-lib/log/v3"

"github.com/erigontech/erigon/cl/clparams"
"github.com/erigontech/erigon/common/math"
"github.com/erigontech/erigon/core"
"github.com/erigontech/erigon/core/rawdb"
"github.com/erigontech/erigon/core/state"
"github.com/erigontech/erigon/core/types"
"github.com/erigontech/erigon/core/vm"
"github.com/erigontech/erigon/crypto/cryptopool"
"github.com/erigontech/erigon/polygon/bor/borcfg"
bortypes "github.com/erigontech/erigon/polygon/bor/types"
"github.com/erigontech/erigon/rpc"
Expand Down
Loading