ea043f4ca3
Remove `signature` and `util/signature` packages. Re-implement their functionality in new `crypto` package. Generalize the approach of digital signature computation and verification by adding `Signer` and `PublicKey` primitives similar to standard `crypto` package. Support already exising in protocol signature schemes. Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
58 lines
998 B
Go
58 lines
998 B
Go
package reputationtest
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/nspcc-dev/neo-go/pkg/crypto/keys"
|
|
"github.com/nspcc-dev/neofs-sdk-go/reputation"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func PeerID() *reputation.PeerID {
|
|
v := reputation.NewPeerID()
|
|
|
|
p, err := keys.NewPrivateKey()
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
|
|
key := [33]byte{}
|
|
copy(key[:], p.Bytes())
|
|
v.SetPublicKey(key)
|
|
|
|
return v
|
|
}
|
|
|
|
func Trust() *reputation.Trust {
|
|
v := reputation.NewTrust()
|
|
v.SetPeer(PeerID())
|
|
v.SetValue(1.5)
|
|
|
|
return v
|
|
}
|
|
|
|
func PeerToPeerTrust() *reputation.PeerToPeerTrust {
|
|
v := reputation.NewPeerToPeerTrust()
|
|
v.SetTrustingPeer(PeerID())
|
|
v.SetTrust(Trust())
|
|
|
|
return v
|
|
}
|
|
|
|
func GlobalTrust() *reputation.GlobalTrust {
|
|
v := reputation.NewGlobalTrust()
|
|
v.SetManager(PeerID())
|
|
v.SetTrust(Trust())
|
|
|
|
return v
|
|
}
|
|
|
|
func SignedGlobalTrust(t testing.TB) *reputation.GlobalTrust {
|
|
gt := GlobalTrust()
|
|
|
|
p, err := keys.NewPrivateKey()
|
|
require.NoError(t, err)
|
|
require.NoError(t, gt.Sign(&p.PrivateKey))
|
|
|
|
return gt
|
|
}
|