pkg

package
v0.1.9 Latest Latest
Warning

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

Go to latest
Published: May 6, 2025 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Address

type Address string

func (Address) String

func (s Address) String() string

type Identifier

type Identifier interface {
	Identity() string
}

Identifier is the interface that defines how an object can be used as an identity

type IdentityManager

type IdentityManager interface {
	// Store returns the key store kind
	StoreKind() string

	// NodeID returns the node id (public key)
	NodeID() StrIdentifier

	// FarmID return the farm id this node is part of. this is usually a configuration
	// that the node is booted with. An error is returned if the farmer id is not configured
	FarmID() pkg.FarmID

	// Farm returns name of the farm. Or error
	Farm() (string, error)

	// FarmSecret get the farm secret as defined in the boot params
	FarmSecret() string

	// Sign signs the message with privateKey and returns a signature.
	Sign(message []byte) ([]byte, error)

	// Verify reports whether sig is a valid signature of message by publicKey.
	Verify(message, sig []byte) error

	// Encrypt encrypts message with the public key of the node
	Encrypt(message []byte) ([]byte, error)

	// Decrypt decrypts message with the private of the node
	Decrypt(message []byte) ([]byte, error)

	// EncryptECDH aes encrypt msg using a shared key derived from private key of the node and public key of the other party using Elliptic curve Diffie Helman algorithm
	// the nonce if prepended to the encrypted message
	EncryptECDH(msg []byte, publicKey []byte) ([]byte, error)

	// DecryptECDH decrypt aes encrypted msg using a shared key derived from private key of the node and public key of the other party using Elliptic curve Diffie Helman algorithm
	DecryptECDH(msg []byte, publicKey []byte) ([]byte, error)

	// PrivateKey sends the keypair
	PrivateKey() []byte
}

IdentityManager interface.

type Registrar

type Registrar interface {
	NodeID() (uint32, error)
	TwinID() (uint32, error)
}

type RegistrarGateway

type RegistrarGateway interface {
	CreateTwin(relay []string, rmbEncKey string) (client.Account, error)
	EnsureAccount(relay []string, rmbEncKey string) (twin client.Account, err error)
	GetTwin(id uint64) (client.Account, error)
	GetTwinByPubKey(pk []byte) (uint64, error)

	CreateNode(node client.Node) (uint64, error)
	GetNode(id uint64) (client.Node, error)
	GetNodes(farmID uint64) ([]uint64, error)
	GetNodeByTwinID(twin uint64) (client.Node, error)
	UpdateNode(node client.Node) error
	UpdateNodeUptimeV2(uptime uint64, timestamp int64) (err error)

	GetFarm(id uint64) (client.Farm, error)

	GetTime() (time.Time, error)
	GetZosVersion() (client.ZosVersion, error)

	GetNodeContracts(node uint32) ([]substrateTypes.U64, error)
	GetContract(id uint64) (substrate.Contract, pkg.SubstrateError)
	GetContractIDByNameRegistration(name string) (uint64, pkg.SubstrateError)
	GetNodeRentContract(node uint32) (uint64, pkg.SubstrateError)
	GetPowerTarget() (power substrate.NodePower, err error)
	Report(consumptions []substrate.NruConsumption) (substrateTypes.Hash, error)
	SetContractConsumption(resources ...substrate.ContractResources) error
	SetNodePowerState(up bool) (hash substrateTypes.Hash, err error)
}

type StrIdentifier

type StrIdentifier string

StrIdentifier is a helper type that implement the Identifier interface on top of simple string

func (StrIdentifier) Identity

func (s StrIdentifier) Identity() string

Identity implements the Identifier interface

Directories

Path Synopsis
Package provision exposes the Engine type.
Package provision exposes the Engine type.

Jump to

Keyboard shortcuts

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