signer

package
v0.18.5 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2024 License: Apache-2.0 Imports: 42 Imported by: 0

README

signer

The signer MTG receives operation requests from mixin kernel transactions, the operation is encoded in the common/operation.go format.

There are two types of operation requests available, and each operation should use a unique session id in the operation body.

  1. OperationTypeKeygenInput requests the MTG to start a new MPC key generation.
  2. OperationTypeSignInput requests the MTG to start a new MPC message signature.

Both operations may succeed or fail, and the signer MTG doesn't guarantee the success. If the operation succeeds, the signer MTG will respond the result with kernel transaction, otherwise, the signer MTG does nothing.

The requester can only assume the operation failed after around 10 minutes timeout, because the signer MTG won't respond. If the requester wants assurance of a successful operation request, it should have a mechanism to start a new operation request with a new session id.

Security

The signer MTG authenticate operation requests through two methods:

  1. The operation is encrypted by a shared AES key between the signer MTG and requester.
  2. The signer MTG only accepts one valid mixin asset as the request transactions.

So the requester should keep the AES key safe and make sure nobody has access to the mixin asset.

Documentation

Index

Constants

View Source
const (
	SessionTimeout       = time.Hour
	KernelTimeout        = 3 * time.Minute
	OperationExtraLimit  = 128
	MPCFirstMessageRound = 2
	PrepareExtra         = "PREPARE"
)

Variables

View Source
var SCHEMA string

Functions

func TestCMPPrepareKeys

func TestCMPPrepareKeys(ctx context.Context, require *require.Assertions, nodes []*Node, crv byte) (string, string)

func TestFROSTPrepareKeys added in v0.11.0

func TestFROSTPrepareKeys(ctx context.Context, require *require.Assertions, nodes []*Node, curve uint8) string

func TestProcessOutput added in v0.11.0

func TestProcessOutput(ctx context.Context, require *require.Assertions, nodes []*Node, out *mtg.Action, sessionId string) *common.Operation

Types

type Configuration

type Configuration struct {
	AppId                   string             `toml:"app-id"`
	KeeperAppId             string             `toml:"keeper-app-id"`
	StoreDir                string             `toml:"store-dir"`
	MessengerConversationId string             `toml:"messenger-conversation-id"`
	MonitorConversaionId    string             `toml:"monitor-conversation-id"`
	ObserverUserId          string             `toml:"observer-user-id"`
	Threshold               int                `toml:"threshold"`
	SharedKey               string             `toml:"shared-key"`
	AssetId                 string             `toml:"asset-id"`
	KeeperAssetId           string             `toml:"keeper-asset-id"`
	KeeperPublicKey         string             `toml:"keeper-public-key"`
	SaverAPI                string             `toml:"saver-api"`
	SaverKey                string             `toml:"saver-key"`
	MixinRPC                string             `toml:"mixin-rpc"`
	MTG                     *mtg.Configuration `toml:"mtg"`
}

func (*Configuration) Messenger

func (c *Configuration) Messenger() *messenger.MixinConfiguration

type Key added in v0.13.0

type Key struct {
	Public      string
	Fingerprint string
	Curve       byte
	Share       string
	SessionId   string
	CreatedAt   time.Time
	BackedUpAt  sql.NullTime
}

type KeygenResult

type KeygenResult struct {
	Public []byte
	Share  []byte
	SSID   []byte
}

type MultiPartySession added in v0.9.6

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

type Network

type Network interface {
	ReceiveMessage(context.Context) (*messenger.MixinMessage, error)
	QueueMessage(ctx context.Context, receiver string, b []byte) error
}

type Node

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

func NewNode

func NewNode(store *SQLite3Store, group *mtg.Group, network Network, conf *Configuration, keeper *mtg.Configuration, mixin *mixin.Client) *Node

func TestPrepare

func TestPrepare(require *require.Assertions) (context.Context, []*Node, *saver.SQLite3Store)

func (*Node) Boot

func (node *Node) Boot(ctx context.Context)

func (*Node) DailyWorks added in v0.9.13

func (node *Node) DailyWorks(ctx context.Context, now time.Time) []byte

TODO put all works query to the custodian module

func (*Node) GetKeepers added in v0.18.3

func (node *Node) GetKeepers() []string

func (*Node) GetMembers added in v0.18.3

func (node *Node) GetMembers() []string

func (*Node) GetPartySlice added in v0.18.3

func (node *Node) GetPartySlice() party.IDSlice

func (*Node) Index

func (node *Node) Index() int

func (*Node) ProcessOutput

func (node *Node) ProcessOutput(ctx context.Context, out *mtg.Action) ([]*mtg.Transaction, string)

type SQLite3Store

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

func OpenSQLite3Store

func OpenSQLite3Store(path string) (*SQLite3Store, error)

func (*SQLite3Store) CheckActionResultsBySessionId added in v0.13.5

func (s *SQLite3Store) CheckActionResultsBySessionId(ctx context.Context, sessionId string) bool

func (*SQLite3Store) Close

func (s *SQLite3Store) Close() error

func (*SQLite3Store) CountDailyWorks added in v0.9.13

func (s *SQLite3Store) CountDailyWorks(ctx context.Context, members []party.ID, begin, end time.Time) ([]int, error)

func (*SQLite3Store) FailSession

func (s *SQLite3Store) FailSession(ctx context.Context, sessionId string) error

func (*SQLite3Store) ListInitialSessions added in v0.9.11

func (s *SQLite3Store) ListInitialSessions(ctx context.Context, limit int) ([]*Session, error)

func (*SQLite3Store) ListPendingSessions added in v0.9.11

func (s *SQLite3Store) ListPendingSessions(ctx context.Context, limit int) ([]*Session, error)

func (*SQLite3Store) ListPreparedSessions added in v0.10.0

func (s *SQLite3Store) ListPreparedSessions(ctx context.Context, limit int) ([]*Session, error)

func (*SQLite3Store) ListSessionPreparedMembers added in v0.10.0

func (s *SQLite3Store) ListSessionPreparedMembers(ctx context.Context, sessionId string, threshold int) ([]party.ID, error)

func (*SQLite3Store) ListSessionSignerResults added in v0.10.0

func (s *SQLite3Store) ListSessionSignerResults(ctx context.Context, sessionId string) (map[string]string, error)

func (*SQLite3Store) ListUnbackupedKeys added in v0.13.0

func (s *SQLite3Store) ListUnbackupedKeys(ctx context.Context, threshold int) ([]*Key, error)

func (*SQLite3Store) MarkKeyBackuped added in v0.13.0

func (s *SQLite3Store) MarkKeyBackuped(ctx context.Context, public string) error

func (*SQLite3Store) MarkSessionCommitted added in v0.10.0

func (s *SQLite3Store) MarkSessionCommitted(ctx context.Context, sessionId string) error

func (*SQLite3Store) MarkSessionDone

func (s *SQLite3Store) MarkSessionDone(ctx context.Context, sessionId string) error

func (*SQLite3Store) MarkSessionPending added in v0.10.0

func (s *SQLite3Store) MarkSessionPending(ctx context.Context, sessionId string, curve uint8, fingerprint string, extra []byte) error

func (*SQLite3Store) MarkSessionPrepared added in v0.10.0

func (s *SQLite3Store) MarkSessionPrepared(ctx context.Context, sessionId string, preparedAt time.Time) error

func (*SQLite3Store) Migrate added in v0.13.0

func (s *SQLite3Store) Migrate(ctx context.Context) error

func (*SQLite3Store) Migrate2 added in v0.13.4

func (s *SQLite3Store) Migrate2(ctx context.Context) error

func (*SQLite3Store) PrepareSessionSignerIfNotExist added in v0.10.0

func (s *SQLite3Store) PrepareSessionSignerIfNotExist(ctx context.Context, sessionId, signerId string, createdAt time.Time) error

func (*SQLite3Store) ReadActionResults added in v0.13.5

func (s *SQLite3Store) ReadActionResults(ctx context.Context, outputId string) ([]*mtg.Transaction, string, bool)

func (*SQLite3Store) ReadKeyByFingerprint added in v0.3.0

func (s *SQLite3Store) ReadKeyByFingerprint(ctx context.Context, sum string) (string, uint8, []byte, error)

func (*SQLite3Store) ReadProperty

func (s *SQLite3Store) ReadProperty(ctx context.Context, k string) (string, error)

func (*SQLite3Store) ReadSession

func (s *SQLite3Store) ReadSession(ctx context.Context, sessionId string) (*Session, error)

func (*SQLite3Store) SessionsState added in v0.9.11

func (s *SQLite3Store) SessionsState(ctx context.Context) (*State, error)

func (*SQLite3Store) UpdateSessionSigner added in v0.10.0

func (s *SQLite3Store) UpdateSessionSigner(ctx context.Context, sessionId, signerId string, extra []byte, updatedAt time.Time, self bool) error

func (*SQLite3Store) WriteActionResults added in v0.13.5

func (s *SQLite3Store) WriteActionResults(ctx context.Context, outputId string, txs []*mtg.Transaction, compaction, sessionId string) error

func (*SQLite3Store) WriteKeyIfNotExists

func (s *SQLite3Store) WriteKeyIfNotExists(ctx context.Context, sessionId string, curve uint8, public string, conf []byte, saved bool) error

func (*SQLite3Store) WriteProperty

func (s *SQLite3Store) WriteProperty(ctx context.Context, k, v string) error

func (*SQLite3Store) WriteSessionIfNotExist

func (s *SQLite3Store) WriteSessionIfNotExist(ctx context.Context, op *common.Operation, transaction crypto.Hash, outputIndex int, createdAt time.Time, needsCommittment bool) error

func (*SQLite3Store) WriteSessionSignerIfNotExist

func (s *SQLite3Store) WriteSessionSignerIfNotExist(ctx context.Context, sessionId, signerId string, extra []byte, createdAt time.Time, self bool) error

func (*SQLite3Store) WriteSessionWorkIfNotExist added in v0.9.13

func (s *SQLite3Store) WriteSessionWorkIfNotExist(ctx context.Context, sessionId, signerId string, round int, extra []byte) error

type Session

type Session struct {
	Id         string
	MixinHash  string
	MixinIndex int
	Operation  byte
	Curve      byte
	Public     string
	Extra      string
	State      byte
	CreatedAt  time.Time
	PreparedAt sql.NullTime
}

type SignResult

type SignResult struct {
	Signature []byte
	SSID      []byte
}

type State added in v0.9.11

type State struct {
	Initial int
	Pending int
	Done    int
	Keys    int
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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