private

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Aug 1, 2023 License: MIT Imports: 13 Imported by: 0

README

Private module

Note

  • The passphrase is used in the private module is not sended to the chain.
  • Parameters such as DID or DIDKey can be replaced to moniker.

Usage

(Tx) Initial administrator of the private chain
// Set initial admin of the private chain
initialAdminMsg := types.InitialAdminMsg{
    InitAdminDIDKey: "did:xpla:EyAhwxY8KYKNqfZKFoWs9GT1jchFNwrs8MMfeyssmqty#key1",
    // InitAdminDIDKey: "admindid#key1",
    DIDPassphrase:   "passphrase",
    DIDKeyPath:      "DID/KEY/DIRECTORY",
}

txbytes, err := xplac.InitialAdmin(initialAdminMsg).CreateAndSignTx()
res, err := xplac.Broadcast(txbytes)
(Tx) Add administrator
// Add administrator
// Init admin can only add another admins
addAdminMsg := types.AddAdminMsg{
    // NewAdminDIDKey: "admindid#key1",
    NewAdminDIDKey:         "did:xpla:EyAhwxY8KYKNqfZKFoWs9GT1jchFNwrs8MMfeyssmqty#key1",
    NewAdminAddress:        "xpriv1k9vu5k7nzq8rfdqu5prvrxlpsrh9y5kxxvla77",
    // InitAdminDIDKey: "initadmindid#key1",
    InitAdminDIDKey:        "did:xpla:EyAhwxY8KYKNqfZKFoWs9GT1jchFNwrs8MMfeyssmqty#key1",
    InitAdminDIDPassphrase: "passphrase",
    InitAdminDIDKeyPath:    "DID/KEY/DIRECTORY",
}

txbytes, err := xplac.AddAdmin(addAdminMsg).CreateAndSignTx()
res, err := xplac.Broadcast(txbytes)
(Tx) Participate
// Users try to participate to the private chain
participateMsg := types.ParticipateMsg{
    // ParticipantDIDKey: "participantdid#key1",
    ParticipantDIDKey: "did:xpla:EyAhwxY8KYKNqfZKFoWs9GT1jchFNwrs8MMfeyssmqty#key1",
    DIDPassphrase:     "passphrase",
    DIDKeyPath:        "DID/KEY/DIRECTORY",
}

txbytes, err := xplac.Participate(participateMsg).CreateAndSignTx()
res, err := xplac.Broadcast(txbytes)
(Tx) Accept
// Admin accepts the participant to join private chain
acceptMsg := types.AcceptMsg{
    // ParticipantDIDKey: "participantdid",
    ParticipantDID:     "did:xpla:EyAhwxY8KYKNqfZKFoWs9GT1jchFNwrs8MMfeyssmqty",
    // AdminDIDKey: "admindid#key1",
    AdminDIDKey:        "did:xpla:AGX4EWyvuqA1ivpwbstRu1vSgnTXAqyM3agQvbjstRcp#key1",
    AdminDIDPassphrase: "passphrase",
    AdminDIDKeyPath:    "DID/KEY/DIRECTORY",
}

txbytes, err := xplac.Accept(acceptMsg).CreateAndSignTx()
res, err := xplac.Broadcast(txbytes)
(Tx) Deny
// Admin denies the participant to join private chain
denyMsg := types.DenyMsg{
    // ParticipantDIDKey: "participantdid",
    ParticipantDID: "did:xpla:EyAhwxY8KYKNqfZKFoWs9GT1jchFNwrs8MMfeyssmqty",
    AdminDID:       "did:xpla:AGX4EWyvuqA1ivpwbstRu1vSgnTXAqyM3agQvbjstRcp",
}
txbytes, err := xplac.Deny(denyMsg).CreateAndSignTx()
res, err := xplac.Broadcast(txbytes)
(Tx) Exile
// Admin exile the participant of the private chain
exileMsg := types.ExileMsg{
    // ParticipantDIDKey: "participantdid",
    ParticipantDID: "did:xpla:EyAhwxY8KYKNqfZKFoWs9GT1jchFNwrs8MMfeyssmqty",
}

txbytes, err := xplac.Exile(exileMsg).CreateAndSignTx()
res, err := xplac.Broadcast(txbytes)
(Tx) Quit
// The participant quit of the private chain
quitMsg := types.QuitMsg{
    // ParticipantDIDKey: "participantdid#key1",
    ParticipantDIDKey: "did:xpla:EyAhwxY8KYKNqfZKFoWs9GT1jchFNwrs8MMfeyssmqty#key1",
    DIDPassphrase:     "passphrase",
    DIDKeyPath:        "DID/KEY/DIRECTORY",
}
txbytes, err := xplac.Quit(quitMsg).CreateAndSignTx()
res, err := xplac.Broadcast(txbytes)
(Query) Get admin list
// Get Admin list
res, err = xplac.Admin().Query()
(Query) Participate state
// Get participate state
participateStateMsg := types.ParticipateStateMsg{
    // DID: "didmoniker"
    DID: "did:xpla:EyAhwxY8KYKNqfZKFoWs9GT1jchFNwrs8MMfeyssmqty",
}

res, err = xplac.ParticipateState(participateStateMsg).Query()
(Query) Participate sequence
// Get participate sequence
participateSequenceMsg := types.ParticipateSequenceMsg{
    // DID: "didmoniker"
    DID: "did:xpla:HZPozx8eoQrv9vLi26SuZ5gKtKgMduCpectAdYVn3ikP",
}

res, err = xplac.ParticipateSequence(participateSequenceMsg).Query()
(Query) Generate DID signature by using DID sequence
// Generate DID signature
// Sign includes current DID sequence which is increased when user uses DID by sending tx
// Only the owner of the DID can receive DID signature
genDIDSignMsg := types.GenDIDSignMsg{
    // DIDKey: "didmoniker#key1"
    DIDKey:        "did:xpla:EyAhwxY8KYKNqfZKFoWs9GT1jchFNwrs8MMfeyssmqty#key1",
    DIDPassphrase: passphrase,
    DIDKeyPath:    config.CommonParams.DefaultDIDKeypath,
}

res, err = xplac.GenDIDSign(genDIDSignMsg).Query()
(Query) Issue Verfiable Credential
// Get the VP
// "DIDSignBase64" is result by querying "GenDIDSign"
issueVCMsg := types.IssueVCMsg{
    // DIDKey: "didmoniker#key1"
    DIDKey:        "did:xpla:EyAhwxY8KYKNqfZKFoWs9GT1jchFNwrs8MMfeyssmqty#key1",
    DIDSignBase64: "u6+LFHzyluJ2pXyggZPTCp6c6sGVL13BvqGAwjAjUClV+3C6ivSoObUvCvnegMA4BbFkD9nUPP/2Wtsk51xMwA==",
}

res, err = xplac.IssueVC(issueVCMsg).Query()
(Query) Get Verifiable Presentation
// Get the VP includes VC
// "DIDSignBase64" is result by querying "GenDIDSign"
getVPMsg := types.GetVPMsg{
    // DIDKey: "didmoniker#key1"
    DIDKey:        "did:xpla:EyAhwxY8KYKNqfZKFoWs9GT1jchFNwrs8MMfeyssmqty#key1",
    DIDSignBase64: "u6+LFHzyluJ2pXyggZPTCp6c6sGVL13BvqGAwjAjUClV+3C6ivSoObUvCvnegMA4BbFkD9nUPP/2Wtsk51xMwA==",
}

res, err = xplac.GetVP(getVPMsg).Query()
(Query) All under reviews state of participants
// all under reviews
res, err := xplac.AllUnderReviews().Query()
(Query) All participants
// all participants
res, err = xplac.AllParticipants().Query()

Documentation

Index

Constants

View Source
const (
	PrivateModule                     = "private"
	PrivateInitialAdminMsgType        = "initial-admin"
	PrivateAddAdminMsgType            = "add-admin"
	PrivateParticipateMsgType         = "participate"
	PrivateAcceptMsgType              = "accept"
	PrivateDenyMsgType                = "deny"
	PrivateExileMsgType               = "exile"
	PrivateQuitMsgType                = "quit"
	PrivateQueryAdminMsgType          = "query-admin"
	PrivateParticipateStateMsgType    = "participate-state"
	PrivateParticipateSequenceMsgType = "participate-sequence"
	PrivateGenDIDSignMsgType          = "gen-did-sig"
	PrivateIssueVCMsgType             = "issue-vc"
	PrivateGetVPMsgType               = "get-vp"
	PrivateAllUnderReviewsMsgType     = "all-under-reviews"
	PrivateAllParticipantsMsgType     = "all-participants"
)

Variables

This section is empty.

Functions

func MakeAcceptMsg

func MakeAcceptMsg(acceptMsg types.AcceptMsg, privKey key.PrivateKey) (privtypes.MsgAccept, error)

(Tx) make msg - accept

func MakeAddAdminMsg

func MakeAddAdminMsg(addAdminMsg types.AddAdminMsg, privKey key.PrivateKey) (privtypes.MsgAddAdmin, error)

(Tx) make msg - add admin

func MakeAllParticipantsMsg added in v0.0.2

func MakeAllParticipantsMsg() (privtypes.QueryAllParticipantsRequest, error)

(Query) make msg - all participants

func MakeAllUnderReviewsMsg added in v0.0.2

func MakeAllUnderReviewsMsg() (privtypes.QueryAllUnderReviewsRequest, error)

(Query) make msg - all under reviews

func MakeDenyMsg

func MakeDenyMsg(denyMsg types.DenyMsg, privKey key.PrivateKey) (privtypes.MsgDeny, error)

(Tx) make msg - deny

func MakeExileMsg

func MakeExileMsg(exileMsg types.ExileMsg, privKey key.PrivateKey) (privtypes.MsgExile, error)

(Tx) make msg - exile

func MakeGenDIDSignMsg

func MakeGenDIDSignMsg(genDIDSignMsg types.GenDIDSignMsg, lcdUrl, grpcUrl string, grpcConn grpc.ClientConn, ctx context.Context) (string, error)

(Query) make msg - gen DID signature

func MakeGetVPMsg

func MakeGetVPMsg(getVPMsg types.GetVPMsg) (privtypes.QueryGetVPRequest, error)

(Query) make msg - get vp

func MakeInitialAdminMsg

func MakeInitialAdminMsg(initialAdminMsg types.InitialAdminMsg, privKey key.PrivateKey) (privtypes.MsgInitialAdmin, error)

(Tx) make msg - initial admin

func MakeIssueVCMsg

func MakeIssueVCMsg(issueVCMsg types.IssueVCMsg) (privtypes.QueryIssueVCRequest, error)

(Query) make msg - issue vc

func MakeParticipateMsg

func MakeParticipateMsg(participateMsg types.ParticipateMsg, lcdUrl, grpcUrl string, grpcConn grpc.ClientConn, privKey key.PrivateKey, ctx context.Context) (privtypes.MsgParticipate, error)

(Tx) make msg - participate

func MakeParticipateSequenceMsg added in v0.0.2

func MakeParticipateSequenceMsg(participateSequenceMsg types.ParticipateSequenceMsg) (privtypes.QueryParticipateSequenceRequest, error)

(Query) make msg - participate sequence

func MakeParticipateStateMsg

func MakeParticipateStateMsg(participateStateMsg types.ParticipateStateMsg) (privtypes.QueryParticipateStateRequest, error)

(Query) make msg - participate state

func MakeQueryAdminMsg

func MakeQueryAdminMsg() (privtypes.QueryAdminRequest, error)

(Query) make msg - query admin

func MakeQuitMsg

func MakeQuitMsg(quitMsg types.QuitMsg, lcdUrl, grpcUrl string, grpcConn grpc.ClientConn, privKey key.PrivateKey, ctx context.Context) (privtypes.MsgQuit, error)

(Tx) make msg - quit

Types

This section is empty.

Jump to

Keyboard shortcuts

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