Documentation ¶
Index ¶
- Constants
- Variables
- func ErrDIDDeactivated(did DID) sdk.Error
- func ErrDIDExists(did DID) sdk.Error
- func ErrDIDNotFound(did DID) sdk.Error
- func ErrInvalidDID(did string) sdk.Error
- func ErrInvalidDIDDocument(doc DIDDocument) sdk.Error
- func ErrInvalidDIDDocumentWithSeq(doc DIDDocumentWithSeq) sdk.Error
- func ErrInvalidKeyController(did DID) sdk.Error
- func ErrInvalidNetworkID(id string) sdk.Error
- func ErrInvalidSecp256k1PublicKey(err error) sdk.Error
- func ErrInvalidSignature(sig []byte) sdk.Error
- func ErrInvalidVeriMethodID(id string) sdk.Error
- func ErrSigVerificationFailed() sdk.Error
- func ErrVeriMethodIDNotFound(id VeriMethodID) sdk.Error
- func NewPrivKeyFromBytes(bz []byte) (secp256k1.PrivKeySecp256k1, error)
- func NewPubKeyFromBase58(b58 string) (secp256k1.PubKeySecp256k1, error)
- func RegisterCodec(cdc *codec.Codec)
- func Sign(data Signable, seq Sequence, privKey crypto.PrivKey) ([]byte, error)
- func ValidateGenesis(data GenesisState) error
- type Authentication
- type Context
- type Contexts
- type DID
- type DIDDocument
- type DIDDocumentWithSeq
- type GenesisDIDDocumentKey
- type GenesisState
- type KeyType
- type MsgCreateDID
- type MsgDeactivateDID
- type MsgUpdateDID
- type QueryDIDParams
- type Sequence
- type Signable
- type VeriMethod
- type VeriMethodID
Constants ¶
const ( DIDMethod = "panacea" Base58Charset = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz" )
const ( CodeDIDExists sdk.CodeType = 101 CodeInvalidDID sdk.CodeType = 102 CodeInvalidDIDDocument sdk.CodeType = 103 CodeDIDNotFound sdk.CodeType = 104 CodeInvalidSignature sdk.CodeType = 105 CodeInvalidVeriMethodID sdk.CodeType = 106 CodeVeriMethodIDNotFound sdk.CodeType = 107 CodeSigVerificationFailed sdk.CodeType = 108 CodeInvalidSecp256k1PublicKey sdk.CodeType = 109 CodeInvalidNetworkID sdk.CodeType = 110 CodeInvalidDIDDocumentWithSeq sdk.CodeType = 111 CodeDIDDeactivated sdk.CodeType = 112 CodeInvalidKeyController sdk.CodeType = 113 )
const ( // module name ModuleName = "did" // StoreKey to be used when creating the KVStore StoreKey = ModuleName // RouterKey to be used in router RouterKey = ModuleName // QuerierRoute is the query router key QuerierRoute = ModuleName )
const DefaultCodespace sdk.CodespaceType = ModuleName
const InitialSequence = Sequence(0)
const (
QueryDID = "did"
)
Variables ¶
var ModuleCdc *codec.Codec
ModuleCdc generic sealed codec to be used throughout module
Functions ¶
func ErrDIDDeactivated ¶
func ErrDIDExists ¶
func ErrDIDNotFound ¶
func ErrInvalidDID ¶
func ErrInvalidDIDDocument ¶
func ErrInvalidDIDDocument(doc DIDDocument) sdk.Error
func ErrInvalidDIDDocumentWithSeq ¶
func ErrInvalidDIDDocumentWithSeq(doc DIDDocumentWithSeq) sdk.Error
func ErrInvalidKeyController ¶
func ErrInvalidNetworkID ¶
func ErrInvalidSignature ¶
func ErrInvalidVeriMethodID ¶
func ErrVeriMethodIDNotFound ¶
func ErrVeriMethodIDNotFound(id VeriMethodID) sdk.Error
func NewPrivKeyFromBytes ¶
func NewPrivKeyFromBytes(bz []byte) (secp256k1.PrivKeySecp256k1, error)
NewPrivKeyFromBytes converts a byte slice into a Secp256k1 private key. It returns an error when the length of the input is invalid.
func NewPubKeyFromBase58 ¶
func NewPubKeyFromBase58(b58 string) (secp256k1.PubKeySecp256k1, error)
NewPubKeyFromBase58 decodes a base58-encoded Secp256k1 public key. It returns an error when the length of the input is invalid.
func RegisterCodec ¶
RegisterCodec registers concrete types on Amino codec
func ValidateGenesis ¶
func ValidateGenesis(data GenesisState) error
Types ¶
type Authentication ¶
type Authentication struct { VeriMethodID VeriMethodID // DedicatedMethod is not nil if it is only authorized for authentication // https://www.w3.org/TR/did-core/#example-18-authentication-property-containing-three-verification-methods DedicatedMethod *VeriMethod }
func (Authentication) MarshalJSON ¶
func (a Authentication) MarshalJSON() ([]byte, error)
func (*Authentication) UnmarshalJSON ¶
func (a *Authentication) UnmarshalJSON(bz []byte) error
func (Authentication) Valid ¶
func (a Authentication) Valid(did DID) bool
type Contexts ¶
type Contexts []Context
func (Contexts) MarshalJSON ¶
func (*Contexts) UnmarshalJSON ¶
type DID ¶
type DID string
func (DID) GetSignBytes ¶
GetSignBytes returns a byte array which is used to generate a signature for verifying DID ownership.
type DIDDocument ¶
type DIDDocument struct { Contexts Contexts `json:"@context"` ID DID `json:"id"` VeriMethods []VeriMethod `json:"verificationMethod"` Authentications []Authentication `json:"authentication"` }
func NewDIDDocument ¶
func NewDIDDocument(id DID, veriMethod VeriMethod) DIDDocument
func (DIDDocument) Empty ¶
func (doc DIDDocument) Empty() bool
func (DIDDocument) GetSignBytes ¶
func (doc DIDDocument) GetSignBytes() []byte
GetSignBytes returns a byte array which is used to generate a signature for verifying DID ownership.
func (DIDDocument) String ¶
func (doc DIDDocument) String() string
func (DIDDocument) Valid ¶
func (doc DIDDocument) Valid() bool
func (DIDDocument) VeriMethodByID ¶
func (doc DIDDocument) VeriMethodByID(id VeriMethodID) (VeriMethod, bool)
VeriMethodByID finds a VeriMethod by ID. If the corresponding VeriMethod doesn't exist, it returns a false.
type DIDDocumentWithSeq ¶
type DIDDocumentWithSeq struct { Document DIDDocument `json:"document"` Seq Sequence `json:"sequence"` }
DIDDocumentWithSeq is for storing a Sequence along with a DIDDocument. The Sequence is used to make DID operations not replay-able. It's used to generate signatures of DID operations.
func NewDIDDocumentWithSeq ¶
func NewDIDDocumentWithSeq(doc DIDDocument, seq Sequence) DIDDocumentWithSeq
func (DIDDocumentWithSeq) Deactivate ¶
func (d DIDDocumentWithSeq) Deactivate(newSeq Sequence) DIDDocumentWithSeq
Deactivate creates a new DIDDocumentWithSeq with an empty DIDDocument (tombstone). Note that it requires a new sequence.
func (DIDDocumentWithSeq) Deactivated ¶
func (d DIDDocumentWithSeq) Deactivated() bool
Deactivated returns true if the DIDDocument has been activated.
func (DIDDocumentWithSeq) Empty ¶
func (d DIDDocumentWithSeq) Empty() bool
Empty returns true if all members in DIDDocumentWithSeq are empty. The empty struct means that the entity doesn't exist.
func (DIDDocumentWithSeq) Valid ¶
func (d DIDDocumentWithSeq) Valid() bool
type GenesisDIDDocumentKey ¶
type GenesisDIDDocumentKey struct {
DID DID `json:"did"`
}
func (GenesisDIDDocumentKey) Marshal ¶
func (k GenesisDIDDocumentKey) Marshal() string
func (*GenesisDIDDocumentKey) Unmarshal ¶
func (k *GenesisDIDDocumentKey) Unmarshal(key string) error
type GenesisState ¶
type GenesisState struct {
Documents map[string]DIDDocumentWithSeq `json:"documents"`
}
func DefaultGenesisState ¶
func DefaultGenesisState() GenesisState
type MsgCreateDID ¶
type MsgCreateDID struct { DID DID `json:"did"` Document DIDDocument `json:"document"` VeriMethodID VeriMethodID `json:"verification_method_id"` Signature []byte `json:"signature"` FromAddress sdk.AccAddress `json:"from_address"` }
MsgCreateDID defines a CreateDID message.
func NewMsgCreateDID ¶
func NewMsgCreateDID(did DID, doc DIDDocument, veriMethodID VeriMethodID, sig []byte, fromAddr sdk.AccAddress) MsgCreateDID
NewMsgCreateDID is a constructor of MsgCreateDID.
func (MsgCreateDID) GetSignBytes ¶
func (msg MsgCreateDID) GetSignBytes() []byte
GetSignBytes returns the canonical byte representation of the message. Used to generate a signature.
func (MsgCreateDID) GetSigners ¶
func (msg MsgCreateDID) GetSigners() []sdk.AccAddress
GetSigners return the addresses of signers that must sign.
func (MsgCreateDID) Route ¶
func (msg MsgCreateDID) Route() string
Route returns the name of the module.
func (MsgCreateDID) Type ¶
func (msg MsgCreateDID) Type() string
Type returns the name of the action.
func (MsgCreateDID) ValidateBasic ¶
func (msg MsgCreateDID) ValidateBasic() sdk.Error
ValidateBasic runs stateless checks on the message.
type MsgDeactivateDID ¶
type MsgDeactivateDID struct { DID DID `json:"did"` VeriMethodID VeriMethodID `json:"verification_method_id"` Signature []byte `json:"signature"` FromAddress sdk.AccAddress `json:"from_address"` }
MsgDeactivateDID defines a UpdateDID message.
func NewMsgDeactivateDID ¶
func NewMsgDeactivateDID(did DID, veriMethodID VeriMethodID, sig []byte, fromAddr sdk.AccAddress) MsgDeactivateDID
NewMsgDeactivateDID is a constructor of MsgDeactivateDID.
func (MsgDeactivateDID) GetSignBytes ¶
func (msg MsgDeactivateDID) GetSignBytes() []byte
GetSignBytes returns the canonical byte representation of the message. Used to generate a signature.
func (MsgDeactivateDID) GetSigners ¶
func (msg MsgDeactivateDID) GetSigners() []sdk.AccAddress
GetSigners return the addresses of signers that must sign.
func (MsgDeactivateDID) Route ¶
func (msg MsgDeactivateDID) Route() string
Route returns the name of the module.
func (MsgDeactivateDID) Type ¶
func (msg MsgDeactivateDID) Type() string
Type returns the name of the action.
func (MsgDeactivateDID) ValidateBasic ¶
func (msg MsgDeactivateDID) ValidateBasic() sdk.Error
VaValidateBasic runs stateless checks on the message.
type MsgUpdateDID ¶
type MsgUpdateDID struct { DID DID `json:"did"` Document DIDDocument `json:"document"` VeriMethodID VeriMethodID `json:"verification_method_id"` Signature []byte `json:"signature"` FromAddress sdk.AccAddress `json:"from_address"` }
MsgUpdateDID defines a UpdateDID message.
func NewMsgUpdateDID ¶
func NewMsgUpdateDID(did DID, doc DIDDocument, veriMethodID VeriMethodID, sig []byte, fromAddr sdk.AccAddress) MsgUpdateDID
NewMsgUpdateDID is a constructor of MsgUpdateDID.
func (MsgUpdateDID) GetSignBytes ¶
func (msg MsgUpdateDID) GetSignBytes() []byte
GetSignBytes returns the canonical byte representation of the message. Used to generate a signature.
func (MsgUpdateDID) GetSigners ¶
func (msg MsgUpdateDID) GetSigners() []sdk.AccAddress
GetSigners return the addresses of signers that must sign.
func (MsgUpdateDID) Route ¶
func (msg MsgUpdateDID) Route() string
Route returns the name of the module.
func (MsgUpdateDID) Type ¶
func (msg MsgUpdateDID) Type() string
Type returns the name of the action.
func (MsgUpdateDID) ValidateBasic ¶
func (msg MsgUpdateDID) ValidateBasic() sdk.Error
ValidateBasic runs stateless checks on the message.
type QueryDIDParams ¶
type QueryDIDParams struct {
DID DID
}
func NewQueryDIDParams ¶
func NewQueryDIDParams(DID DID) *QueryDIDParams
type Sequence ¶
type Sequence uint64
Sequence is a preventative measure to distinguish replayed transactions (replay attack).
type Signable ¶
type Signable interface { // Get the canonical byte representation of the data. GetSignBytes() []byte }
Signable is an interface for data which can be converted to a sign-able byte slice (deterministic).
type VeriMethod ¶
type VeriMethod struct { ID VeriMethodID `json:"id"` Type KeyType `json:"type"` Controller DID `json:"controller"` PubKeyBase58 string `json:"publicKeyBase58"` }
TODO: support various types: https://www.w3.org/TR/did-core/#key-types-and-formats
func NewVeriMethod ¶
func NewVeriMethod(id VeriMethodID, keyType KeyType, controller DID, key crypto.PubKey) VeriMethod
func (VeriMethod) Valid ¶
func (pk VeriMethod) Valid(did DID) bool
type VeriMethodID ¶
type VeriMethodID string
func NewVeriMethodID ¶
func NewVeriMethodID(did DID, name string) VeriMethodID
func ParseVeriMethodID ¶
func ParseVeriMethodID(id string, did DID) (VeriMethodID, error)
func (VeriMethodID) Valid ¶
func (id VeriMethodID) Valid(did DID) bool