specters

package
v0.0.0-...-d0ade2f Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2022 License: GPL-3.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const ShamirParts = 5

ShamirParts is the number of parts generating by shamir algorithm

View Source
const ShamirThreshold = 3

ShamirThreshold is the necessary number of parts for unsealing process

Variables

This section is empty.

Functions

func DecodeKey

func DecodeKey(b string) ([]byte, error)

DecodeKey decodes from b64 to a byte array that can be unmarshalled.

func DefaultBoostrapPeers

func DefaultBoostrapPeers() (peers []peer.AddrInfo, err error)

DefaultBoostrapPeers returns the default bootstrap peers for Specters

func EncodeKey

func EncodeKey(b []byte) string

EncodeKey encodes a marshalled key to b64.

Types

type Config

type Config struct {
	Debug bool
}

Config is a type with default config for Specters

type Identity

type Identity interface {
	encoding.BinaryMarshaler
	encoding.BinaryUnmarshaler

	db.PrivateKeyDB

	// Raw returns the raw bytes of the key (not wrapped in the
	// libp2p-crypto protobuf).
	//
	// This function is the inverse of {Priv,Pub}KeyUnmarshaler.
	Raw() ([]byte, error)

	// Sign the given bytes cryptographically.
	Sign([]byte) ([]byte, error)

	// GetPublic returns the public key paired with this identity.
	GetPublic() PubKey
}

Identity represents an entity capable of signing a message and returning the associated public key for verification.

func NewLibP2PIdentity

func NewLibP2PIdentity(key crypto.PrivKey) Identity

NewLibP2PIdentity returns a new LibP2PIdentity.

func UnmarshalLibP2PIdentity

func UnmarshalLibP2PIdentity(data []byte) (Identity, error)

UnmarshalLibP2PIdentity converts a protobuf serialized LibP2PIdentity into its representative object

type LibP2PIdentity

type LibP2PIdentity struct {
	crypto.PrivKey
}

LibP2PIdentity wraps crypto.PrivKey, overwriting GetPublic with specters.PubKey.

func (*LibP2PIdentity) GetPublic

func (p *LibP2PIdentity) GetPublic() PubKey

GetPublic returns the public key paired with this identity.

func (*LibP2PIdentity) GetPublicDB

func (p *LibP2PIdentity) GetPublicDB() db.PublicKeyDB

GetPublicDB returns the public key DB paired with this identity.

func (*LibP2PIdentity) MarshalBinary

func (p *LibP2PIdentity) MarshalBinary() ([]byte, error)

MarshalBinary converts an identity object into its protobuf serialized form.

func (*LibP2PIdentity) Raw

func (p *LibP2PIdentity) Raw() ([]byte, error)

Raw returns the raw bytes of the key (not wrapped in the libp2p-crypto protobuf).

This function is the inverse of {Priv,Pub}KeyUnmarshaler.

func (*LibP2PIdentity) Sign

func (p *LibP2PIdentity) Sign(data []byte) ([]byte, error)

Sign the given bytes cryptographically.

func (*LibP2PIdentity) UnmarshalBinary

func (p *LibP2PIdentity) UnmarshalBinary(data []byte) error

UnmarshalBinary converts a protobuf serialized identity into its representative object

type LibP2PPubKey

type LibP2PPubKey struct {
	crypto.PubKey
}

LibP2PPubKey wraps crypto.PubKey.

func (*LibP2PPubKey) MarshalBinary

func (p *LibP2PPubKey) MarshalBinary() ([]byte, error)

MarshalBinary converts an identity object into its protobuf serialized form.

func (*LibP2PPubKey) Raw

func (p *LibP2PPubKey) Raw() ([]byte, error)

Raw returns the raw bytes of the key (not wrapped in the libp2p-crypto protobuf).

This function is the inverse of {Priv,Pub}KeyUnmarshaler.

func (*LibP2PPubKey) UnmarshalBinary

func (p *LibP2PPubKey) UnmarshalBinary(data []byte) error

UnmarshalBinary converts a protobuf serialized identity into its representative object

func (*LibP2PPubKey) Verify

func (p *LibP2PPubKey) Verify(data []byte, sigBytes []byte) (bool, error)

Verify that 'sig' is the signed hash of 'data'

type NewSpecterOption

type NewSpecterOption func(*NewSpecterOptions)

NewSpecterOption specifies a new Specter option.

func WithAlias

func WithAlias(alias string) NewSpecterOption

WithAlias provides control over alias for Specter.

type NewSpecterOptions

type NewSpecterOptions struct {
	Alias string
}

NewSpecterOptions defines options for creating a new Specter.

type PubKey

type PubKey interface {
	encoding.BinaryMarshaler
	encoding.BinaryUnmarshaler

	// Raw returns the raw bytes of the key (not wrapped in the
	// libp2p-crypto protobuf).
	//
	// This function is the inverse of {Priv,Pub}KeyUnmarshaler.
	Raw() ([]byte, error)

	// Verify that 'sig' is the signed hash of 'data'
	Verify([]byte, []byte) (bool, error)
}

PubKey can be anything that provides a verify method.

func NewLibP2PPubKey

func NewLibP2PPubKey(key crypto.PubKey) PubKey

NewLibP2PPubKey returns a new PubKey.

func UnmarshalLibP2PPubKey

func UnmarshalLibP2PPubKey(data []byte) (PubKey, error)

UnmarshalLibP2PPubKey converts a protobuf serialized LibP2PPubKey into its representative object

type Specter

type Specter interface {
	PubKey
	db.InstanceDB

	// Init initializes the keys
	Init() error

	// GetPubKey gets the public key
	GetPubKey() string
}

Specter is an app interface for Specter identity

func NewSpecterDB

func NewSpecterDB(pk string, opts ...NewSpecterOption) (s Specter, err error)

NewSpecterDB creates a new instance of SpecterDB

type SpecterDB

type SpecterDB struct {
	ID        string `json:"_id"`
	PubKey    string `json:"public_key"`
	Alias     string `json:"alias"`
	CreatedAt int64  `json:"created_at"`
	Signature string `json:"signature"`
	// contains filtered or unexported fields
}

SpecterDB is Textile Threads DB specter identity

func (*SpecterDB) GetID

func (s *SpecterDB) GetID() db.InstanceID

GetID gets the ID of InstanceDB

func (*SpecterDB) GetPubKey

func (s *SpecterDB) GetPubKey() string

GetPubKey gets the public key

func (*SpecterDB) Init

func (s *SpecterDB) Init() error

Init initializes the keys

func (*SpecterDB) MarshalBinary

func (s *SpecterDB) MarshalBinary() ([]byte, error)

MarshalBinary converts an identity object into its protobuf serialized form.

func (*SpecterDB) Raw

func (s *SpecterDB) Raw() ([]byte, error)

Raw returns the raw bytes of the key (not wrapped in the libp2p-crypto protobuf).

This function is the inverse of {Priv,Pub}KeyUnmarshaler.

func (*SpecterDB) SetID

func (s *SpecterDB) SetID(id db.InstanceID)

SetID sets the ID on InstanceDB

func (*SpecterDB) SignInstance

func (s *SpecterDB) SignInstance(pk db.PrivateKeyDB) (err error)

SignInstance the given instance cryptographically.

func (*SpecterDB) UnmarshalBinary

func (s *SpecterDB) UnmarshalBinary(data []byte) error

UnmarshalBinary converts a protobuf serialized identity into its representative object

func (*SpecterDB) Verify

func (s *SpecterDB) Verify(data []byte, sigBytes []byte) (bool, error)

Verify that 'sig' is the signed hash of 'data'

func (*SpecterDB) VerifyInstance

func (s *SpecterDB) VerifyInstance(pk db.PublicKeyDB) (bool, error)

VerifyInstance that 'sig' is the signed hash of instance

type Specters

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

Specters is an app for specters orchestration

func NewSpecters

func NewSpecters(ctx context.Context, clusterID string, version string, db db.DB, config Config) (*Specters, error)

NewSpecters creates a new instance of Specters

func (*Specters) ClusterID

func (s *Specters) ClusterID() string

ClusterID returns the Specters clusterID

func (*Specters) GetSpecterByPubKey

func (s *Specters) GetSpecterByPubKey(pk string) (specter Specter, err error)

GetSpecterByPubKey returns a registered Specter identity from a public key

func (*Specters) GetToken

func (s *Specters) GetToken(specter Specter) (string, error)

GetToken returns a token for a valid Specter

func (*Specters) HasSpecters

func (s *Specters) HasSpecters() (bool, error)

HasSpecters returns if at least one specter exists

func (*Specters) Init

func (s *Specters) Init(pk []byte) ([][]byte, error)

Init generates a master identity split in several parts

func (*Specters) IsInitialized

func (s *Specters) IsInitialized() bool

IsInitialized returns if Specters is already initialized

func (*Specters) IsSealed

func (s *Specters) IsSealed() bool

IsSealed gets if the Specters' manager is sealed

func (*Specters) SetIdentity

func (s *Specters) SetIdentity(identity Identity)

SetIdentity set the identity for the Specters manager

func (*Specters) Unseal

func (s *Specters) Unseal(part []byte) error

Unseal set a part to unseal the master key and set it if the enough parts are set

func (*Specters) UnsealProgress

func (s *Specters) UnsealProgress() int

UnsealProgress gets the number of parts provided to unseal the Specters manager

func (*Specters) Version

func (s *Specters) Version() string

Version returns the Specters version

Jump to

Keyboard shortcuts

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