signer

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: May 18, 2023 License: Apache-2.0 Imports: 33 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 (
	OperationExtraLimit  = 128
	MPCFirstMessageRound = 2
)

Variables

View Source
var SCHEMA string

Functions

func TestCMPPrepareKeys

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

func TestCMPProcessOutput

func TestCMPProcessOutput(ctx context.Context, assert *assert.Assertions, nodes []*Node, out *mtg.Output, sessionId string) *common.Operation

Types

type Configuration

type Configuration struct {
	StoreDir                string             `toml:"store-dir"`
	MessengerConversationId string             `toml:"messenger-conversation-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"`
	MixinRPC                string             `toml:"mixin-rpc"`
	MTG                     *mtg.Configuration `toml:"mtg"`
}

func (*Configuration) Messenger

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

type KeygenResult

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

type Network

type Network interface {
	ReceiveMessage(context.Context) (string, []byte, error)
	QueueMessage(ctx context.Context, receiver string, b []byte) error
	BroadcastMessage(ctx context.Context, 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(assert *assert.Assertions) (context.Context, []*Node)

func (*Node) Boot

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

func (*Node) Index

func (node *Node) Index() int

func (*Node) ProcessCollectibleOutput

func (node *Node) ProcessCollectibleOutput(context.Context, *mtg.CollectibleOutput)

func (*Node) ProcessOutput

func (node *Node) ProcessOutput(ctx context.Context, out *mtg.Output)

type SQLite3Store

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

func OpenSQLite3Store

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

func (*SQLite3Store) Close

func (s *SQLite3Store) Close() error

func (*SQLite3Store) FailSession

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

func (*SQLite3Store) FinishSignSession

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

func (*SQLite3Store) ListSessionSigners

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

func (*SQLite3Store) ListSessions

func (s *SQLite3Store) ListSessions(ctx context.Context, state, limit int) ([]*common.Operation, error)

func (*SQLite3Store) MarkSessionDone

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

func (*SQLite3Store) ReadKeyByShortSum

func (s *SQLite3Store) ReadKeyByShortSum(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) WriteKeyIfNotExists

func (s *SQLite3Store) WriteKeyIfNotExists(ctx context.Context, sessionId string, curve uint8, public string, conf []byte) 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) error

func (*SQLite3Store) WriteSessionSignerIfNotExist

func (s *SQLite3Store) WriteSessionSignerIfNotExist(ctx context.Context, sessionId, signerId string, extra []byte, createdAt time.Time, self bool) 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
}

type SignResult

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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