Documentation ¶
Index ¶
- Constants
- func DIDsToBytes(dids ...*DID) [][]byte
- func DIDsToStrings(dids ...*DID) []string
- func ValidateDIDBytes(givenDID []byte, did DID) error
- type Config
- type DID
- func BytesToDIDs(bytes ...[]byte) ([]*DID, error)
- func DIDsPointers(dids ...DID) []*DID
- func FromPointerDIDs(pdids ...*DID) []DID
- func NewDID(address common.Address) DID
- func NewDIDFromBytes(bAddr []byte) (DID, error)
- func NewDIDFromString(address string) (DID, error)
- func RemoveDuplicateDIDs(dids []DID) []DID
- func StringsToDIDs(strs ...string) ([]*DID, error)
- type Factory
- type IDKey
- type IDKeys
- type IDTX
- type Key
- type KeyResponse
- type Purpose
- type Service
Constants ¶
const ( // ErrMalformedAddress standard error for malformed address ErrMalformedAddress = errors.Error("malformed address provided") // ErrInvalidDIDLength must be used with invalid bytelength when attempting to convert to a DID ErrInvalidDIDLength = errors.Error("invalid DID length") // BootstrappedDIDFactory stores the id of the factoryV2 BootstrappedDIDFactory string = "BootstrappedDIDFactory" // BootstrappedDIDService stores the id of the service BootstrappedDIDService string = "BootstrappedDIDService" // KeyTypeECDSA has the value one in the ERC725 identity contract KeyTypeECDSA = 1 )
const DIDLength = common.AddressLength
DIDLength contains the length of a DID
Variables ¶
This section is empty.
Functions ¶
func DIDsToStrings ¶
DIDsToStrings converts DIDs to hex strings.
func ValidateDIDBytes ¶
ValidateDIDBytes validates a centrifuge ID given as bytes
Types ¶
type Config ¶
type Config interface {
GetEthereumGasLimit(op config.ContractOp) uint64
}
Config defines methods required for the package identity.
type DID ¶
DID stores the identity address of the user
func BytesToDIDs ¶
BytesToDIDs converts bytes to DIDs
func FromPointerDIDs ¶
FromPointerDIDs return pointer DIDs to value DIDs
func NewDIDFromBytes ¶
NewDIDFromBytes returns a DID based on a bytes input
func NewDIDFromString ¶
NewDIDFromString returns a DID based on a hex string
func RemoveDuplicateDIDs ¶
RemoveDuplicateDIDs removes duplicate DIDs
func StringsToDIDs ¶
StringsToDIDs converts hex strings to DIDs.
func (DID) MarshalJSON ¶
MarshalJSON marshals DID to json bytes.
func (*DID) UnmarshalJSON ¶
UnmarshalJSON loads json bytes to DID
type Factory ¶
type Factory interface { CreateIdentity(ethAccount string, keys []Key) (transaction *types.Transaction, err error) IdentityExists(did DID) (exists bool, err error) NextIdentityAddress() (DID, error) }
Factory for identity factory contract interface
type Key ¶ added in v1.0.0
type Key interface { GetKey() [32]byte GetPurpose() *big.Int GetRevokedAt() uint32 GetType() *big.Int }
Key defines a single ERC725 identity key
func ConvertAccountKeysToKeyDID ¶ added in v1.3.0
ConvertAccountKeysToKeyDID converts config keys to identity keys
type KeyResponse ¶
KeyResponse contains the needed fields of the GetKey response
type Purpose ¶
Purpose contains the different representation of purpose along the code
var ( // KeyPurposeManagement purpose stores the management key to interact with the ERC725 identity contract KeyPurposeManagement Purpose // KeyPurposeAction purpose stores the action key to interact with the ERC725 identity contract KeyPurposeAction Purpose // KeyPurposeP2PDiscovery purpose stores the action key to interact with the ERC725 identity contract KeyPurposeP2PDiscovery Purpose // KeyPurposeSigning purpose stores the action key to interact with the ERC725 identity contract KeyPurposeSigning Purpose )
func GetPurposeByName ¶
GetPurposeByName retrieves the Purpose by name
type Service ¶ added in v1.0.0
type Service interface { // AddKey adds a key to identity contract AddKey(ctx context.Context, key Key) error // GetKey return a key from the identity contract GetKey(did DID, key [32]byte) (*KeyResponse, error) // ExecuteAsync creates the abi encoding and calls the execute method on the identity contract ExecuteAsync( ctx context.Context, to common.Address, contractAbi, methodName string, args ...interface{}) (transaction *types. Transaction, err error) // AddMultiPurposeKey adds a key with multiple purposes AddMultiPurposeKey(context context.Context, key [32]byte, purposes []*big.Int, keyType *big.Int) error // RevokeKey revokes an existing key in the smart contract RevokeKey(ctx context.Context, key [32]byte) error // GetClientP2PURL returns the p2p url associated with the did GetClientP2PURL(did DID) (string, error) // Exists checks if an identity contract exists Exists(ctx context.Context, did DID) error // ValidateKey checks if a given key is valid for the given centrifugeID. ValidateKey(ctx context.Context, did DID, key []byte, purpose *big.Int, at *time.Time) error // ValidateSignature checks if signature is valid for given identity ValidateSignature(did DID, pubKey []byte, signature []byte, message []byte, timestamp time.Time) error // CurrentP2PKey retrieves the last P2P key stored in the identity CurrentP2PKey(did DID) (ret string, err error) // GetClientsP2PURLs returns p2p urls associated with each centIDs // will error out at first failure GetClientsP2PURLs(dids []*DID) ([]string, error) // GetKeysByPurpose returns keys grouped by purpose from the identity contract. GetKeysByPurpose(did DID, purpose *big.Int) ([]Key, error) }
Service interface contains the methods to interact with the identity contract