vault

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2025 License: MIT Imports: 45 Imported by: 11

Documentation

Index

Constants

View Source
const EmailQueueName = "vault:email_queue"
View Source
const EmailVaultBackupTypeName = "key:email"

Variables

View Source
var TssKeyGenTimeout = errors.New("keygen timeout")

Functions

This section is empty.

Types

type BlockStorageImp

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

func NewBlockStorageImp

func NewBlockStorageImp(cfg vault_config.BlockStorage) (*BlockStorageImp, error)

func (*BlockStorageImp) DeleteFile

func (bs *BlockStorageImp) DeleteFile(fileName string) error

func (*BlockStorageImp) Exist

func (bs *BlockStorageImp) Exist(fileName string) (bool, error)

func (*BlockStorageImp) FileExist

func (bs *BlockStorageImp) FileExist(fileName string) (bool, error)

func (*BlockStorageImp) GetFile

func (bs *BlockStorageImp) GetFile(fileName string) ([]byte, error)

func (*BlockStorageImp) GetVault

func (bs *BlockStorageImp) GetVault(fileName string) ([]byte, error)

func (*BlockStorageImp) SaveVault

func (bs *BlockStorageImp) SaveVault(file string, content []byte) error

func (*BlockStorageImp) UploadFile

func (bs *BlockStorageImp) UploadFile(fileContent []byte, fileName string) error

func (*BlockStorageImp) UploadFileWithRetry

func (bs *BlockStorageImp) UploadFileWithRetry(fileContent []byte, fileName string, retry int) error

type DKLSTssService

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

func NewDKLSTssService

func NewDKLSTssService(cfg vault_config.Config,
	storage Storage,
	queueClient *asynq.Client) (*DKLSTssService, error)

func (*DKLSTssService) BackupVault

func (t *DKLSTssService) BackupVault(vaultName, localPartyId, email, pluginId string,
	partiesJoined []string,
	ecdsaPubkey, eddsaPubkey string,
	hexChainCode string,
	localStateAccessor *LocalStateAccessorImp) error

func (*DKLSTssService) GetExistingVault

func (t *DKLSTssService) GetExistingVault(vaultFileName, password string) (*vaultType.Vault, error)

func (*DKLSTssService) GetMPCKeygenWrapper

func (t *DKLSTssService) GetMPCKeygenWrapper(isEdDSA bool) *MPCWrapperImp

func (*DKLSTssService) ProcessDKLSKeygen

func (t *DKLSTssService) ProcessDKLSKeygen(req vgtypes.VaultCreateRequest) (string, string, error)

func (*DKLSTssService) ProcessDKLSKeysign

func (t *DKLSTssService) ProcessDKLSKeysign(req types.KeysignRequest) (map[string]tss.KeysignResponse, error)

func (*DKLSTssService) ProcessReshare

func (t *DKLSTssService) ProcessReshare(vault *vaultType.Vault,
	sessionID string,
	hexEncryptionKey string,
	email string,
	pluginId string) error

func (*DKLSTssService) SaveVaultToStorage

func (t *DKLSTssService) SaveVaultToStorage(vault *vaultType.Vault, email, pluginId string) error

type Handle

type Handle int32

type KeyGenerationTaskResult

type KeyGenerationTaskResult struct {
	EDDSAPublicKey string
	ECDSAPublicKey string
}

KeyGenerationTaskResult is a struct that represents the result of a key generation task

type LocalStateAccessorImp

type LocalStateAccessorImp struct {
	Vault *vaultType.Vault
	// contains filtered or unexported fields
}

func NewLocalStateAccessorImp

func NewLocalStateAccessorImp(vault *vaultType.Vault) *LocalStateAccessorImp

NewLocalStateAccessorImp creates a new instance of LocalStateAccessorImp

func (*LocalStateAccessorImp) GetLocalCacheState

func (l *LocalStateAccessorImp) GetLocalCacheState(pubKey string) (string, error)

func (*LocalStateAccessorImp) GetLocalState

func (l *LocalStateAccessorImp) GetLocalState(pubKey string) (string, error)

func (*LocalStateAccessorImp) SaveLocalState

func (l *LocalStateAccessorImp) SaveLocalState(pubKey, localState string) error

type LocalVaultStorage

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

func NewLocalVaultStorage

func NewLocalVaultStorage(cfg LocalVaultStorageConfig) (*LocalVaultStorage, error)

func (*LocalVaultStorage) DeleteFile

func (lvs *LocalVaultStorage) DeleteFile(fileName string) error

func (*LocalVaultStorage) Exist

func (lvs *LocalVaultStorage) Exist(fileName string) (bool, error)

func (*LocalVaultStorage) GetVault

func (lvs *LocalVaultStorage) GetVault(fileName string) ([]byte, error)

func (*LocalVaultStorage) SaveVault

func (lvs *LocalVaultStorage) SaveVault(file string, content []byte) error

type LocalVaultStorageConfig

type LocalVaultStorageConfig struct {
	VaultFilePath string `mapstructure:"vault_file_path" json:"vault_file_path"`
}

type MPCKeygenWrapper

type MPCKeygenWrapper interface {
	KeygenSetupMsgNew(threshold int, keyID []byte, ids []byte) ([]byte, error)
	KeygenSessionFromSetup(setup []byte, id []byte) (Handle, error)
	KeyRefreshSessionFromSetup(setup []byte, id []byte, oldKeyshare Handle) (Handle, error)
	KeygenSessionOutputMessage(session Handle) ([]byte, error)
	KeygenSessionInputMessage(session Handle, message []byte) (bool, error)
	KeygenSessionMessageReceiver(session Handle, message []byte, index int) (string, error)
	KeygenSessionFinish(session Handle) (Handle, error)
	KeygenSessionFree(session Handle) error
	MigrateSessionFromSetup(setup []byte, id []byte, publicKey []byte, rootChainCode []byte, secretCoefficient []byte) (Handle, error)
}

type MPCKeyshareWrapper

type MPCKeyshareWrapper interface {
	KeyshareFromBytes(buf []byte) (Handle, error)
	KeyshareToBytes(share Handle) ([]byte, error)
	KeysharePublicKey(share Handle) ([]byte, error)
	KeyshareKeyID(share Handle) ([]byte, error)
	KeyshareDeriveChildPublicKey(share Handle, derivationPathStr []byte) ([]byte, error)
	KeyshareToRefreshBytes(share Handle) ([]byte, error)
	RefreshShareFromBytes(buf []byte) (Handle, error)
	RefreshShareToBytes(share Handle) ([]byte, error)
	KeyshareFree(share Handle) error
	KeyshareChainCode(share Handle) ([]byte, error)
}

type MPCKeysignWrapper

type MPCKeysignWrapper interface {
	SignSetupMsgNew(keyID []byte, chainPath []byte, messageHash []byte, ids []byte) ([]byte, error)
	SignSessionFromSetup(setup []byte, id []byte, shareOrPresign Handle) (Handle, error)
	SignSessionOutputMessage(session Handle) ([]byte, error)
	SignSessionMessageReceiver(session Handle, message []byte, index int) ([]byte, error)
	SignSessionInputMessage(session Handle, message []byte) (bool, error)
	SignSessionFinish(session Handle) ([]byte, error)
	SignSessionFree(session Handle) error
}

type MPCQcWrapper

type MPCQcWrapper interface {
	QcSetupMsgNew(keyshareHandle Handle, threshold int, ids []string, oldParties []int, newParties []int) ([]byte, error)
	QcSessionFromSetup(setupMsg []byte, id string, keyshareHandle Handle) (Handle, error)
	QcSessionOutputMessage(session Handle) ([]byte, error)
	QcSessionMessageReceiver(session Handle, message []byte, index int) (string, error)
	QcSessionInputMessage(session Handle, message []byte) (bool, error)
	QcSessionFinish(session Handle) (Handle, error)
}

type MPCSetupWrapper

type MPCSetupWrapper interface {
	DecodeKeyID(setup []byte) ([]byte, error)
	DecodeSessionID(setup []byte) ([]byte, error)
	DecodeMessage(setup []byte) ([]byte, error)
	DecodePartyName(setup []byte, index int) ([]byte, error)
}

type MPCWrapperImp

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

func NewMPCWrapperImp

func NewMPCWrapperImp(isEdDSA bool) *MPCWrapperImp

func (*MPCWrapperImp) DecodeKeyID

func (w *MPCWrapperImp) DecodeKeyID(setup []byte) ([]byte, error)

func (*MPCWrapperImp) DecodeMessage

func (w *MPCWrapperImp) DecodeMessage(setup []byte) ([]byte, error)

func (*MPCWrapperImp) DecodePartyName

func (w *MPCWrapperImp) DecodePartyName(setup []byte, index int) ([]byte, error)

func (*MPCWrapperImp) DecodeSessionID

func (w *MPCWrapperImp) DecodeSessionID(setup []byte) ([]byte, error)

func (*MPCWrapperImp) KeyRefreshSessionFromSetup

func (w *MPCWrapperImp) KeyRefreshSessionFromSetup(setup []byte, id []byte, oldKeyshare Handle) (Handle, error)

func (*MPCWrapperImp) KeygenSessionFinish

func (w *MPCWrapperImp) KeygenSessionFinish(h Handle) (Handle, error)

func (*MPCWrapperImp) KeygenSessionFree

func (w *MPCWrapperImp) KeygenSessionFree(h Handle) error

func (*MPCWrapperImp) KeygenSessionFromSetup

func (w *MPCWrapperImp) KeygenSessionFromSetup(setup []byte, id []byte) (Handle, error)

func (*MPCWrapperImp) KeygenSessionInputMessage

func (w *MPCWrapperImp) KeygenSessionInputMessage(h Handle, message []byte) (bool, error)

func (*MPCWrapperImp) KeygenSessionMessageReceiver

func (w *MPCWrapperImp) KeygenSessionMessageReceiver(h Handle, message []byte, index int) (string, error)

func (*MPCWrapperImp) KeygenSessionOutputMessage

func (w *MPCWrapperImp) KeygenSessionOutputMessage(h Handle) ([]byte, error)

func (*MPCWrapperImp) KeygenSetupMsgNew

func (w *MPCWrapperImp) KeygenSetupMsgNew(threshold int, keyID []byte, ids []byte) ([]byte, error)

func (*MPCWrapperImp) KeyshareChainCode

func (w *MPCWrapperImp) KeyshareChainCode(share Handle) ([]byte, error)

func (*MPCWrapperImp) KeyshareDeriveChildPublicKey

func (w *MPCWrapperImp) KeyshareDeriveChildPublicKey(share Handle, derivationPathStr []byte) ([]byte, error)

func (*MPCWrapperImp) KeyshareFree

func (w *MPCWrapperImp) KeyshareFree(share Handle) error

func (*MPCWrapperImp) KeyshareFromBytes

func (w *MPCWrapperImp) KeyshareFromBytes(buf []byte) (Handle, error)

func (*MPCWrapperImp) KeyshareKeyID

func (w *MPCWrapperImp) KeyshareKeyID(share Handle) ([]byte, error)

func (*MPCWrapperImp) KeysharePublicKey

func (w *MPCWrapperImp) KeysharePublicKey(share Handle) ([]byte, error)

func (*MPCWrapperImp) KeyshareToBytes

func (w *MPCWrapperImp) KeyshareToBytes(share Handle) ([]byte, error)

func (*MPCWrapperImp) KeyshareToRefreshBytes

func (w *MPCWrapperImp) KeyshareToRefreshBytes(share Handle) ([]byte, error)

func (*MPCWrapperImp) MigrateSessionFromSetup

func (w *MPCWrapperImp) MigrateSessionFromSetup(setup []byte, id []byte, publicKey []byte, rootChainCode []byte, secretCoefficient []byte) (Handle, error)

func (*MPCWrapperImp) QcSessionFinish

func (w *MPCWrapperImp) QcSessionFinish(h Handle) (Handle, error)

func (*MPCWrapperImp) QcSessionFromSetup

func (w *MPCWrapperImp) QcSessionFromSetup(setupMsg []byte, id string, keyshareHandle Handle) (Handle, error)

func (*MPCWrapperImp) QcSessionInputMessage

func (w *MPCWrapperImp) QcSessionInputMessage(h Handle, message []byte) (bool, error)

func (*MPCWrapperImp) QcSessionMessageReceiver

func (w *MPCWrapperImp) QcSessionMessageReceiver(h Handle, message []byte, index int) (string, error)

func (*MPCWrapperImp) QcSessionOutputMessage

func (w *MPCWrapperImp) QcSessionOutputMessage(h Handle) ([]byte, error)

func (*MPCWrapperImp) QcSetupMsgNew

func (w *MPCWrapperImp) QcSetupMsgNew(keyshareHandle Handle, threshod int, ids []string, oldParties []int, newParties []int) ([]byte, error)

func (*MPCWrapperImp) RefreshShareFromBytes

func (w *MPCWrapperImp) RefreshShareFromBytes(buf []byte) (Handle, error)

func (*MPCWrapperImp) RefreshShareToBytes

func (w *MPCWrapperImp) RefreshShareToBytes(share Handle) ([]byte, error)

func (*MPCWrapperImp) SignSessionFinish

func (w *MPCWrapperImp) SignSessionFinish(h Handle) ([]byte, error)

func (*MPCWrapperImp) SignSessionFree

func (w *MPCWrapperImp) SignSessionFree(h Handle) error

func (*MPCWrapperImp) SignSessionFromSetup

func (w *MPCWrapperImp) SignSessionFromSetup(setup []byte, id []byte, shareOrPresign Handle) (Handle, error)

func (*MPCWrapperImp) SignSessionInputMessage

func (w *MPCWrapperImp) SignSessionInputMessage(h Handle, message []byte) (bool, error)

func (*MPCWrapperImp) SignSessionMessageReceiver

func (w *MPCWrapperImp) SignSessionMessageReceiver(h Handle, message []byte, index int) ([]byte, error)

func (*MPCWrapperImp) SignSessionOutputMessage

func (w *MPCWrapperImp) SignSessionOutputMessage(h Handle) ([]byte, error)

func (*MPCWrapperImp) SignSetupMsgNew

func (w *MPCWrapperImp) SignSetupMsgNew(keyID []byte, chainPath []byte, messageHash []byte, ids []byte) ([]byte, error)

type ManagementService

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

ManagementService is a struct that represents the vault management service it provides the following capatilities - Keygen -- create vault / reshare vault - Keysign -- sign a message

func NewManagementService

func NewManagementService(
	cfg vault_config.Config,
	queueClient *asynq.Client,
	storage Storage,
	txIndexerService *tx_indexer.Service,
) (*ManagementService, error)

NewManagementService creates a new instance of the ManagementService

func (*ManagementService) HandleKeyGenerationDKLS

func (s *ManagementService) HandleKeyGenerationDKLS(ctx context.Context, t *asynq.Task) error

func (*ManagementService) HandleKeySignDKLS

func (s *ManagementService) HandleKeySignDKLS(ctx context.Context, t *asynq.Task) error

func (*ManagementService) HandleReshareDKLS

func (s *ManagementService) HandleReshareDKLS(ctx context.Context, t *asynq.Task) error

type Storage

type Storage interface {
	GetVault(fileName string) ([]byte, error)
	SaveVault(fileName string, content []byte) error
	Exist(fileName string) (bool, error)
	DeleteFile(fileName string) error
}

Jump to

Keyboard shortcuts

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