File tree Expand file tree Collapse file tree 12 files changed +59
-14
lines changed
Expand file tree Collapse file tree 12 files changed +59
-14
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 an 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 an Secp256k1 private key
Original file line number Diff line number Diff line change @@ -41,7 +41,7 @@ require (
4141 github.com/multiformats/go-multiaddr-fmt v0.1.0
4242 github.com/multiformats/go-multibase v0.2.0
4343 github.com/multiformats/go-multicodec v0.8.1
44- github.com/multiformats/go-multihash v0.2.1
44+ github.com/multiformats/go-multihash v0.2.2
4545 github.com/multiformats/go-multistream v0.4.1
4646 github.com/multiformats/go-varint v0.0.7
4747 github.com/pbnjay/memory v0.0.0-20210728143218-7b4eea64cf58
Original file line number Diff line number Diff line change @@ -265,8 +265,8 @@ github.com/multiformats/go-multibase v0.2.0/go.mod h1:bFBZX4lKCA/2lyOFSAoKH5SS6o
265265github.1485827954.workers.dev/multiformats/go-multicodec v0.8.1 h1:ycepHwavHafh3grIbR1jIXnKCsFm0fqsfEOsJ8NtKE8 =
266266github.1485827954.workers.dev/multiformats/go-multicodec v0.8.1 /go.mod h1:L3QTQvMIaVBkXOXXtVmYE+LI16i14xuaojr/H7Ai54k =
267267github.1485827954.workers.dev/multiformats/go-multihash v0.0.8 /go.mod h1:YSLudS+Pi8NHE7o6tb3D8vrpKa63epEDmG8nTduyAew =
268- github.com/multiformats/go-multihash v0.2.1 h1:aem8ZT0VA2nCHHk7bPJ1BjUbHNciqZC/d16Vve9l108 =
269- github.com/multiformats/go-multihash v0.2.1 /go.mod h1:WxoMcYG85AZVQUyRyo9s4wULvW5qrI9vb2Lt6evduFc =
268+ github.com/multiformats/go-multihash v0.2.2 h1:Uu7LWs/PmWby1gkj1S1DXx3zyd3aVabA4FiMKn/2tAc =
269+ github.com/multiformats/go-multihash v0.2.2 /go.mod h1:dXgKXCXjBzdscBLk9JkjINiEsCKRVch90MdaGiKsvSM =
270270github.1485827954.workers.dev/multiformats/go-multistream v0.4.1 h1:rFy0Iiyn3YT0asivDUIR05leAdwZq3de4741sbiSdfo =
271271github.1485827954.workers.dev/multiformats/go-multistream v0.4.1 /go.mod h1:Mz5eykRVAjJWckE2U78c6xqdtyNUEhKSM0Lwar2p77Q =
272272github.1485827954.workers.dev/multiformats/go-varint v0.0.1 /go.mod h1:3Ls8CIEsrijN6+B7PbrXRPxHRPuXSrVKRY101jdMZYE =
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