diff --git a/diagram.png b/diagram.png deleted file mode 100644 index 562695ed..00000000 Binary files a/diagram.png and /dev/null differ diff --git a/diagram.puml b/diagram.puml deleted file mode 100644 index e619b620..00000000 --- a/diagram.puml +++ /dev/null @@ -1,774 +0,0 @@ -@startuml -legend -Legend -Render Aggregations: true -Render Fields: true -Render Methods: true -Pritave Aggregations: false -end legend -namespace cmd { - class AddressCmdOutput << (S,Aquamarine) >> { - + HexAddress string - + ValConsAddress string - - } - class ChainNode << (S,Aquamarine) >> { - + PrivValAddr string - - } - class Config << (S,Aquamarine) >> { - + HomeDir string - + PrivValKeyFile string - + ChainID string - + CosignerConfig *CosignerConfig - + ChainNodes []ChainNode - - + Nodes() []signer.NodeConfig - + MustMarshalYaml() []byte - + CosignerPeers() []signer.CosignerConfig - - } - class CosignerConfig << (S,Aquamarine) >> { - + Threshold int - + Shares int - + P2PListen string - + Peers []CosignerPeer - + Timeout string - - } - class CosignerPeer << (S,Aquamarine) >> { - + ShareID int - + P2PAddr string - - } - class Info << (S,Aquamarine) >> { - + Version string - + GitCommit string - + GoVersion string - + CosmosSdkVersion string - + TendermintVersion string - - } -} - - -"cmd.Config""uses" o-- "cmd.ChainNode" -"cmd.Config""uses" o-- "cmd.CosignerConfig" -"cmd.CosignerConfig""uses" o-- "cmd.CosignerPeer" - -namespace proto { - class Block << (S,Aquamarine) >> { - - state protoimpl.MessageState - - sizeCache protoimpl.SizeCache - - unknownFields protoimpl.UnknownFields - - + Height int64 - + Round int64 - + Step int32 - + SignBytes []byte - + Timestamp int64 - - + Reset() - + String() string - + ProtoMessage() - + ProtoReflect() protoreflect.Message - + Descriptor() ([]byte, []int) - + GetHeight() int64 - + GetRound() int64 - + GetStep() int32 - + GetSignBytes() []byte - + GetTimestamp() int64 - - } - interface CosignerGRPCClient { - + SignBlock(ctx "context.Context, in *CosignerGRPCSignBlockRequest, opts ...grpc.CallOption) (*CosignerGRPCSignBlockResponse, error) - + SetEphemeralSecretPartsAndSign(ctx "context.Context, in *CosignerGRPCSetEphemeralSecretPartsAndSignRequest, opts ...grpc.CallOption) (*CosignerGRPCSetEphemeralSecretPartsAndSignResponse, error) - + GetEphemeralSecretParts(ctx "context.Context, in *CosignerGRPCGetEphemeralSecretPartsRequest, opts ...grpc.CallOption) (*CosignerGRPCGetEphemeralSecretPartsResponse, error) - + TransferLeadership(ctx "context.Context, in *CosignerGRPCTransferLeadershipRequest, opts ...grpc.CallOption) (*CosignerGRPCTransferLeadershipResponse, error) - - } - class CosignerGRPCGetEphemeralSecretPartsRequest << (S,Aquamarine) >> { - - state protoimpl.MessageState - - sizeCache protoimpl.SizeCache - - unknownFields protoimpl.UnknownFields - - + Hrst *HRST - - + Reset() - + String() string - + ProtoMessage() - + ProtoReflect() protoreflect.Message - + Descriptor() ([]byte, []int) - + GetHrst() *HRST - - } - class CosignerGRPCGetEphemeralSecretPartsResponse << (S,Aquamarine) >> { - - state protoimpl.MessageState - - sizeCache protoimpl.SizeCache - - unknownFields protoimpl.UnknownFields - - + EncryptedSecrets []*EphemeralSecretPart - - + Reset() - + String() string - + ProtoMessage() - + ProtoReflect() protoreflect.Message - + Descriptor() ([]byte, []int) - + GetEncryptedSecrets() []*EphemeralSecretPart - - } - interface CosignerGRPCServer { - - mustEmbedUnimplementedCosignerGRPCServer() - - + SignBlock( "context.Context, *CosignerGRPCSignBlockRequest) (*CosignerGRPCSignBlockResponse, error) - + SetEphemeralSecretPartsAndSign( "context.Context, *CosignerGRPCSetEphemeralSecretPartsAndSignRequest) (*CosignerGRPCSetEphemeralSecretPartsAndSignResponse, error) - + GetEphemeralSecretParts( "context.Context, *CosignerGRPCGetEphemeralSecretPartsRequest) (*CosignerGRPCGetEphemeralSecretPartsResponse, error) - + TransferLeadership( "context.Context, *CosignerGRPCTransferLeadershipRequest) (*CosignerGRPCTransferLeadershipResponse, error) - - } - class CosignerGRPCSetEphemeralSecretPartsAndSignRequest << (S,Aquamarine) >> { - - state protoimpl.MessageState - - sizeCache protoimpl.SizeCache - - unknownFields protoimpl.UnknownFields - - + EncryptedSecrets []*EphemeralSecretPart - + Hrst *HRST - + SignBytes []byte - - + Reset() - + String() string - + ProtoMessage() - + ProtoReflect() protoreflect.Message - + Descriptor() ([]byte, []int) - + GetEncryptedSecrets() []*EphemeralSecretPart - + GetHrst() *HRST - + GetSignBytes() []byte - - } - class CosignerGRPCSetEphemeralSecretPartsAndSignResponse << (S,Aquamarine) >> { - - state protoimpl.MessageState - - sizeCache protoimpl.SizeCache - - unknownFields protoimpl.UnknownFields - - + EphemeralPublic []byte - + Timestamp int64 - + Signature []byte - - + Reset() - + String() string - + ProtoMessage() - + ProtoReflect() protoreflect.Message - + Descriptor() ([]byte, []int) - + GetEphemeralPublic() []byte - + GetTimestamp() int64 - + GetSignature() []byte - - } - class CosignerGRPCSignBlockRequest << (S,Aquamarine) >> { - - state protoimpl.MessageState - - sizeCache protoimpl.SizeCache - - unknownFields protoimpl.UnknownFields - - + ChainID string - + Block *Block - - + Reset() - + String() string - + ProtoMessage() - + ProtoReflect() protoreflect.Message - + Descriptor() ([]byte, []int) - + GetChainID() string - + GetBlock() *Block - - } - class CosignerGRPCSignBlockResponse << (S,Aquamarine) >> { - - state protoimpl.MessageState - - sizeCache protoimpl.SizeCache - - unknownFields protoimpl.UnknownFields - - + Signature []byte - - + Reset() - + String() string - + ProtoMessage() - + ProtoReflect() protoreflect.Message - + Descriptor() ([]byte, []int) - + GetSignature() []byte - - } - class CosignerGRPCTransferLeadershipRequest << (S,Aquamarine) >> { - - state protoimpl.MessageState - - sizeCache protoimpl.SizeCache - - unknownFields protoimpl.UnknownFields - - + LeaderID string - - + Reset() - + String() string - + ProtoMessage() - + ProtoReflect() protoreflect.Message - + Descriptor() ([]byte, []int) - + GetLeaderID() string - - } - class CosignerGRPCTransferLeadershipResponse << (S,Aquamarine) >> { - - state protoimpl.MessageState - - sizeCache protoimpl.SizeCache - - unknownFields protoimpl.UnknownFields - - + LeaderID string - + LeaderAddress string - - + Reset() - + String() string - + ProtoMessage() - + ProtoReflect() protoreflect.Message - + Descriptor() ([]byte, []int) - + GetLeaderID() string - + GetLeaderAddress() string - - } - class EphemeralSecretPart << (S,Aquamarine) >> { - - state protoimpl.MessageState - - sizeCache protoimpl.SizeCache - - unknownFields protoimpl.UnknownFields - - + SourceID int32 - + DestinationID int32 - + SourceEphemeralSecretPublicKey []byte - + EncryptedSharePart []byte - + SourceSig []byte - - + Reset() - + String() string - + ProtoMessage() - + ProtoReflect() protoreflect.Message - + Descriptor() ([]byte, []int) - + GetSourceID() int32 - + GetDestinationID() int32 - + GetSourceEphemeralSecretPublicKey() []byte - + GetEncryptedSharePart() []byte - + GetSourceSig() []byte - - } - class HRST << (S,Aquamarine) >> { - - state protoimpl.MessageState - - sizeCache protoimpl.SizeCache - - unknownFields protoimpl.UnknownFields - - + Height int64 - + Round int64 - + Step int32 - + Timestamp int64 - - + Reset() - + String() string - + ProtoMessage() - + ProtoReflect() protoreflect.Message - + Descriptor() ([]byte, []int) - + GetHeight() int64 - + GetRound() int64 - + GetStep() int32 - + GetTimestamp() int64 - - } - class UnimplementedCosignerGRPCServer << (S,Aquamarine) >> { - - mustEmbedUnimplementedCosignerGRPCServer() - - + SignBlock( "context.Context, *CosignerGRPCSignBlockRequest) (*CosignerGRPCSignBlockResponse, error) - + SetEphemeralSecretPartsAndSign( "context.Context, *CosignerGRPCSetEphemeralSecretPartsAndSignRequest) (*CosignerGRPCSetEphemeralSecretPartsAndSignResponse, error) - + GetEphemeralSecretParts( "context.Context, *CosignerGRPCGetEphemeralSecretPartsRequest) (*CosignerGRPCGetEphemeralSecretPartsResponse, error) - + TransferLeadership( "context.Context, *CosignerGRPCTransferLeadershipRequest) (*CosignerGRPCTransferLeadershipResponse, error) - - } - interface UnsafeCosignerGRPCServer { - - mustEmbedUnimplementedCosignerGRPCServer() - - } - class cosignerGRPCClient << (S,Aquamarine) >> { - - cc grpc.ClientConnInterface - - + SignBlock(ctx "context.Context, in *CosignerGRPCSignBlockRequest, opts ...grpc.CallOption) (*CosignerGRPCSignBlockResponse, error) - + SetEphemeralSecretPartsAndSign(ctx "context.Context, in *CosignerGRPCSetEphemeralSecretPartsAndSignRequest, opts ...grpc.CallOption) (*CosignerGRPCSetEphemeralSecretPartsAndSignResponse, error) - + GetEphemeralSecretParts(ctx "context.Context, in *CosignerGRPCGetEphemeralSecretPartsRequest, opts ...grpc.CallOption) (*CosignerGRPCGetEphemeralSecretPartsResponse, error) - + TransferLeadership(ctx "context.Context, in *CosignerGRPCTransferLeadershipRequest, opts ...grpc.CallOption) (*CosignerGRPCTransferLeadershipResponse, error) - - } -} - -"proto.CosignerGRPCServer" <|-- "implements""proto.UnimplementedCosignerGRPCServer" -"proto.UnsafeCosignerGRPCServer" <|-- "implements""proto.UnimplementedCosignerGRPCServer" -"proto.CosignerGRPCClient" <|-- "implements""proto.cosignerGRPCClient" - -"proto.CosignerGRPCGetEphemeralSecretPartsRequest""uses" o-- "proto.HRST" -"proto.CosignerGRPCGetEphemeralSecretPartsResponse""uses" o-- "proto.EphemeralSecretPart" -"proto.CosignerGRPCSetEphemeralSecretPartsAndSignRequest""uses" o-- "proto.EphemeralSecretPart" -"proto.CosignerGRPCSetEphemeralSecretPartsAndSignRequest""uses" o-- "proto.HRST" -"proto.CosignerGRPCSignBlockRequest""uses" o-- "proto.Block" - -namespace signer { - class BeyondBlockError << (S,Aquamarine) >> { - - msg string - - + Error() string - - } - class Block << (S,Aquamarine) >> { - + Height int64 - + Round int64 - + Step int8 - + SignBytes []byte - + Timestamp time.Time - - - toProto() *proto.Block - - } - class Config << (S,Aquamarine) >> { - + Mode string - + PrivValKeyFile string - + PrivValStateDir string - + ChainID string - + CosignerThreshold int - + ListenAddress string - + Nodes []NodeConfig - + Cosigners []CosignerConfig - - + KeyFileExists() error - - } - class ConflictingDataError << (S,Aquamarine) >> { - - msg string - - + Error() string - - } - interface Cosigner { - + GetID() int - + GetAddress() string - + GetEphemeralSecretParts(hrst HRSTKey) (*CosignerEphemeralSecretPartsResponse, error) - + SetEphemeralSecretPartsAndSign(req CosignerSetEphemeralSecretPartsAndSignRequest) (*CosignerSignResponse, error) - - } - class CosignerConfig << (S,Aquamarine) >> { - + ID int - + Address string - - } - class CosignerEphemeralSecretPart << (S,Aquamarine) >> { - + SourceID int - + DestinationID int - + SourceEphemeralSecretPublicKey []byte - + EncryptedSharePart []byte - + SourceSig []byte - - - toProto() *proto.EphemeralSecretPart - - } - class CosignerEphemeralSecretParts << (S,Aquamarine) >> { - - toProto() []*proto.EphemeralSecretPart - - } - class CosignerEphemeralSecretPartsResponse << (S,Aquamarine) >> { - + EncryptedSecrets []CosignerEphemeralSecretPart - - } - class CosignerGRPCServer << (S,Aquamarine) >> { - - cosigner *LocalCosigner - - thresholdValidator *ThresholdValidator - - raftStore *RaftStore - - + SignBlock(ctx context.Context, req *proto.CosignerGRPCSignBlockRequest) (*proto.CosignerGRPCSignBlockResponse, error) - + SetEphemeralSecretPartsAndSign(ctx context.Context, req *proto.CosignerGRPCSetEphemeralSecretPartsAndSignRequest) (*proto.CosignerGRPCSetEphemeralSecretPartsAndSignResponse, error) - + GetEphemeralSecretParts(ctx context.Context, req *proto.CosignerGRPCGetEphemeralSecretPartsRequest) (*proto.CosignerGRPCGetEphemeralSecretPartsResponse, error) - + TransferLeadership(ctx context.Context, req *proto.CosignerGRPCTransferLeadershipRequest) (*proto.CosignerGRPCTransferLeadershipResponse, error) - - } - class CosignerGetEphemeralSecretPartRequest << (S,Aquamarine) >> { - + ID int - + Height int64 - + Round int64 - + Step int8 - + Timestamp time.Time - - } - class CosignerKey << (S,Aquamarine) >> { - + PubKey crypto.PubKey - + ShareKey []byte - + RSAKey rsa.PrivateKey - + ID int - + CosignerKeys []*rsa.PublicKey - - + MarshalJSON() ([]byte, error) - + UnmarshalJSON(data []byte) error - - } - class CosignerPeer << (S,Aquamarine) >> { - + ID int - + PublicKey rsa.PublicKey - - } - class CosignerSetEphemeralSecretPartRequest << (S,Aquamarine) >> { - + SourceID int - + SourceEphemeralSecretPublicKey []byte - + EncryptedSharePart []byte - + SourceSig []byte - + Height int64 - + Round int64 - + Step int8 - + Timestamp time.Time - - } - class CosignerSetEphemeralSecretPartsAndSignRequest << (S,Aquamarine) >> { - + EncryptedSecrets []CosignerEphemeralSecretPart - + HRST HRSTKey - + SignBytes []byte - - } - class CosignerSignBlockRequest << (S,Aquamarine) >> { - + ChainID string - + Block *Block - - } - class CosignerSignBlockResponse << (S,Aquamarine) >> { - + Signature []byte - - } - class CosignerSignRequest << (S,Aquamarine) >> { - + SignBytes []byte - - } - class CosignerSignResponse << (S,Aquamarine) >> { - + EphemeralPublic []byte - + Timestamp time.Time - + Signature []byte - - } - class GRPCServer << (S,Aquamarine) >> { - - cosigner *LocalCosigner - - thresholdValidator *ThresholdValidator - - raftStore *RaftStore - - + SignBlock(ctx context.Context, req *proto.CosignerGRPCSignBlockRequest) (*proto.CosignerGRPCSignBlockResponse, error) - + SetEphemeralSecretPartsAndSign(ctx context.Context, req *proto.CosignerGRPCSetEphemeralSecretPartsAndSignRequest) (*proto.CosignerGRPCSetEphemeralSecretPartsAndSignResponse, error) - + GetEphemeralSecretParts(ctx context.Context, req *proto.CosignerGRPCGetEphemeralSecretPartsRequest) (*proto.CosignerGRPCGetEphemeralSecretPartsResponse, error) - + TransferLeadership(ctx context.Context, req *proto.CosignerGRPCTransferLeadershipRequest) (*proto.CosignerGRPCTransferLeadershipResponse, error) - - } - class HRSKey << (S,Aquamarine) >> { - + Height int64 - + Round int64 - + Step int8 - - } - class HRSTKey << (S,Aquamarine) >> { - + Height int64 - + Round int64 - + Step int8 - + Timestamp int64 - - - toProto() *proto.HRST - - + Less(other HRSTKey) bool - - } - class HrsMetadata << (S,Aquamarine) >> { - + Secret []byte - + DealtShares []pkg.Scalar - + Peers []PeerMetadata - - } - class LocalCosigner << (S,Aquamarine) >> { - - pubKeyBytes []byte - - total uint8 - - peers map[int]CosignerPeer - - address string - - localsigner LocalSoftSignThresholdEd25519Signature - - + SaveLastSignedState(signState SignStateConsensus) error - + GetID() int - + GetAddress() string - + GetEphemeralSecretParts(hrst HRSTKey) (*CosignerEphemeralSecretPartsResponse, error) - + SetEphemeralSecretPartsAndSign(req CosignerSetEphemeralSecretPartsAndSignRequest) (*CosignerSignResponse, error) - - } - class LocalCosignerConfig << (S,Aquamarine) >> { - + CosignerKey CosignerKey - + SignState *SignState - + Peers []CosignerPeer - + Address string - + RaftAddress string - + Total uint8 - + Threshold uint8 - + Signer *LocalSoftSignThresholdEd25519Signature - - } - class LocalHSMsignThresholdEd25519Signature << (S,Aquamarine) >> { - - dealShares(req CosignerGetEphemeralSecretPartRequest) (HrsMetadata, error) - - setEphemeralSecretPart(req CosignerSetEphemeralSecretPartRequest) error - - getEphemeralSecretPart(req CosignerGetEphemeralSecretPartRequest) (CosignerEphemeralSecretPart, error) - - sign(req CosignerSignRequest) (CosignerSignResponse, error) - - } - class LocalSoftSignThresholdEd25519Signature << (S,Aquamarine) >> { - - lastSignStateMutex sync.Mutex - - pubKeyBytes []byte - - key CosignerKey - - rsaKey rsa.PrivateKey - - total uint8 - - threshold uint8 - - lastSignState *SignState - - hrsMeta map[HRSTKey]HrsMetadata - - peers map[int]CosignerPeer - - - sign(req CosignerSignRequest) (CosignerSignResponse, error) - - dealShares(req CosignerGetEphemeralSecretPartRequest) (HrsMetadata, error) - - getEphemeralSecretPart(req CosignerGetEphemeralSecretPartRequest) (CosignerEphemeralSecretPart, error) - - setEphemeralSecretPart(req CosignerSetEphemeralSecretPartRequest) error - - } - class NodeConfig << (S,Aquamarine) >> { - + Address string - - } - class PeerMetadata << (S,Aquamarine) >> { - + Share []byte - + EphemeralSecretPublicKey []byte - - } - class PvGuard << (S,Aquamarine) >> { - - pvMutex sync.Mutex - - + PrivValidator types.PrivValidator - - + GetPubKey() (crypto.PubKey, error) - + SignVote(chainID string, vote *types.Vote) error - + SignProposal(chainID string, proposal *types.Proposal) error - - } - class RaftStore << (S,Aquamarine) >> { - - mu sync.Mutex - - m map[string]string - - raft *raft.Raft - - logger log.Logger - - cosigner *LocalCosigner - - thresholdValidator *ThresholdValidator - - + NodeID string - + RaftDir string - + RaftBind string - + RaftTimeout time.Duration - + Peers []Cosigner - - - getLeaderGRPCClient() (proto.CosignerGRPCClient, *grpc.ClientConn, error) - - init() error - - + LeaderSignBlock(req CosignerSignBlockRequest) (*CosignerSignBlockResponse, error) - + SetThresholdValidator(thresholdValidator *ThresholdValidator) - + OnStart() error - + Open() (*raft-grpc-transport.Manager, error) - + Get(key string) (string, error) - + Emit(key string, value interface{}) error - + Set(key string, value string) error - + Delete(key string) error - + Join(nodeID string, addr string) error - + GetLeader() raft.ServerAddress - - } - class ReconnRemoteSigner << (S,Aquamarine) >> { - - address string - - chainID string - - privKey ed25519.PrivKey - - privVal types.PrivValidator - - dialer net.Dialer - - - loop() - - handleRequest(req privval.Message) privval.Message - - handleSignVoteRequest(vote *types.Vote) privval.Message - - handleSignProposalRequest(proposal *types.Proposal) privval.Message - - handlePubKeyRequest() privval.Message - - handlePingRequest() privval.Message - - + OnStart() error - - } - class RemoteCosigner << (S,Aquamarine) >> { - - id int - - address string - - - getGRPCClient() (proto.CosignerGRPCClient, *grpc.ClientConn, error) - - + GetID() int - + GetAddress() string - + GetEphemeralSecretParts(req HRSTKey) (*CosignerEphemeralSecretPartsResponse, error) - + SetEphemeralSecretPartsAndSign(req CosignerSetEphemeralSecretPartsAndSignRequest) (*CosignerSignResponse, error) - - } - class SameHRSError << (S,Aquamarine) >> { - - msg string - - + Error() string - - } - class SignState << (S,Aquamarine) >> { - - cache map[HRSKey]SignStateConsensus - - filePath string - - + Height int64 - + Round int64 - + Step int8 - + EphemeralPublic []byte - + Signature []byte - + SignBytes bytes.HexBytes - - - save() - - + GetFromCache(hrs HRSKey, lock *sync.Mutex) (HRSKey, *SignStateConsensus) - + Save(ssc SignStateConsensus, lock *sync.Mutex) error - + CheckHRS(hrst HRSTKey) (bool, error) - + GetErrorIfLessOrEqual(height int64, round int64, step int8, lock *sync.Mutex) error - + OnlyDifferByTimestamp(signBytes []byte) error - - } - class SignStateConsensus << (S,Aquamarine) >> { - + Height int64 - + Round int64 - + Step int8 - + Signature []byte - + SignBytes bytes.HexBytes - - + OnlyDifferByTimestamp(signBytes []byte) error - - } - class StillWaitingForBlockError << (S,Aquamarine) >> { - - msg string - - + Error() string - - } - interface ThresholdEd25519Signature { - - dealShares(req CosignerGetEphemeralSecretPartRequest) (HrsMetadata, error) - - getEphemeralSecretPart(req CosignerGetEphemeralSecretPartRequest) (CosignerEphemeralSecretPart, error) - - setEphemeralSecretPart(req CosignerSetEphemeralSecretPartRequest) error - - sign(req CosignerSignRequest) (CosignerSignResponse, error) - - } - class ThresholdValidator << (S,Aquamarine) >> { - - threshold int - - pubkey crypto.PubKey - - lastSignState SignState - - lastSignStateMutex sync.Mutex - - lastSignStateInitiated SignState - - lastSignStateInitiatedMutex sync.Mutex - - cosigner Cosigner - - peers []Cosigner - - raftStore *RaftStore - - logger log.Logger - - - newBeyondBlockError(hrs HRSKey) *BeyondBlockError - - waitForPeerEphemeralShares(peer Cosigner, hrst HRSTKey, wg *sync.WaitGroup, encryptedEphemeralSharesThresholdMap *map[Cosigner][]{packageName}CosignerEphemeralSecretPart, thresholdPeersMutex *sync.Mutex) - - waitForPeerSetEphemeralSharesAndSign(ourID int, peer Cosigner, hrst HRSTKey, encryptedEphemeralSharesThresholdMap *map[Cosigner][]{packageName}CosignerEphemeralSecretPart, signBytes []byte, shareSignatures *[][]byte, shareSignaturesMutex *sync.Mutex, ephemeralPublic *[]byte, wg *sync.WaitGroup) - - getExistingBlockSignature(block *Block) ([]byte, time.Time, error) - - + SaveLastSignedState(signState SignStateConsensus) error - + SaveLastSignedStateInitiated(signState SignStateConsensus) error - + GetPubKey() (crypto.PubKey, error) - + SignVote(chainID string, vote *types.Vote) error - + SignProposal(chainID string, proposal *types.Proposal) error - + SignBlock(chainID string, block *Block) ([]byte, time.Time, error) - - } - class ThresholdValidatorOpt << (S,Aquamarine) >> { - + Pubkey crypto.PubKey - + Threshold int - + SignState SignState - + Cosigner Cosigner - + Peers []Cosigner - + RaftStore *RaftStore - + Logger log.Logger - - } - class UnimplementedThresholdEd25519Signature << (S,Aquamarine) >> { - - dealShares(req CosignerGetEphemeralSecretPartRequest) (HrsMetadata, error) - - setEphemeralSecretPart(req CosignerSetEphemeralSecretPartRequest) error - - getEphemeralSecretPart(req CosignerGetEphemeralSecretPartRequest) (CosignerEphemeralSecretPart, error) - - sign(req CosignerSignRequest) (CosignerSignResponse, error) - - } - class command << (S,Aquamarine) >> { - + Op string - + Key string - + Value string - - } - class fsm << (S,Aquamarine) >> { - - getEventHandler(key string) func(string) - - shouldRetain(key string) bool - - handleLSSEvent(value string) - - applySet(key string, value string) interface{} - - applyDelete(key string) interface{} - - + Apply(l *raft.Log) interface{} - + Snapshot() (raft.FSMSnapshot, error) - + Restore(rc io.ReadCloser) error - - } - class fsmSnapshot << (S,Aquamarine) >> { - - store map[string]string - - logger log.Logger - - + Persist(sink raft.SnapshotSink) error - + Release() - - } - class signer.CosignerEphemeralSecretParts << (T, #FF7700) >> { - } - class signer.fsm << (T, #FF7700) >> { - } -} -"proto.UnimplementedCosignerGRPCServer" *-- "extends""signer.CosignerGRPCServer" -"proto.UnimplementedCosignerGRPCServer" *-- "extends""signer.GRPCServer" -"signer.UnimplementedThresholdEd25519Signature" *-- "extends""signer.LocalHSMsignThresholdEd25519Signature" -"signer.UnimplementedThresholdEd25519Signature" *-- "extends""signer.LocalSoftSignThresholdEd25519Signature" -"service.BaseService" *-- "extends""signer.RaftStore" -"service.BaseService" *-- "extends""signer.ReconnRemoteSigner" - -"signer.Cosigner" <|-- "implements""signer.LocalCosigner" -"signer.ThresholdEd25519Signature" <|-- "implements""signer.LocalHSMsignThresholdEd25519Signature" -"signer.ThresholdEd25519Signature" <|-- "implements""signer.LocalSoftSignThresholdEd25519Signature" -"signer.Cosigner" <|-- "implements""signer.RemoteCosigner" -"signer.ThresholdEd25519Signature" <|-- "implements""signer.UnimplementedThresholdEd25519Signature" - -"signer.Block""uses" o-- "time.Time" -"signer.Config""uses" o-- "signer.CosignerConfig" -"signer.Config""uses" o-- "signer.NodeConfig" -"signer.CosignerEphemeralSecretPartsResponse""uses" o-- "signer.CosignerEphemeralSecretPart" -"signer.CosignerGetEphemeralSecretPartRequest""uses" o-- "time.Time" -"signer.CosignerKey""uses" o-- "crypto.PubKey" -"signer.CosignerKey""uses" o-- "rsa.PrivateKey" -"signer.CosignerKey""uses" o-- "rsa.PublicKey" -"signer.CosignerPeer""uses" o-- "rsa.PublicKey" -"signer.CosignerSetEphemeralSecretPartRequest""uses" o-- "time.Time" -"signer.CosignerSetEphemeralSecretPartsAndSignRequest""uses" o-- "signer.CosignerEphemeralSecretPart" -"signer.CosignerSetEphemeralSecretPartsAndSignRequest""uses" o-- "signer.HRSTKey" -"signer.CosignerSignBlockRequest""uses" o-- "signer.Block" -"signer.CosignerSignResponse""uses" o-- "time.Time" -"signer.HrsMetadata""uses" o-- "pkg.Scalar" -"signer.HrsMetadata""uses" o-- "signer.PeerMetadata" -"signer.LocalCosignerConfig""uses" o-- "signer.CosignerKey" -"signer.LocalCosignerConfig""uses" o-- "signer.CosignerPeer" -"signer.LocalCosignerConfig""uses" o-- "signer.LocalSoftSignThresholdEd25519Signature" -"signer.LocalCosignerConfig""uses" o-- "signer.SignState" -"signer.PvGuard""uses" o-- "types.PrivValidator" -"signer.RaftStore""uses" o-- "signer.Cosigner" -"signer.RaftStore""uses" o-- "time.Duration" -"signer.SignState""uses" o-- "bytes.HexBytes" -"signer.SignStateConsensus""uses" o-- "bytes.HexBytes" -"signer.ThresholdValidatorOpt""uses" o-- "crypto.PubKey" -"signer.ThresholdValidatorOpt""uses" o-- "log.Logger" -"signer.ThresholdValidatorOpt""uses" o-- "signer.Cosigner" -"signer.ThresholdValidatorOpt""uses" o-- "signer.RaftStore" -"signer.ThresholdValidatorOpt""uses" o-- "signer.SignState" - -"signer.RaftStore" #.. "alias of""signer.fsm" -"signer.[]CosignerEphemeralSecretPart" #.. "alias of""signer.CosignerEphemeralSecretParts" -@enduml diff --git a/diagram_refactoring.puml b/diagram_refactoring.puml deleted file mode 100644 index c23277c6..00000000 --- a/diagram_refactoring.puml +++ /dev/null @@ -1,763 +0,0 @@ -@startuml -legend -Legend -Render Aggregations: true -Render Fields: true -Render Methods: true -Pritave Aggregations: false -end legend -namespace cmd { - class AddressCmdOutput << (S,Aquamarine) >> { - + HexAddress string - + ValConsAddress string - - } - class ChainNode << (S,Aquamarine) >> { - + PrivValAddr string - - } - class Config << (S,Aquamarine) >> { - + HomeDir string - + PrivValKeyFile string - + ChainID string - + CosignerConfig *CosignerConfig - + ChainNodes []ChainNode - - + Nodes() []signer.NodeConfig - + MustMarshalYaml() []byte - + CosignerPeers() []signer.CosignerConfig - - } - class CosignerConfig << (S,Aquamarine) >> { - + Threshold int - + Shares int - + P2PListen string - + Peers []CosignerPeer - + Timeout string - - } - class CosignerPeer << (S,Aquamarine) >> { - + ShareID int - + P2PAddr string - - } - class Info << (S,Aquamarine) >> { - + Version string - + GitCommit string - + GoVersion string - + CosmosSdkVersion string - + TendermintVersion string - - } -} - - -"cmd.Config""uses" o-- "cmd.ChainNode" -"cmd.Config""uses" o-- "cmd.CosignerConfig" -"cmd.CosignerConfig""uses" o-- "cmd.CosignerPeer" - -namespace proto { - class Block << (S,Aquamarine) >> { - - state protoimpl.MessageState - - sizeCache protoimpl.SizeCache - - unknownFields protoimpl.UnknownFields - - + Height int64 - + Round int64 - + Step int32 - + SignBytes []byte - + Timestamp int64 - - + Reset() - + String() string - + ProtoMessage() - + ProtoReflect() protoreflect.Message - + Descriptor() ([]byte, []int) - + GetHeight() int64 - + GetRound() int64 - + GetStep() int32 - + GetSignBytes() []byte - + GetTimestamp() int64 - - } - interface CosignerGRPCClient { - + SignBlock(ctx "context.Context, in *CosignerGRPCSignBlockRequest, opts ...grpc.CallOption) (*CosignerGRPCSignBlockResponse, error) - + SetEphemeralSecretPartsAndSign(ctx "context.Context, in *CosignerGRPCSetEphemeralSecretPartsAndSignRequest, opts ...grpc.CallOption) (*CosignerGRPCSetEphemeralSecretPartsAndSignResponse, error) - + GetEphemeralSecretParts(ctx "context.Context, in *CosignerGRPCGetEphemeralSecretPartsRequest, opts ...grpc.CallOption) (*CosignerGRPCGetEphemeralSecretPartsResponse, error) - + TransferLeadership(ctx "context.Context, in *CosignerGRPCTransferLeadershipRequest, opts ...grpc.CallOption) (*CosignerGRPCTransferLeadershipResponse, error) - - } - class CosignerGRPCGetEphemeralSecretPartsRequest << (S,Aquamarine) >> { - - state protoimpl.MessageState - - sizeCache protoimpl.SizeCache - - unknownFields protoimpl.UnknownFields - - + Hrst *HRST - - + Reset() - + String() string - + ProtoMessage() - + ProtoReflect() protoreflect.Message - + Descriptor() ([]byte, []int) - + GetHrst() *HRST - - } - class CosignerGRPCGetEphemeralSecretPartsResponse << (S,Aquamarine) >> { - - state protoimpl.MessageState - - sizeCache protoimpl.SizeCache - - unknownFields protoimpl.UnknownFields - - + EncryptedSecrets []*EphemeralSecretPart - - + Reset() - + String() string - + ProtoMessage() - + ProtoReflect() protoreflect.Message - + Descriptor() ([]byte, []int) - + GetEncryptedSecrets() []*EphemeralSecretPart - - } - interface CosignerGRPCServer { - - mustEmbedUnimplementedCosignerGRPCServer() - - + SignBlock( "context.Context, *CosignerGRPCSignBlockRequest) (*CosignerGRPCSignBlockResponse, error) - + SetEphemeralSecretPartsAndSign( "context.Context, *CosignerGRPCSetEphemeralSecretPartsAndSignRequest) (*CosignerGRPCSetEphemeralSecretPartsAndSignResponse, error) - + GetEphemeralSecretParts( "context.Context, *CosignerGRPCGetEphemeralSecretPartsRequest) (*CosignerGRPCGetEphemeralSecretPartsResponse, error) - + TransferLeadership( "context.Context, *CosignerGRPCTransferLeadershipRequest) (*CosignerGRPCTransferLeadershipResponse, error) - - } - class CosignerGRPCSetEphemeralSecretPartsAndSignRequest << (S,Aquamarine) >> { - - state protoimpl.MessageState - - sizeCache protoimpl.SizeCache - - unknownFields protoimpl.UnknownFields - - + EncryptedSecrets []*EphemeralSecretPart - + Hrst *HRST - + SignBytes []byte - - + Reset() - + String() string - + ProtoMessage() - + ProtoReflect() protoreflect.Message - + Descriptor() ([]byte, []int) - + GetEncryptedSecrets() []*EphemeralSecretPart - + GetHrst() *HRST - + GetSignBytes() []byte - - } - class CosignerGRPCSetEphemeralSecretPartsAndSignResponse << (S,Aquamarine) >> { - - state protoimpl.MessageState - - sizeCache protoimpl.SizeCache - - unknownFields protoimpl.UnknownFields - - + EphemeralPublic []byte - + Timestamp int64 - + Signature []byte - - + Reset() - + String() string - + ProtoMessage() - + ProtoReflect() protoreflect.Message - + Descriptor() ([]byte, []int) - + GetEphemeralPublic() []byte - + GetTimestamp() int64 - + GetSignature() []byte - - } - class CosignerGRPCSignBlockRequest << (S,Aquamarine) >> { - - state protoimpl.MessageState - - sizeCache protoimpl.SizeCache - - unknownFields protoimpl.UnknownFields - - + ChainID string - + Block *Block - - + Reset() - + String() string - + ProtoMessage() - + ProtoReflect() protoreflect.Message - + Descriptor() ([]byte, []int) - + GetChainID() string - + GetBlock() *Block - - } - class CosignerGRPCSignBlockResponse << (S,Aquamarine) >> { - - state protoimpl.MessageState - - sizeCache protoimpl.SizeCache - - unknownFields protoimpl.UnknownFields - - + Signature []byte - - + Reset() - + String() string - + ProtoMessage() - + ProtoReflect() protoreflect.Message - + Descriptor() ([]byte, []int) - + GetSignature() []byte - - } - class CosignerGRPCTransferLeadershipRequest << (S,Aquamarine) >> { - - state protoimpl.MessageState - - sizeCache protoimpl.SizeCache - - unknownFields protoimpl.UnknownFields - - + LeaderID string - - + Reset() - + String() string - + ProtoMessage() - + ProtoReflect() protoreflect.Message - + Descriptor() ([]byte, []int) - + GetLeaderID() string - - } - class CosignerGRPCTransferLeadershipResponse << (S,Aquamarine) >> { - - state protoimpl.MessageState - - sizeCache protoimpl.SizeCache - - unknownFields protoimpl.UnknownFields - - + LeaderID string - + LeaderAddress string - - + Reset() - + String() string - + ProtoMessage() - + ProtoReflect() protoreflect.Message - + Descriptor() ([]byte, []int) - + GetLeaderID() string - + GetLeaderAddress() string - - } - class EphemeralSecretPart << (S,Aquamarine) >> { - - state protoimpl.MessageState - - sizeCache protoimpl.SizeCache - - unknownFields protoimpl.UnknownFields - - + SourceID int32 - + DestinationID int32 - + SourceEphemeralSecretPublicKey []byte - + EncryptedSharePart []byte - + SourceSig []byte - - + Reset() - + String() string - + ProtoMessage() - + ProtoReflect() protoreflect.Message - + Descriptor() ([]byte, []int) - + GetSourceID() int32 - + GetDestinationID() int32 - + GetSourceEphemeralSecretPublicKey() []byte - + GetEncryptedSharePart() []byte - + GetSourceSig() []byte - - } - class HRST << (S,Aquamarine) >> { - - state protoimpl.MessageState - - sizeCache protoimpl.SizeCache - - unknownFields protoimpl.UnknownFields - - + Height int64 - + Round int64 - + Step int32 - + Timestamp int64 - - + Reset() - + String() string - + ProtoMessage() - + ProtoReflect() protoreflect.Message - + Descriptor() ([]byte, []int) - + GetHeight() int64 - + GetRound() int64 - + GetStep() int32 - + GetTimestamp() int64 - - } - class UnimplementedCosignerGRPCServer << (S,Aquamarine) >> { - - mustEmbedUnimplementedCosignerGRPCServer() - - + SignBlock( "context.Context, *CosignerGRPCSignBlockRequest) (*CosignerGRPCSignBlockResponse, error) - + SetEphemeralSecretPartsAndSign( "context.Context, *CosignerGRPCSetEphemeralSecretPartsAndSignRequest) (*CosignerGRPCSetEphemeralSecretPartsAndSignResponse, error) - + GetEphemeralSecretParts( "context.Context, *CosignerGRPCGetEphemeralSecretPartsRequest) (*CosignerGRPCGetEphemeralSecretPartsResponse, error) - + TransferLeadership( "context.Context, *CosignerGRPCTransferLeadershipRequest) (*CosignerGRPCTransferLeadershipResponse, error) - - } - interface UnsafeCosignerGRPCServer { - - mustEmbedUnimplementedCosignerGRPCServer() - - } - class cosignerGRPCClient << (S,Aquamarine) >> { - - cc grpc.ClientConnInterface - - + SignBlock(ctx "context.Context, in *CosignerGRPCSignBlockRequest, opts ...grpc.CallOption) (*CosignerGRPCSignBlockResponse, error) - + SetEphemeralSecretPartsAndSign(ctx "context.Context, in *CosignerGRPCSetEphemeralSecretPartsAndSignRequest, opts ...grpc.CallOption) (*CosignerGRPCSetEphemeralSecretPartsAndSignResponse, error) - + GetEphemeralSecretParts(ctx "context.Context, in *CosignerGRPCGetEphemeralSecretPartsRequest, opts ...grpc.CallOption) (*CosignerGRPCGetEphemeralSecretPartsResponse, error) - + TransferLeadership(ctx "context.Context, in *CosignerGRPCTransferLeadershipRequest, opts ...grpc.CallOption) (*CosignerGRPCTransferLeadershipResponse, error) - - } -} - -"proto.CosignerGRPCServer" <|-- "implements""proto.UnimplementedCosignerGRPCServer" -"proto.UnsafeCosignerGRPCServer" <|-- "implements""proto.UnimplementedCosignerGRPCServer" -"proto.CosignerGRPCClient" <|-- "implements""proto.cosignerGRPCClient" - -"proto.CosignerGRPCGetEphemeralSecretPartsRequest""uses" o-- "proto.HRST" -"proto.CosignerGRPCGetEphemeralSecretPartsResponse""uses" o-- "proto.EphemeralSecretPart" -"proto.CosignerGRPCSetEphemeralSecretPartsAndSignRequest""uses" o-- "proto.EphemeralSecretPart" -"proto.CosignerGRPCSetEphemeralSecretPartsAndSignRequest""uses" o-- "proto.HRST" -"proto.CosignerGRPCSignBlockRequest""uses" o-- "proto.Block" - -namespace signer { - class BeyondBlockError << (S,Aquamarine) >> { - - msg string - - + Error() string - - } - class Block << (S,Aquamarine) >> { - + Height int64 - + Round int64 - + Step int8 - + SignBytes []byte - + Timestamp time.Time - - - toProto() *proto.Block - - } - class Config << (S,Aquamarine) >> { - + Mode string - + PrivValKeyFile string - + PrivValStateDir string - + ChainID string - + CosignerThreshold int - + ListenAddress string - + Nodes []NodeConfig - + Cosigners []CosignerConfig - - + KeyFileExists() error - - } - class ConflictingDataError << (S,Aquamarine) >> { - - msg string - - + Error() string - - } - interface Cosigner { - + GetID() int - + GetAddress() string - + GetEphemeralSecretParts(hrst HRSTKey) (*CosignerEphemeralSecretPartsResponse, error) - + SetEphemeralSecretPartsAndSign(req CosignerSetEphemeralSecretPartsAndSignRequest) (*CosignerSignResponse, error) - - } - class CosignerConfig << (S,Aquamarine) >> { - + ID int - + Address string - - } - class CosignerEphemeralSecretPart << (S,Aquamarine) >> { - + SourceID int - + DestinationID int - + SourceEphemeralSecretPublicKey []byte - + EncryptedSharePart []byte - + SourceSig []byte - - - toProto() *proto.EphemeralSecretPart - - } - class CosignerEphemeralSecretParts << (S,Aquamarine) >> { - - toProto() []*proto.EphemeralSecretPart - - } - class CosignerEphemeralSecretPartsResponse << (S,Aquamarine) >> { - + EncryptedSecrets []CosignerEphemeralSecretPart - - } - class CosignerGRPCServer << (S,Aquamarine) >> { - - cosigner *LocalCosigner - - thresholdValidator *ThresholdValidator - - raftStore *RaftStore - - + SignBlock(ctx context.Context, req *proto.CosignerGRPCSignBlockRequest) (*proto.CosignerGRPCSignBlockResponse, error) - + SetEphemeralSecretPartsAndSign(ctx context.Context, req *proto.CosignerGRPCSetEphemeralSecretPartsAndSignRequest) (*proto.CosignerGRPCSetEphemeralSecretPartsAndSignResponse, error) - + GetEphemeralSecretParts(ctx context.Context, req *proto.CosignerGRPCGetEphemeralSecretPartsRequest) (*proto.CosignerGRPCGetEphemeralSecretPartsResponse, error) - + TransferLeadership(ctx context.Context, req *proto.CosignerGRPCTransferLeadershipRequest) (*proto.CosignerGRPCTransferLeadershipResponse, error) - - } - class CosignerGetEphemeralSecretPartRequest << (S,Aquamarine) >> { - + ID int - + Height int64 - + Round int64 - + Step int8 - + Timestamp time.Time - - } - class CosignerKey << (S,Aquamarine) >> { - + PubKey crypto.PubKey - + ShareKey []byte - + RSAKey rsa.PrivateKey - + ID int - + CosignerKeys []*rsa.PublicKey - - + MarshalJSON() ([]byte, error) - + UnmarshalJSON(data []byte) error - - } - class CosignerPeer << (S,Aquamarine) >> { - + ID int - + PublicKey rsa.PublicKey - - } - class CosignerSetEphemeralSecretPartRequest << (S,Aquamarine) >> { - + SourceID int - + SourceEphemeralSecretPublicKey []byte - + EncryptedSharePart []byte - + SourceSig []byte - + Height int64 - + Round int64 - + Step int8 - + Timestamp time.Time - - } - class CosignerSetEphemeralSecretPartsAndSignRequest << (S,Aquamarine) >> { - + EncryptedSecrets []CosignerEphemeralSecretPart - + HRST HRSTKey - + SignBytes []byte - - } - class CosignerSignBlockRequest << (S,Aquamarine) >> { - + ChainID string - + Block *Block - - } - class CosignerSignBlockResponse << (S,Aquamarine) >> { - + Signature []byte - - } - class CosignerSignRequest << (S,Aquamarine) >> { - + SignBytes []byte - - } - class CosignerSignResponse << (S,Aquamarine) >> { - + EphemeralPublic []byte - + Timestamp time.Time - + Signature []byte - - } - class GRPCServer << (S,Aquamarine) >> { - - cosigner *LocalCosigner - - thresholdValidator *ThresholdValidator - - raftStore *RaftStore - - + SignBlock(ctx context.Context, req *proto.CosignerGRPCSignBlockRequest) (*proto.CosignerGRPCSignBlockResponse, error) - + SetEphemeralSecretPartsAndSign(ctx context.Context, req *proto.CosignerGRPCSetEphemeralSecretPartsAndSignRequest) (*proto.CosignerGRPCSetEphemeralSecretPartsAndSignResponse, error) - + GetEphemeralSecretParts(ctx context.Context, req *proto.CosignerGRPCGetEphemeralSecretPartsRequest) (*proto.CosignerGRPCGetEphemeralSecretPartsResponse, error) - + TransferLeadership(ctx context.Context, req *proto.CosignerGRPCTransferLeadershipRequest) (*proto.CosignerGRPCTransferLeadershipResponse, error) - - } - class HRSKey << (S,Aquamarine) >> { - + Height int64 - + Round int64 - + Step int8 - - } - class HRSTKey << (S,Aquamarine) >> { - + Height int64 - + Round int64 - + Step int8 - + Timestamp int64 - - - toProto() *proto.HRST - - + Less(other HRSTKey) bool - - } - class HrsMetadata << (S,Aquamarine) >> { - + Secret []byte - + DealtShares []pkg.Scalar - + Peers []PeerMetadata - - } - class LocalCosigner << (S,Aquamarine) >> { - - pubKeyBytes []byte - - key CosignerKey - - rsaKey rsa.PrivateKey - - total uint8 - - threshold uint8 - - lastSignState *SignState - - lastSignStateMutex sync.Mutex - - hrsMeta map[HRSTKey]HrsMetadata - - peers map[int]CosignerPeer - - address string - - - sign(req CosignerSignRequest) (CosignerSignResponse, error) - - dealShares(req CosignerGetEphemeralSecretPartRequest) (HrsMetadata, error) - - getEphemeralSecretPart(req CosignerGetEphemeralSecretPartRequest) (CosignerEphemeralSecretPart, error) - - setEphemeralSecretPart(req CosignerSetEphemeralSecretPartRequest) error - - + SaveLastSignedState(signState SignStateConsensus) error - + GetID() int - + GetAddress() string - + GetEphemeralSecretParts(hrst HRSTKey) (*CosignerEphemeralSecretPartsResponse, error) - + SetEphemeralSecretPartsAndSign(req CosignerSetEphemeralSecretPartsAndSignRequest) (*CosignerSignResponse, error) - - } - class LocalCosignerConfig << (S,Aquamarine) >> { - - signature UnimplementedThresholdEd25519Signature - - + CosignerKey CosignerKey - + SignState *SignState - + RsaKey rsa.PrivateKey - + Peers []CosignerPeer - + Address string - + RaftAddress string - + Total uint8 - + Threshold uint8 - - } - class LocalSoftsignThresholdEd25519Signature << (S,Aquamarine) >> { - } - class NodeConfig << (S,Aquamarine) >> { - + Address string - - } - class PeerMetadata << (S,Aquamarine) >> { - + Share []byte - + EphemeralSecretPublicKey []byte - - } - class PvGuard << (S,Aquamarine) >> { - - pvMutex sync.Mutex - - + PrivValidator types.PrivValidator - - + GetPubKey() (crypto.PubKey, error) - + SignVote(chainID string, vote *types.Vote) error - + SignProposal(chainID string, proposal *types.Proposal) error - - } - class RaftStore << (S,Aquamarine) >> { - - mu sync.Mutex - - m map[string]string - - raft *raft.Raft - - logger log.Logger - - cosigner *LocalCosigner - - thresholdValidator *ThresholdValidator - - + NodeID string - + RaftDir string - + RaftBind string - + RaftTimeout time.Duration - + Peers []Cosigner - - - getLeaderGRPCClient() (proto.CosignerGRPCClient, *grpc.ClientConn, error) - - init() error - - + LeaderSignBlock(req CosignerSignBlockRequest) (*CosignerSignBlockResponse, error) - + SetThresholdValidator(thresholdValidator *ThresholdValidator) - + OnStart() error - + Open() (*raft-grpc-transport.Manager, error) - + Get(key string) (string, error) - + Emit(key string, value interface{}) error - + Set(key string, value string) error - + Delete(key string) error - + Join(nodeID string, addr string) error - + GetLeader() raft.ServerAddress - - } - class ReconnRemoteSigner << (S,Aquamarine) >> { - - address string - - chainID string - - privKey ed25519.PrivKey - - privVal types.PrivValidator - - dialer net.Dialer - - - loop() - - handleRequest(req privval.Message) privval.Message - - handleSignVoteRequest(vote *types.Vote) privval.Message - - handleSignProposalRequest(proposal *types.Proposal) privval.Message - - handlePubKeyRequest() privval.Message - - handlePingRequest() privval.Message - - + OnStart() error - - } - class RemoteCosigner << (S,Aquamarine) >> { - - id int - - address string - - - getGRPCClient() (proto.CosignerGRPCClient, *grpc.ClientConn, error) - - + GetID() int - + GetAddress() string - + GetEphemeralSecretParts(req HRSTKey) (*CosignerEphemeralSecretPartsResponse, error) - + SetEphemeralSecretPartsAndSign(req CosignerSetEphemeralSecretPartsAndSignRequest) (*CosignerSignResponse, error) - - } - class SameHRSError << (S,Aquamarine) >> { - - msg string - - + Error() string - - } - class SignState << (S,Aquamarine) >> { - - cache map[HRSKey]SignStateConsensus - - filePath string - - + Height int64 - + Round int64 - + Step int8 - + EphemeralPublic []byte - + Signature []byte - + SignBytes bytes.HexBytes - - - save() - - + GetFromCache(hrs HRSKey, lock *sync.Mutex) (HRSKey, *SignStateConsensus) - + Save(ssc SignStateConsensus, lock *sync.Mutex) error - + CheckHRS(hrst HRSTKey) (bool, error) - + GetErrorIfLessOrEqual(height int64, round int64, step int8, lock *sync.Mutex) error - + OnlyDifferByTimestamp(signBytes []byte) error - - } - class SignStateConsensus << (S,Aquamarine) >> { - + Height int64 - + Round int64 - + Step int8 - + Signature []byte - + SignBytes bytes.HexBytes - - + OnlyDifferByTimestamp(signBytes []byte) error - - } - class StillWaitingForBlockError << (S,Aquamarine) >> { - - msg string - - + Error() string - - } - interface ThresholdEd25519Signature { - - dealShares(req CosignerGetEphemeralSecretPartRequest) (HrsMetadata, error) - - getEphemeralSecretPart(req CosignerGetEphemeralSecretPartRequest) (CosignerEphemeralSecretPart, error) - - setEphemeralSecretPart(req CosignerSetEphemeralSecretPartRequest) error - - sign(req CosignerSignRequest) (CosignerSignResponse, error) - - } - class ThresholdValidator << (S,Aquamarine) >> { - - threshold int - - pubkey crypto.PubKey - - lastSignState SignState - - lastSignStateMutex sync.Mutex - - lastSignStateInitiated SignState - - lastSignStateInitiatedMutex sync.Mutex - - cosigner Cosigner - - peers []Cosigner - - raftStore *RaftStore - - logger log.Logger - - - newBeyondBlockError(hrs HRSKey) *BeyondBlockError - - waitForPeerEphemeralShares(peer Cosigner, hrst HRSTKey, wg *sync.WaitGroup, encryptedEphemeralSharesThresholdMap *map[Cosigner][]{packageName}CosignerEphemeralSecretPart, thresholdPeersMutex *sync.Mutex) - - waitForPeerSetEphemeralSharesAndSign(ourID int, peer Cosigner, hrst HRSTKey, encryptedEphemeralSharesThresholdMap *map[Cosigner][]{packageName}CosignerEphemeralSecretPart, signBytes []byte, shareSignatures *[][]byte, shareSignaturesMutex *sync.Mutex, ephemeralPublic *[]byte, wg *sync.WaitGroup) - - getExistingBlockSignature(block *Block) ([]byte, time.Time, error) - - + SaveLastSignedState(signState SignStateConsensus) error - + SaveLastSignedStateInitiated(signState SignStateConsensus) error - + GetPubKey() (crypto.PubKey, error) - + SignVote(chainID string, vote *types.Vote) error - + SignProposal(chainID string, proposal *types.Proposal) error - + SignBlock(chainID string, block *Block) ([]byte, time.Time, error) - - } - class ThresholdValidatorOpt << (S,Aquamarine) >> { - + Pubkey crypto.PubKey - + Threshold int - + SignState SignState - + Cosigner Cosigner - + Peers []Cosigner - + RaftStore *RaftStore - + Logger log.Logger - - } - class UnimplementedThresholdEd25519Signature << (S,Aquamarine) >> { - - dealShares(req CosignerGetEphemeralSecretPartRequest) (HrsMetadata, error) - - setEphemeralSecretPart(req CosignerSetEphemeralSecretPartRequest) error - - getEphemeralSecretPart(req CosignerGetEphemeralSecretPartRequest) (CosignerEphemeralSecretPart, error) - - sign(req CosignerSignRequest) (CosignerSignResponse, error) - - } - class command << (S,Aquamarine) >> { - + Op string - + Key string - + Value string - - } - class fsm << (S,Aquamarine) >> { - - getEventHandler(key string) func(string) - - shouldRetain(key string) bool - - handleLSSEvent(value string) - - applySet(key string, value string) interface{} - - applyDelete(key string) interface{} - - + Apply(l *raft.Log) interface{} - + Snapshot() (raft.FSMSnapshot, error) - + Restore(rc io.ReadCloser) error - - } - class fsmSnapshot << (S,Aquamarine) >> { - - store map[string]string - - logger log.Logger - - + Persist(sink raft.SnapshotSink) error - + Release() - - } - class signer.CosignerEphemeralSecretParts << (T, #FF7700) >> { - } - class signer.fsm << (T, #FF7700) >> { - } -} -"proto.UnimplementedCosignerGRPCServer" *-- "extends""signer.CosignerGRPCServer" -"proto.UnimplementedCosignerGRPCServer" *-- "extends""signer.GRPCServer" -"signer.UnimplementedThresholdEd25519Signature" *-- "extends""signer.LocalCosigner" -"signer.UnimplementedThresholdEd25519Signature" *-- "extends""signer.LocalSoftsignThresholdEd25519Signature" -"service.BaseService" *-- "extends""signer.RaftStore" -"service.BaseService" *-- "extends""signer.ReconnRemoteSigner" - -"signer.Cosigner" <|-- "implements""signer.LocalCosigner" -"signer.ThresholdEd25519Signature" <|-- "implements""signer.LocalCosigner" -"signer.Cosigner" <|-- "implements""signer.RemoteCosigner" -"signer.ThresholdEd25519Signature" <|-- "implements""signer.UnimplementedThresholdEd25519Signature" - -"signer.Block""uses" o-- "time.Time" -"signer.Config""uses" o-- "signer.CosignerConfig" -"signer.Config""uses" o-- "signer.NodeConfig" -"signer.CosignerEphemeralSecretPartsResponse""uses" o-- "signer.CosignerEphemeralSecretPart" -"signer.CosignerGetEphemeralSecretPartRequest""uses" o-- "time.Time" -"signer.CosignerKey""uses" o-- "crypto.PubKey" -"signer.CosignerKey""uses" o-- "rsa.PrivateKey" -"signer.CosignerKey""uses" o-- "rsa.PublicKey" -"signer.CosignerPeer""uses" o-- "rsa.PublicKey" -"signer.CosignerSetEphemeralSecretPartRequest""uses" o-- "time.Time" -"signer.CosignerSetEphemeralSecretPartsAndSignRequest""uses" o-- "signer.CosignerEphemeralSecretPart" -"signer.CosignerSetEphemeralSecretPartsAndSignRequest""uses" o-- "signer.HRSTKey" -"signer.CosignerSignBlockRequest""uses" o-- "signer.Block" -"signer.CosignerSignResponse""uses" o-- "time.Time" -"signer.HrsMetadata""uses" o-- "pkg.Scalar" -"signer.HrsMetadata""uses" o-- "signer.PeerMetadata" -"signer.LocalCosignerConfig""uses" o-- "rsa.PrivateKey" -"signer.LocalCosignerConfig""uses" o-- "signer.CosignerKey" -"signer.LocalCosignerConfig""uses" o-- "signer.CosignerPeer" -"signer.LocalCosignerConfig""uses" o-- "signer.SignState" -"signer.PvGuard""uses" o-- "types.PrivValidator" -"signer.RaftStore""uses" o-- "signer.Cosigner" -"signer.RaftStore""uses" o-- "time.Duration" -"signer.SignState""uses" o-- "bytes.HexBytes" -"signer.SignStateConsensus""uses" o-- "bytes.HexBytes" -"signer.ThresholdValidatorOpt""uses" o-- "crypto.PubKey" -"signer.ThresholdValidatorOpt""uses" o-- "log.Logger" -"signer.ThresholdValidatorOpt""uses" o-- "signer.Cosigner" -"signer.ThresholdValidatorOpt""uses" o-- "signer.RaftStore" -"signer.ThresholdValidatorOpt""uses" o-- "signer.SignState" - -"signer.RaftStore" #.. "alias of""signer.fsm" -"signer.[]CosignerEphemeralSecretPart" #.. "alias of""signer.CosignerEphemeralSecretParts" -@enduml