legacydid

package
v0.1.0-xco.1 Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2022 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultCodespace = "xco.lib.legacydid"
)

Variables

View Source
var (
	ValidDid      = regexp.MustCompile(`^did\:[a-z0-9]+\:(?:([A-Z.a-z0-9]|\-|_|%[0-9A-Fa-f][0-9A-Fa-f])*\:)*(?:[A-Z.a-z0-9]|\-|_|%[0-9A-Fa-f][0-9A-Fa-f])+(?:#[a-zA-Z0-9-\._]+)?$`)
	ValidPubKey   = regexp.MustCompile(`^[123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ]{43,44}$`)
	IsValidDid    = ValidDid.MatchString
	IsValidPubKey = ValidPubKey.MatchString
)
View Source
var (
	ErrInvalidLengthDid        = fmt.Errorf("proto: negative length found during unmarshaling")
	ErrIntOverflowDid          = fmt.Errorf("proto: integer overflow")
	ErrUnexpectedEndOfGroupDid = fmt.Errorf("proto: unexpected end of group")
)
View Source
var (
	ErrInvalidLengthDiddoc        = fmt.Errorf("proto: negative length found during unmarshaling")
	ErrIntOverflowDiddoc          = fmt.Errorf("proto: integer overflow")
	ErrUnexpectedEndOfGroupDiddoc = fmt.Errorf("proto: unexpected end of group")
)
View Source
var (
	ErrInvalidDid         = sdkerrors.Register(DefaultCodespace, 2, "invalid did")
	ErrInvalidPubKey      = sdkerrors.Register(DefaultCodespace, 3, "invalid pubKey")
	ErrDidPubKeyMismatch  = sdkerrors.Register(DefaultCodespace, 4, "did pubKey mismatch")
	ErrInvalidIssuer      = sdkerrors.Register(DefaultCodespace, 5, "invalid issuer")
	ErrInvalidCredentials = sdkerrors.Register(DefaultCodespace, 6, "invalid credentials")
	ErrInvalidClaimId     = sdkerrors.Register(DefaultCodespace, 7, "invalid claim ID")
)
View Source
var DidPrefix = "did:xco:"

Functions

func FromMnemonic

func FromMnemonic(mnemonic string) (xcodid, error)

func FromSeed

func FromSeed(seed [32]byte) (xcodid, error)

func Gen

func Gen() (xcodid, error)

func GenerateMnemonic

func GenerateMnemonic() (string, error)

func Newxcodid

func Newxcodid(did, verifyKey, encryptionPublicKey string, secret Secret) xcodid

func Unmarshalxcodid

func Unmarshalxcodid(jsonxcodid string) (xcodid, error)

func UnprefixedDid

func UnprefixedDid(did Did) string

func UnprefixedDidFromPubKey

func UnprefixedDidFromPubKey(pubKey string) string

func VerifyKeyToAddr

func VerifyKeyToAddr(verifyKey string) sdk.AccAddress

Types

type BaseDidDoc

type BaseDidDoc struct {
	Did         string           `protobuf:"bytes,1,opt,name=did,proto3" json:"did,omitempty" yaml:"did"`
	PubKey      string           `protobuf:"bytes,2,opt,name=pub_key,json=pubKey,proto3" json:"pubKey" yaml:"pubKey"`
	Credentials []*DidCredential `protobuf:"bytes,3,rep,name=credentials,proto3" json:"credentials,omitempty" yaml:"credentials"`
}

BaseDidDoc defines a base DID document type. It implements the DidDoc interface.

func (*BaseDidDoc) Descriptor

func (*BaseDidDoc) Descriptor() ([]byte, []int)

func (*BaseDidDoc) Marshal

func (m *BaseDidDoc) Marshal() (dAtA []byte, err error)

func (*BaseDidDoc) MarshalTo

func (m *BaseDidDoc) MarshalTo(dAtA []byte) (int, error)

func (*BaseDidDoc) MarshalToSizedBuffer

func (m *BaseDidDoc) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*BaseDidDoc) ProtoMessage

func (*BaseDidDoc) ProtoMessage()

func (*BaseDidDoc) Reset

func (m *BaseDidDoc) Reset()

func (*BaseDidDoc) Size

func (m *BaseDidDoc) Size() (n int)

func (*BaseDidDoc) String

func (m *BaseDidDoc) String() string

func (*BaseDidDoc) Unmarshal

func (m *BaseDidDoc) Unmarshal(dAtA []byte) error

func (*BaseDidDoc) XXX_DiscardUnknown

func (m *BaseDidDoc) XXX_DiscardUnknown()

func (*BaseDidDoc) XXX_Marshal

func (m *BaseDidDoc) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*BaseDidDoc) XXX_Merge

func (m *BaseDidDoc) XXX_Merge(src proto.Message)

func (*BaseDidDoc) XXX_Size

func (m *BaseDidDoc) XXX_Size() int

func (*BaseDidDoc) XXX_Unmarshal

func (m *BaseDidDoc) XXX_Unmarshal(b []byte) error

type Claim

type Claim struct {
	Id           string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty" yaml:"id"`
	KYCValidated bool   `protobuf:"varint,2,opt,name=KYC_validated,json=KYCValidated,proto3" json:"KYCValidated" yaml:"KYCValidated"`
}

The claim section of a credential, indicating if the DID is KYC validated

func (*Claim) Descriptor

func (*Claim) Descriptor() ([]byte, []int)

func (*Claim) GetId

func (m *Claim) GetId() string

func (*Claim) GetKYCValidated

func (m *Claim) GetKYCValidated() bool

func (*Claim) Marshal

func (m *Claim) Marshal() (dAtA []byte, err error)

func (*Claim) MarshalTo

func (m *Claim) MarshalTo(dAtA []byte) (int, error)

func (*Claim) MarshalToSizedBuffer

func (m *Claim) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*Claim) ProtoMessage

func (*Claim) ProtoMessage()

func (*Claim) Reset

func (m *Claim) Reset()

func (*Claim) Size

func (m *Claim) Size() (n int)

func (*Claim) String

func (m *Claim) String() string

func (*Claim) Unmarshal

func (m *Claim) Unmarshal(dAtA []byte) error

func (*Claim) XXX_DiscardUnknown

func (m *Claim) XXX_DiscardUnknown()

func (*Claim) XXX_Marshal

func (m *Claim) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*Claim) XXX_Merge

func (m *Claim) XXX_Merge(src proto.Message)

func (*Claim) XXX_Size

func (m *Claim) XXX_Size() int

func (*Claim) XXX_Unmarshal

func (m *Claim) XXX_Unmarshal(b []byte) error

type Did

type Did = string

type DidCredential

type DidCredential struct {
	CredType []string `protobuf:"bytes,1,rep,name=cred_type,json=credType,proto3" json:"type" yaml:"type"`
	Issuer   string   `protobuf:"bytes,2,opt,name=issuer,proto3" json:"issuer,omitempty" yaml:"issuer"`
	Issued   string   `protobuf:"bytes,3,opt,name=issued,proto3" json:"issued,omitempty" yaml:"issued"`
	Claim    *Claim   `protobuf:"bytes,4,opt,name=claim,proto3" json:"claim,omitempty" yaml:"claim"`
}

Digital identity credential issued to an xco DID

func (*DidCredential) Descriptor

func (*DidCredential) Descriptor() ([]byte, []int)

func (*DidCredential) GetClaim

func (m *DidCredential) GetClaim() *Claim

func (*DidCredential) GetCredType

func (m *DidCredential) GetCredType() []string

func (*DidCredential) GetIssued

func (m *DidCredential) GetIssued() string

func (*DidCredential) GetIssuer

func (m *DidCredential) GetIssuer() string

func (*DidCredential) Marshal

func (m *DidCredential) Marshal() (dAtA []byte, err error)

func (*DidCredential) MarshalTo

func (m *DidCredential) MarshalTo(dAtA []byte) (int, error)

func (*DidCredential) MarshalToSizedBuffer

func (m *DidCredential) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*DidCredential) ProtoMessage

func (*DidCredential) ProtoMessage()

func (*DidCredential) Reset

func (m *DidCredential) Reset()

func (*DidCredential) Size

func (m *DidCredential) Size() (n int)

func (*DidCredential) String

func (m *DidCredential) String() string

func (*DidCredential) Unmarshal

func (m *DidCredential) Unmarshal(dAtA []byte) error

func (*DidCredential) XXX_DiscardUnknown

func (m *DidCredential) XXX_DiscardUnknown()

func (*DidCredential) XXX_Marshal

func (m *DidCredential) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*DidCredential) XXX_Merge

func (m *DidCredential) XXX_Merge(src proto.Message)

func (*DidCredential) XXX_Size

func (m *DidCredential) XXX_Size() int

func (*DidCredential) XXX_Unmarshal

func (m *DidCredential) XXX_Unmarshal(b []byte) error

type DidDoc

type DidDoc interface {
	proto.Message

	SetDid(did Did) error
	GetDid() Did
	SetPubKey(pubkey string) error
	GetPubKey() string
	Address() sdk.AccAddress
}

type Secret

type Secret struct {
	Seed                 string `protobuf:"bytes,1,opt,name=seed,proto3" json:"seed,omitempty" yaml:"seed"`
	SignKey              string `protobuf:"bytes,2,opt,name=sign_key,json=signKey,proto3" json:"signKey" yaml:"signKey"`
	EncryptionPrivateKey string `` /* 139-byte string literal not displayed */
}

The private section of an xco DID, based on the Sovrin DID spec

func NewSecret

func NewSecret(seed, signKey, encryptionPrivateKey string) Secret

func (*Secret) Descriptor

func (*Secret) Descriptor() ([]byte, []int)

func (Secret) Equals

func (s Secret) Equals(other Secret) bool

func (*Secret) GetEncryptionPrivateKey

func (m *Secret) GetEncryptionPrivateKey() string

func (*Secret) GetSeed

func (m *Secret) GetSeed() string

func (*Secret) GetSignKey

func (m *Secret) GetSignKey() string

func (*Secret) Marshal

func (m *Secret) Marshal() (dAtA []byte, err error)

func (*Secret) MarshalTo

func (m *Secret) MarshalTo(dAtA []byte) (int, error)

func (*Secret) MarshalToSizedBuffer

func (m *Secret) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*Secret) ProtoMessage

func (*Secret) ProtoMessage()

func (*Secret) Reset

func (m *Secret) Reset()

func (*Secret) Size

func (m *Secret) Size() (n int)

func (*Secret) String

func (m *Secret) String() string

func (*Secret) Unmarshal

func (m *Secret) Unmarshal(dAtA []byte) error

func (*Secret) XXX_DiscardUnknown

func (m *Secret) XXX_DiscardUnknown()

func (*Secret) XXX_Marshal

func (m *Secret) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*Secret) XXX_Merge

func (m *Secret) XXX_Merge(src proto.Message)

func (*Secret) XXX_Size

func (m *Secret) XXX_Size() int

func (*Secret) XXX_Unmarshal

func (m *Secret) XXX_Unmarshal(b []byte) error

Jump to

Keyboard shortcuts

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