libutils

package
v0.0.0-...-49972a8 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2022 License: LGPL-2.1 Imports: 28 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ErrorParseJWS          = `error parsing into JWS`
	ErrorParseX509         = `error parsing into X509`
	ErrorBase64            = `error decoding into base64`
	ErrorVerifying         = `error verifying signature`
	ErrorGetMSPID          = `failed getting the client's MSPID: %v`
	ErrorGetIdentity       = `failed to get identity %s`
	ErrorUpdateIdentity    = `failed to update identity %s`
	ErrorIdentityExists    = `identity %s already exists`
	ErrorDefaultNotExist   = `%s does not exist`
	ErrorRequiredParameter = "a required parameter (%s) was not provided"
)

Error responses errorXXX occurs when XXX

Variables

This section is empty.

Functions

func CertificateAlreadyExists

func CertificateAlreadyExists(ctx contractapi.TransactionContextInterface, certPemBase64 string, indexName string, attributes []string) (bool, error)

CertificateAlreadyExists check if the certificate already exists in the world-state deprecated: Certificates will be stored in ledger, only public key

Arguments:

0: certPemBase64 - certificate to validate
1: indexName -
2: attributes -

Returns:

0: bool
1: error

func CheckAttr

func CheckAttr(name, value string, attrs *attrmgr.Attributes) (bool, error)

CheckAttr return value for a certificate attribute or check the value of an attribute

func CheckSignatureFrom

func CheckSignatureFrom(certRoot []byte, certIssue []byte) error

CheckSignatureFrom verifies that the signature on certIssue is a valid signature from Root Cert.

func CompareCertsPemBase64

func CompareCertsPemBase64(cert1, cert2 string) bool

func ConcatenateBytes

func ConcatenateBytes(data ...[]byte) []byte

ConcatenateBytes is useful for combining multiple arrays of bytes, especially for signatures or digests over multiple fields

func ConstructQueryResponseFromIterator

func ConstructQueryResponseFromIterator(resultsIterator shim.StateQueryIteratorInterface) ([]interface{}, error)

ConstructQueryResponseFromIterator constructs a slice of assets from the resultsIterator

func Contains

func Contains(arr []string, elem string) bool

func CreateIndex

func CreateIndex(stub shim.ChaincodeStubInterface, indexName string, attributes []string) error

CreateIndex create search index for ledger

Arguments:

0: indexName -
1: attributes -

Returns:

0: error

func DeepCopy

func DeepCopy(v interface{}) (interface{}, error)

func DeleteIndex

func DeleteIndex(stub shim.ChaincodeStubInterface, indexName string, attributes []string, validateDelState bool) error

DeleteIndex remove search index for ledger

Arguments:

0: indexName -
1: attributes -

Returns:

0: error

func DidFormat

func DidFormat(hashPubKey string) string

func FunctionCompare

func FunctionCompare(f1, f2 string) (bool, error)

FunctionCompare compares one function name with another, the input parameter can be in the form "org.tecnomatica.participant:GetParticipant"

func GenerateUUIDBytes

func GenerateUUIDBytes() []byte

GenerateUUIDBytes returns a UUID based on RFC 4122 returning the generated bytes

func GenerateUUIDFormatDate

func GenerateUUIDFormatDate(stub shim.ChaincodeStubInterface) string

func GenerateUUIDStr

func GenerateUUIDStr() string

GenerateUUIDStr returns a UUID based on RFC 4122

func GetAttrsNonStandardCert

func GetAttrsNonStandardCert(certPem []byte) (map[string]string, error)

func GetBoolOrDefault

func GetBoolOrDefault(value string, defaultVal bool) bool

GetBoolOrDefault Note that the method returns default value if the string cannot be parsed!

func GetDateCertificate

func GetDateCertificate(cert *x509.Certificate) map[string]string

GetDateCertificate returns the issue and expiration date of a certificate

func GetEnvOrDefault

func GetEnvOrDefault(env, defaultVal string) string

func GetPublicKey

func GetPublicKey(cert *x509.Certificate) (string, error)

func GetQueryResultForQueryString

func GetQueryResultForQueryString(ctx contractapi.TransactionContextInterface, queryString string) ([]interface{}, error)

GetQueryResultForQueryString executes the passed in query string. The result set is built and returned as a byte array containing the JSON results.

func GetQueryResultForQueryStringWithPagination

func GetQueryResultForQueryStringWithPagination(ctx contractapi.TransactionContextInterface, queryString string, pageSize int32, bookmark string) (*model.PaginatedQueryResponse, error)

GetQueryResultForQueryStringWithPagination executes the passed in query string with pagination info. The result set is built and returned as a byte array containing the JSON results.

func GetTxTimestampRFC3339

func GetTxTimestampRFC3339(stub shim.ChaincodeStubInterface) (string, error)

func GetX509CertFromPem

func GetX509CertFromPem(certPemBase64 string) (*x509.Certificate, error)

GetX509CertFromPem use to validate cert

func GetX509CertFromPemByte

func GetX509CertFromPemByte(certPem []byte) (*x509.Certificate, error)

GetX509CertFromPemByte use to validate cert

func HasExpired

func HasExpired(cert *x509.Certificate) error

func MapToSlice

func MapToSlice(dMap map[string]string) []string

func NormalizeString

func NormalizeString(text string) string

NormalizeString

func ParseRFC3339toTime

func ParseRFC3339toTime(tm string) (time.Time, error)

func SliceToMap

func SliceToMap(slice []string, dMap map[string]string)

func ToChaincodeArgs

func ToChaincodeArgs(args ...string) [][]byte

ToChaincodeArgs converts string args to []byte args

func UpdateJSON

func UpdateJSON(request interface{}, stateDB interface{}) ([]byte, error)

func VerifyIssuedByRootCert

func VerifyIssuedByRootCert(certRoot []byte, certIssue []byte) error

VerifyIssuedByRootCert Verify cert issued by Root Certificate.

func VerifySignature

func VerifySignature(message string, key string) ([]byte, error)

Types

type BeforeTransactionUnmarshalResponse

type BeforeTransactionUnmarshalResponse struct {
	Id       string `json:"id"` // user id or did
	Function string `json:"function"`
}

Jump to

Keyboard shortcuts

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