mirror of
https://github.com/anyproto/any-sync.git
synced 2025-06-09 09:35:03 +09:00
Move peer util package into crypto
This commit is contained in:
parent
9679bb3bf3
commit
b62ad57988
4 changed files with 7 additions and 11 deletions
|
@ -4,7 +4,6 @@ import (
|
|||
"context"
|
||||
"github.com/anytypeio/any-sync/net/secureservice/handshake/handshakeproto"
|
||||
crypto2 "github.com/anytypeio/any-sync/util/crypto"
|
||||
peer2 "github.com/anytypeio/any-sync/util/peer"
|
||||
"github.com/libp2p/go-libp2p/core/crypto"
|
||||
"github.com/libp2p/go-libp2p/core/network"
|
||||
"github.com/libp2p/go-libp2p/core/peer"
|
||||
|
@ -568,9 +567,9 @@ func newConnPair(t require.TestingT) (sc1, sc2 *secConn) {
|
|||
sk2b, err := sk2.Raw()
|
||||
signKey2, err := crypto.UnmarshalEd25519PrivateKey(sk2b)
|
||||
require.NoError(t, err)
|
||||
peerId1, err := peer2.IdFromSigningPubKey(sk1.GetPublic())
|
||||
peerId1, err := crypto2.IdFromSigningPubKey(sk1.GetPublic())
|
||||
require.NoError(t, err)
|
||||
peerId2, err := peer2.IdFromSigningPubKey(sk2.GetPublic())
|
||||
peerId2, err := crypto2.IdFromSigningPubKey(sk2.GetPublic())
|
||||
require.NoError(t, err)
|
||||
sc1 = &secConn{
|
||||
Conn: c1,
|
||||
|
@ -594,7 +593,7 @@ type secConn struct {
|
|||
func (s *secConn) LocalPeer() peer.ID {
|
||||
skB, _ := s.localKey.Raw()
|
||||
sk, _ := crypto2.NewSigningEd25519PubKeyFromBytes(skB)
|
||||
lp, _ := peer2.IdFromSigningPubKey(sk)
|
||||
lp, _ := crypto2.IdFromSigningPubKey(sk)
|
||||
return lp
|
||||
}
|
||||
|
||||
|
|
|
@ -6,7 +6,6 @@ import (
|
|||
"github.com/anytypeio/any-sync/commonspace/object/accountdata"
|
||||
"github.com/anytypeio/any-sync/nodeconf"
|
||||
"github.com/anytypeio/any-sync/util/crypto"
|
||||
"github.com/anytypeio/any-sync/util/peer"
|
||||
)
|
||||
|
||||
// AccountTestService provides service for test purposes, generates new random account every Init
|
||||
|
@ -28,7 +27,7 @@ func (s *AccountTestService) Init(a *app.App) (err error) {
|
|||
return err
|
||||
}
|
||||
|
||||
peerId, err := peer.IdFromSigningPubKey(peerKey.GetPublic())
|
||||
peerId, err := crypto.IdFromSigningPubKey(peerKey.GetPublic())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -8,7 +8,6 @@ import (
|
|||
"errors"
|
||||
"fmt"
|
||||
"github.com/anytypeio/any-sync/util/crypto/cryptoproto"
|
||||
"github.com/anytypeio/any-sync/util/peer"
|
||||
"github.com/anytypeio/any-sync/util/strkey"
|
||||
"github.com/gogo/protobuf/proto"
|
||||
"github.com/libp2p/go-libp2p/core/crypto"
|
||||
|
@ -161,7 +160,7 @@ func (k *Ed25519PubKey) Account() string {
|
|||
|
||||
// PeerId returns string representation of key for peer id
|
||||
func (k *Ed25519PubKey) PeerId() string {
|
||||
peerId, _ := peer.IdFromSigningPubKey(k)
|
||||
peerId, _ := IdFromSigningPubKey(k)
|
||||
return peerId.String()
|
||||
}
|
||||
|
||||
|
|
|
@ -1,12 +1,11 @@
|
|||
package peer
|
||||
package crypto
|
||||
|
||||
import (
|
||||
utilcrypto "github.com/anytypeio/any-sync/util/crypto"
|
||||
"github.com/libp2p/go-libp2p/core/crypto"
|
||||
"github.com/libp2p/go-libp2p/core/peer"
|
||||
)
|
||||
|
||||
func IdFromSigningPubKey(pubKey utilcrypto.PubKey) (peer.ID, error) {
|
||||
func IdFromSigningPubKey(pubKey PubKey) (peer.ID, error) {
|
||||
rawSigning, err := pubKey.Raw()
|
||||
if err != nil {
|
||||
return "", err
|
Loading…
Add table
Add a link
Reference in a new issue