File tree Expand file tree Collapse file tree 8 files changed +53
-8
lines changed Expand file tree Collapse file tree 8 files changed +53
-8
lines changed Original file line number Diff line number Diff line change @@ -12,8 +12,7 @@ import (
1212
1313 pb "github.com/libp2p/go-libp2p/core/crypto/pb"
1414 "github.com/libp2p/go-libp2p/core/internal/catch"
15-
16- "github.com/minio/sha256-simd"
15+ "github.com/libp2p/go-libp2p/internal/sha256"
1716)
1817
1918// ECDSAPrivateKey is an implementation of an ECDSA private key
Original file line number Diff line number Diff line change @@ -16,10 +16,10 @@ import (
1616 . "github.com/libp2p/go-libp2p/core/crypto"
1717 pb "github.com/libp2p/go-libp2p/core/crypto/pb"
1818 "github.com/libp2p/go-libp2p/core/test"
19+ "github.com/libp2p/go-libp2p/internal/sha256"
1920
2021 "github.com/decred/dcrd/dcrec/secp256k1/v4"
2122 secp256k1ecdsa "github.com/decred/dcrd/dcrec/secp256k1/v4/ecdsa"
22- "github.com/minio/sha256-simd"
2323)
2424
2525func TestKeys (t * testing.T ) {
Original file line number Diff line number Diff line change @@ -10,8 +10,7 @@ import (
1010
1111 pb "github.com/libp2p/go-libp2p/core/crypto/pb"
1212 "github.com/libp2p/go-libp2p/core/internal/catch"
13-
14- "github.com/minio/sha256-simd"
13+ "github.com/libp2p/go-libp2p/internal/sha256"
1514)
1615
1716// RsaPrivateKey is a rsa private key
Original file line number Diff line number Diff line change 99
1010 "github.com/decred/dcrd/dcrec/secp256k1/v4"
1111 "github.com/decred/dcrd/dcrec/secp256k1/v4/ecdsa"
12- "github.com/minio/sha256-simd "
12+ "github.com/libp2p/go-libp2p/internal/sha256 "
1313)
1414
1515// Secp256k1PrivateKey is a Secp256k1 private key
Original file line number Diff line number Diff line change 1+ //go:build go1.21
2+
3+ // This package use build tags to select between github.com/minio/sha256-simd
4+ // for go1.20 and bellow and crypto/sha256 for go1.21 and above.
5+ // This is used because a fast SHANI implementation of sha256 is only avaiable
6+ // in the std for go1.21 and above. See https://go.dev/issue/50543.
7+ // TODO: Once go1.22 releases remove this package and replace all uses
8+ // with crypto/sha256 because the two supported version of go will have the fast
9+ // implementation.
10+ package sha256
11+
12+ import (
13+ "crypto/sha256"
14+ "hash"
15+ )
16+
17+ func Sum256 (b []byte ) [sha256 .Size ]byte {
18+ return sha256 .Sum256 (b )
19+ }
20+
21+ func New () hash.Hash {
22+ return sha256 .New ()
23+ }
Original file line number Diff line number Diff line change 1+ //go:build !go1.21
2+
3+ // This package use build tags to select between github.com/minio/sha256-simd
4+ // for go1.20 and bellow and crypto/sha256 for go1.21 and above.
5+ // This is used because a fast SHANI implementation of sha256 is only avaiable
6+ // in the std for go1.21 and above. See https://go.dev/issue/50543.
7+ // TODO: Once go1.22 releases remove this package and replace all uses
8+ // with crypto/sha256 because the two supported version of go will have the fast
9+ // implementation.
10+ package sha256
11+
12+ import (
13+ "hash"
14+
15+ "github.com/minio/sha256-simd"
16+ )
17+
18+ func Sum256 (b []byte ) [sha256 .Size ]byte {
19+ return sha256 .Sum256 (b )
20+ }
21+
22+ func New () hash.Hash {
23+ return sha256 .New ()
24+ }
Original file line number Diff line number Diff line change 99 "github.com/libp2p/go-libp2p/core/peer"
1010 "github.com/libp2p/go-libp2p/core/peerstore"
1111 "github.com/libp2p/go-libp2p/core/test"
12+ "github.com/libp2p/go-libp2p/internal/sha256"
1213 "github.com/libp2p/go-libp2p/p2p/host/eventbus"
1314 "github.com/libp2p/go-libp2p/p2p/net/swarm"
1415 swarmt "github.com/libp2p/go-libp2p/p2p/net/swarm/testing"
@@ -18,7 +19,6 @@ import (
1819 "github.com/libp2p/go-libp2p/p2p/transport/tcp"
1920 webtransport "github.com/libp2p/go-libp2p/p2p/transport/webtransport"
2021
21- "github.com/minio/sha256-simd"
2222 ma "github.com/multiformats/go-multiaddr"
2323 "github.com/multiformats/go-multibase"
2424 "github.com/multiformats/go-multihash"
Original file line number Diff line number Diff line change @@ -12,11 +12,11 @@ import (
1212
1313 "github.com/libp2p/go-libp2p/core/crypto"
1414 "github.com/libp2p/go-libp2p/core/peer"
15+ "github.com/libp2p/go-libp2p/internal/sha256"
1516 "github.com/libp2p/go-libp2p/p2p/security/noise/pb"
1617
1718 "github.com/flynn/noise"
1819 pool "github.com/libp2p/go-buffer-pool"
19- "github.com/minio/sha256-simd"
2020 "google.golang.org/protobuf/proto"
2121)
2222
You can’t perform that action at this time.
0 commit comments