reputation

package
v0.0.0-...-5e759bf Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 1, 2023 License: Apache-2.0 Imports: 8 Imported by: 12

Documentation

Overview

Package reputation collects functionality related to the FrostFS reputation system.

The functionality is based on the system described in the FrostFS specification.

Trust type represents simple instances of trust values. PeerToPeerTrust extends Trust to support the direction of trust, i.e. from whom to whom. GlobalTrust is designed as a global measure of trust in a network member. See the docs for each type for details.

Instances can be also used to process FrostFS API V2 protocol messages (see neo.fs.v2.reputation package in https://github.com/TrueCloudLab/frostfs-api).

On client side:

import "github.com/TrueCloudLab/frostfs-api-go/v2/reputation"

var msg reputation.GlobalTrust
trust.WriteToV2(&msg)

// send trust

On server side:

// recv msg

var trust reputation.GlobalTrust
trust.ReadFromV2(msg)

// process trust

Using package types in an application is recommended to potentially work with different protocol versions with which these types are compatible.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ComparePeerKey

func ComparePeerKey(peer PeerID, key []byte) bool

ComparePeerKey checks if the given PeerID corresponds to the party authenticated by the given binary public key.

Types

type GlobalTrust

type GlobalTrust struct {
	// contains filtered or unexported fields
}

GlobalTrust represents the final assessment of trust in the participant of the FrostFS reputation system obtained taking into account all other participants.

GlobalTrust is mutually compatible with github.com/TrueCloudLab/frostfs-api-go/v2/reputation.GlobalTrust message. See ReadFromV2 / WriteToV2 methods.

To submit GlobalTrust value in FrostFS zero instance SHOULD be declared, initialized using Init method and filled using dedicated methods.

func (*GlobalTrust) Init

func (x *GlobalTrust) Init()

Init initializes all internal data of the GlobalTrust required by FrostFS API protocol. Init MUST be called when creating a new global trust instance. Init SHOULD NOT be called multiple times. Init SHOULD NOT be called if the GlobalTrust instance is used for decoding only.

func (GlobalTrust) Manager

func (x GlobalTrust) Manager() (res PeerID)

Manager returns peer set using SetManager.

Zero GlobalTrust has zero manager which is incorrect according to the FrostFS API protocol.

func (GlobalTrust) Marshal

func (x GlobalTrust) Marshal() []byte

Marshal encodes GlobalTrust into a binary format of the FrostFS API protocol (Protocol Buffers with direct field order).

See also Unmarshal.

func (*GlobalTrust) ReadFromV2

func (x *GlobalTrust) ReadFromV2(m reputation.GlobalTrust) error

ReadFromV2 reads GlobalTrust from the reputation.GlobalTrust message. Returns an error if the message is malformed according to the FrostFS API V2 protocol.

See also WriteToV2.

func (*GlobalTrust) SetManager

func (x *GlobalTrust) SetManager(id PeerID)

SetManager sets identifier of the FrostFS reputation system's participant which performed trust estimation.

See also Manager.

func (*GlobalTrust) SetTrust

func (x *GlobalTrust) SetTrust(trust Trust)

SetTrust sets the global trust score of the network to a specific network member.

See also Trust.

func (*GlobalTrust) Sign

func (x *GlobalTrust) Sign(signer frostfscrypto.Signer) error

Sign calculates and writes signature of the GlobalTrust data. Returns signature calculation errors.

Zero GlobalTrust is unsigned.

Note that any GlobalTrust mutation is likely to break the signature, so it is expected to be calculated as a final stage of GlobalTrust formation.

See also VerifySignature.

func (GlobalTrust) Trust

func (x GlobalTrust) Trust() (res Trust)

Trust returns trust set using SetTrust.

Zero GlobalTrust return zero Trust which is incorrect according to the FrostFS API protocol.

func (*GlobalTrust) Unmarshal

func (x *GlobalTrust) Unmarshal(data []byte) error

Unmarshal decodes FrostFS API protocol binary format into the GlobalTrust (Protocol Buffers with direct field order). Returns an error describing a format violation.

See also Marshal.

func (GlobalTrust) VerifySignature

func (x GlobalTrust) VerifySignature() bool

VerifySignature checks if GlobalTrust signature is presented and valid.

Zero GlobalTrust fails the check.

See also Sign.

func (GlobalTrust) WriteToV2

func (x GlobalTrust) WriteToV2(m *reputation.GlobalTrust)

WriteToV2 writes GlobalTrust to the reputation.GlobalTrust message. The message must not be nil.

See also ReadFromV2.

type PeerID

type PeerID struct {
	// contains filtered or unexported fields
}

PeerID represents unique identifier of the peer participating in the FrostFS reputation system.

ID is mutually compatible with github.com/TrueCloudLab/frostfs-api-go/v2/reputation.PeerID message. See ReadFromV2 / WriteToV2 methods.

Instances can be created using built-in var declaration.

func (*PeerID) DecodeString

func (x *PeerID) DecodeString(s string) error

DecodeString decodes string into PeerID according to FrostFS API protocol. Returns an error if s is malformed.

See also DecodeString.

func (PeerID) EncodeToString

func (x PeerID) EncodeToString() string

EncodeToString encodes ID into FrostFS API protocol string.

Zero PeerID is base58 encoding of PeerIDSize zeros.

See also DecodeString.

func (PeerID) PublicKey

func (x PeerID) PublicKey() []byte

PublicKey return public key set using SetPublicKey.

Zero PeerID has zero key which is incorrect according to FrostFS API protocol.

Return value MUST NOT be mutated, make a copy first.

func (*PeerID) ReadFromV2

func (x *PeerID) ReadFromV2(m reputation.PeerID) error

ReadFromV2 reads PeerID from the reputation.PeerID message. Returns an error if the message is malformed according to the FrostFS API V2 protocol.

See also WriteToV2.

func (*PeerID) SetPublicKey

func (x *PeerID) SetPublicKey(key []byte)

SetPublicKey sets PeerID as a binary-encoded public key which authenticates the participant of the FrostFS reputation system.

Argument MUST NOT be mutated, make a copy first.

See also CompareKey.

func (PeerID) String

func (x PeerID) String() string

String implements fmt.Stringer.

String is designed to be human-readable, and its format MAY differ between SDK versions. String MAY return same result as EncodeToString. String MUST NOT be used to encode ID into FrostFS protocol string.

func (PeerID) WriteToV2

func (x PeerID) WriteToV2(m *reputation.PeerID)

WriteToV2 writes PeerID to the reputation.PeerID message. The message must not be nil.

See also ReadFromV2.

type PeerToPeerTrust

type PeerToPeerTrust struct {
	// contains filtered or unexported fields
}

PeerToPeerTrust represents trust of one participant of the FrostFS reputation system to another one.

Trust is mutually compatible with github.com/TrueCloudLab/frostfs-api-go/v2/reputation.PeerToPeerTrust message. See ReadFromV2 / WriteToV2 methods.

Instances can be created using built-in var declaration.

func (*PeerToPeerTrust) ReadFromV2

ReadFromV2 reads PeerToPeerTrust from the reputation.PeerToPeerTrust message. Returns an error if the message is malformed according to the FrostFS API V2 protocol.

See also WriteToV2.

func (*PeerToPeerTrust) SetTrust

func (x *PeerToPeerTrust) SetTrust(t Trust)

SetTrust sets trust value of the trusting peer to another participant of the FrostFS reputation system.

See also Trust.

func (*PeerToPeerTrust) SetTrustingPeer

func (x *PeerToPeerTrust) SetTrustingPeer(id PeerID)

SetTrustingPeer specifies the peer from which trust comes in terms of the FrostFS reputation system.

See also TrustingPeer.

func (PeerToPeerTrust) Trust

func (x PeerToPeerTrust) Trust() (res Trust)

Trust returns trust set using SetTrust.

Zero PeerToPeerTrust returns zero Trust which is incorect according to the FrostFS API protocol.

func (PeerToPeerTrust) TrustingPeer

func (x PeerToPeerTrust) TrustingPeer() (res PeerID)

TrustingPeer returns peer set using SetTrustingPeer.

Zero PeerToPeerTrust has no trusting peer which is incorrect according to the FrostFS API protocol.

func (PeerToPeerTrust) WriteToV2

func (x PeerToPeerTrust) WriteToV2(m *reputation.PeerToPeerTrust)

WriteToV2 writes PeerToPeerTrust to the reputation.PeerToPeerTrust message. The message must not be nil.

See also ReadFromV2.

type Trust

type Trust struct {
	// contains filtered or unexported fields
}

Trust represents quantitative assessment of the trust of a participant in the FrostFS reputation system.

Trust is mutually compatible with github.com/TrueCloudLab/frostfs-api-go/v2/reputation.Trust message. See ReadFromV2 / WriteToV2 methods.

Instances can be created using built-in var declaration.

func (Trust) Peer

func (x Trust) Peer() (res PeerID)

Peer returns peer identifier set using SetPeer.

Zero Trust returns zero PeerID which is incorrect according to the FrostFS API protocol.

func (*Trust) ReadFromV2

func (x *Trust) ReadFromV2(m reputation.Trust) error

ReadFromV2 reads Trust from the reputation.Trust message. Returns an error if the message is malformed according to the FrostFS API V2 protocol.

See also WriteToV2.

func (*Trust) SetPeer

func (x *Trust) SetPeer(id PeerID)

SetPeer specifies identifier of the participant of the FrostFS reputation system to which the Trust relates.

See also Peer.

func (*Trust) SetValue

func (x *Trust) SetValue(val float64)

SetValue sets the Trust value. Value MUST be in range [0;1].

See also Value.

func (Trust) Value

func (x Trust) Value() float64

Value returns value set using SetValue.

Zero Trust has zero value.

func (Trust) WriteToV2

func (x Trust) WriteToV2(m *reputation.Trust)

WriteToV2 writes Trust to the reputation.Trust message. The message must not be nil.

See also ReadFromV2.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL