Documentation ¶
Index ¶
- Constants
- Variables
- func Contains(vs []string, t string) bool
- func Filter(vs []string, f func(string) bool) []string
- func GetEd25519VerificationKey2020(keyBytes []byte) []byte
- func GetTxHash(txBytes []byte) string
- func IndexOf(array []string, searchElement string, fromIndex int) int
- func IsUnique(list []string) bool
- func IsValidBase58(data string) bool
- func IsValidDID(did string, method string, allowedNamespaces []string) bool
- func IsValidDIDUrl(didURL string, method string, allowedNamespaces []string) bool
- func IsValidID(id string) bool
- func IsValidIndyID(data string) bool
- func IsValidUUID(u string) bool
- func JoinDID(method, namespace, id string) string
- func JoinDIDUrl(did string, path string, query string, fragment string) string
- func MustEncodeJSON(data interface{}) string
- func MustEncodeMultibaseBase58(data []byte) string
- func MustSplitDID(did string) (method string, namespace string, id string)
- func MustSplitDIDUrl(didURL string) (did string, path string, query string, fragment string)
- func NormalizeDID(did string) string
- func NormalizeDIDList(didList []string) []string
- func NormalizeDIDUrl(didURL string) string
- func NormalizeDIDUrlList(didURLs []string) []string
- func NormalizeID(id string) string
- func NormalizeIDList(keys []string) []string
- func NormalizeUUID(uuid string) string
- func ReplaceDidInDidURL(didURL string, oldDid string, newDid string) string
- func ReplaceDidInDidURLList(didURLList []string, oldDid string, newDid string) []string
- func ReplaceInSlice(list []string, old, new string)
- func StrBytes(p string) []byte
- func Subtract(minuend []string, subtrahend []string) []string
- func ToInterfaces(list []string) []interface{}
- func TrySplitDID(did string) (method string, namespace string, id string, err error)
- func TrySplitDIDUrl(didURL string) (did string, path string, query string, fragment string, err error)
- func Unique(array []string) []string
- func UniqueSorted(ls []string) []string
- func ValidateBase58(data string) error
- func ValidateBase58Ed25519VerificationKey2018(data string) error
- func ValidateDID(did string, method string, allowedNamespaces []string) error
- func ValidateDIDUrl(didURL string, method string, allowedNamespaces []string) error
- func ValidateEd25519PubKey(keyBytes []byte) error
- func ValidateFragment(fragment string) error
- func ValidateID(id string) error
- func ValidateJWK(jwkString string) error
- func ValidateMultibase(data string) error
- func ValidateMultibaseEd25519VerificationKey2020(data string) error
- func ValidateMultibaseEncoding(data string, expectedEncoding multibase.Encoding) error
- func ValidateMulticodecEd25519VerificationKey2020(keyBytes []byte) error
- func ValidatePath(path string) error
- func ValidateQuery(query string) error
- func ValidateURI(uri string) error
- func ValidateUUID(u string) error
- func VerifyECDSASignature(pubKey ecdsa.PublicKey, message []byte, signature []byte) error
- func VerifyED25519Signature(pubKey ed25519.PublicKey, message []byte, signature []byte) error
- func VerifyRSASignature(pubKey rsa.PublicKey, message []byte, signature []byte) error
Constants ¶
const (
IndyIDLength = 16
)
const StandardUUIDLength = 36
Variables ¶
var ( SplitDIDRegexp = regexp.MustCompile(`^did:([^:]+?)(:([^:]+?))?:([^:]+)$`) DidNamespaceRegexp = regexp.MustCompile(`^[a-zA-Z0-9]*$`) )
var ( DIDPathAbemptyRegexp = regexp.MustCompile(`^([/a-zA-Z0-9\-\.\_\~\!\$\&\'\(\)\*\+\,\;\=\:\@]*|(%[0-9A-Fa-f]{2})*)*$`) DIDQueryRegexp = regexp.MustCompile(`^([/a-zA-Z0-9\-\.\_\~\!\$\&\'\(\)\*\+\,\;\=\:\@\/\?]*|(%[0-9A-Fa-f]{2})*)*$`) DIDFragmentRegexp = regexp.MustCompile(`^([/a-zA-Z0-9\-\.\_\~\!\$\&\'\(\)\*\+\,\;\=\:\@\/\?]*|(%[0-9A-Fa-f]{2})*)*$`) )
var SplitDIDURLRegexp = regexp.MustCompile(`([^/?#]*)?([^?#]*)(\?([^#]*))?(#([^#]+$))?$`)
SplitDIDURLRegexp ... That for groups: Example: did:cheqd:testnet:fafdsffq11213343/path-to-s/ome-external-resource?query#key1??? 1 - [^/?#]* - all the symbols except / and ? and # . This is the DID part (did:cheqd:testnet:fafdsffq11213343) 2 - [^?#]* - all the symbols except ? and #. it means te section started from /, path-abempty (/path-to-s/ome-external-resource) 3 - \?([^#]*) - group for `query` part but with ? symbol (?query) 4 - [^#]* - group inside query string, match only exact query (query) 5 - #([^#]+[\$]?) - group for fragment, starts with #, includes # (#key1???) 6 - [^#]+[\$]? - fragment only (key1???) Number of queries is not limited.
var ValidURIRegexp = regexp.MustCompile(`^(([^:\/?#]+):)?(\/\/([^\/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?`)
ValidURIRegexp ... Goes from RFC: https://www.rfc-editor.org/rfc/rfc3986#appendix-B
Functions ¶
func GetEd25519VerificationKey2020 ¶ added in v1.1.0
func IsValidBase58 ¶
func IsValidDIDUrl ¶
func IsValidIndyID ¶ added in v1.1.0
func IsValidUUID ¶
func MustEncodeJSON ¶ added in v1.1.0
func MustEncodeJSON(data interface{}) string
func MustSplitDIDUrl ¶
func NormalizeDID ¶
func NormalizeDIDList ¶
func NormalizeDIDUrl ¶
func NormalizeDIDUrlList ¶
func NormalizeID ¶ added in v1.1.0
func NormalizeIDList ¶ added in v1.1.0
func NormalizeUUID ¶
func ReplaceDidInDidURL ¶ added in v1.1.0
func ReplaceDidInDidURLList ¶ added in v1.1.0
func ReplaceInSlice ¶
func ToInterfaces ¶
func ToInterfaces(list []string) []interface{}
func TrySplitDID ¶
TrySplitDID Validates generic format of DID. It doesn't validate method, name and id content. Call ValidateDID for further validation.
func TrySplitDIDUrl ¶
func TrySplitDIDUrl(didURL string) (did string, path string, query string, fragment string, err error)
TrySplitDIDUrl Validates generic format of DIDUrl. It doesn't validate path, query and fragment content. Call ValidateDIDUrl for further validation.
func UniqueSorted ¶
func ValidateBase58 ¶
func ValidateBase58Ed25519VerificationKey2018 ¶ added in v1.1.0
func ValidateDID ¶
ValidateDID checks method and allowed namespaces only when the corresponding parameters are specified.
func ValidateDIDUrl ¶
ValidateDIDUrl checks method and allowed namespaces only when the corresponding parameters are specified.
func ValidateEd25519PubKey ¶
func ValidateFragment ¶
func ValidateID ¶
func ValidateJWK ¶
func ValidateMultibase ¶
func ValidateMultibaseEd25519VerificationKey2020 ¶ added in v1.1.0
func ValidateMulticodecEd25519VerificationKey2020 ¶ added in v1.1.0
func ValidatePath ¶
func ValidateQuery ¶
func ValidateURI ¶
func ValidateUUID ¶
func VerifyECDSASignature ¶
VerifyECDSASignature uses ASN1 to decode r and s, SHA265 to calculate message digest
func VerifyED25519Signature ¶
func VerifyRSASignature ¶
VerifyRSASignature uses PSS padding and SHA256 digest A good explanation of different paddings: https://security.stackexchange.com/questions/183179/what-is-rsa-oaep-rsa-pss-in-simple-terms
Types ¶
This section is empty.