Hedera DID module¶
This module provides API for Hedera DID management.
Based on latest Hedera DID spec.
DID resolver¶
HederaDidResolver
¶
Hedera DID Resolver implementation.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
client
|
Client
|
Hedera Client |
required |
cache_instance
|
Cache[str, TimestampedRecord[DidDocument]] | None
|
Custom cache instance. If not provided, in-memory cache is used |
None
|
Source code in hiero_did_sdk_python/did/hedera_did_resolver.py
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 |
|
resolve(did)
async
¶
Resolve DID document by identifier.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
did
|
str
|
DID identifier to resolve |
required |
Returns:
Name | Type | Description |
---|---|---|
object |
DIDResolutionResult
|
DID resolution result |
Source code in hiero_did_sdk_python/did/hedera_did_resolver.py
DidResolutionError
¶
Bases: StrEnum
Enum for DID resolution errors
Source code in hiero_did_sdk_python/did/hedera_did_resolver.py
INVALID_DID = 'invalidDid'
class-attribute
instance-attribute
¶
The resolver is misconfigured or is being asked to resolve a DID anchored on an unknown network
NOT_FOUND = 'notFound'
class-attribute
instance-attribute
¶
The resolver does not know how to resolve the given DID. Most likely it is not a did:hedera
.
UNKNOWN_NETWORK = 'unknownNetwork'
class-attribute
instance-attribute
¶
Unknown resolution error
DID management API¶
HederaDid
¶
Class representing Hedera DID instance, provides access to DID management API.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
client
|
Client
|
Hedera Client |
required |
identifier
|
str | None
|
DID identifier (for existing DIDs) |
None
|
private_key_der
|
str | None
|
DID Owner (controller) private key encoded in DER format. Can be empty for read-only access |
None
|
Source code in hiero_did_sdk_python/did/hedera_did.py
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 |
|
add_service(id_, service_type, service_endpoint)
async
¶
Add Service to DID document
Parameters:
Name | Type | Description | Default |
---|---|---|---|
id_
|
str
|
Service ID to create |
required |
service_type
|
DidServiceType
|
DID service type |
required |
service_endpoint
|
str
|
Service endpoint |
required |
Source code in hiero_did_sdk_python/did/hedera_did.py
add_verification_method(id_, controller, public_key_der, type_)
async
¶
Add verification method to DID document
Parameters:
Name | Type | Description | Default |
---|---|---|---|
id_
|
str
|
Verification method ID to create |
required |
controller
|
str
|
Verification method controller ID |
required |
public_key_der
|
str
|
Verification method public key encoded in DER format |
required |
type_
|
SupportedKeyType
|
Verification method key type |
required |
Source code in hiero_did_sdk_python/did/hedera_did.py
add_verification_relationship(id_, controller, public_key_der, relationship_type, type_)
async
¶
Add verification relationship to DID document
Parameters:
Name | Type | Description | Default |
---|---|---|---|
id_
|
str
|
Verification relationship ID to create |
required |
controller
|
str
|
Verification relationship controller ID |
required |
public_key_der
|
str
|
Verification relationship public key encoded in DER format |
required |
relationship_type
|
VerificationRelationshipType
|
Verification relationship type |
required |
type_
|
SupportedKeyType
|
Verification relationship key type |
required |
Source code in hiero_did_sdk_python/did/hedera_did.py
change_owner(controller, new_private_key_der)
async
¶
Change DID Owner (controller).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
controller
|
str
|
Identifier of new DID Owner |
required |
new_private_key_der
|
str
|
New DID Owner private key encoded in DER format |
required |
Source code in hiero_did_sdk_python/did/hedera_did.py
delete()
async
¶
Delete (deactivate) registered DID instance.
register()
async
¶
Register (create) DID instance in Hedera network
Source code in hiero_did_sdk_python/did/hedera_did.py
resolve()
async
¶
Resolve DID document for registered instance.
Returns:
Name | Type | Description |
---|---|---|
object |
DidDocument
|
DID document |
Source code in hiero_did_sdk_python/did/hedera_did.py
revoke_service(id_)
async
¶
Revoke existing DID document service
Parameters:
Name | Type | Description | Default |
---|---|---|---|
id_
|
str
|
Service ID to revoke |
required |
Source code in hiero_did_sdk_python/did/hedera_did.py
revoke_verification_method(id_)
async
¶
Revoke existing DID document verification method
Parameters:
Name | Type | Description | Default |
---|---|---|---|
id_
|
str
|
Verification method ID to revoke |
required |
Source code in hiero_did_sdk_python/did/hedera_did.py
revoke_verification_relationship(id_, relationship_type)
async
¶
Revoke existing DID document verification relationship
Parameters:
Name | Type | Description | Default |
---|---|---|---|
id_
|
str
|
Verification relationship ID to revoke |
required |
relationship_type
|
VerificationRelationshipType
|
Verification relationship type |
required |
Source code in hiero_did_sdk_python/did/hedera_did.py
update_service(id_, service_type, service_endpoint)
async
¶
Update existing DID document service
Parameters:
Name | Type | Description | Default |
---|---|---|---|
id_
|
str
|
Service ID to update |
required |
service_type
|
DidServiceType
|
DID service type |
required |
service_endpoint
|
str
|
Service endpoint |
required |
Source code in hiero_did_sdk_python/did/hedera_did.py
update_verification_method(id_, controller, public_key_der, type_)
async
¶
Update existing DID document verification method
Parameters:
Name | Type | Description | Default |
---|---|---|---|
id_
|
str
|
Verification method ID to update |
required |
controller
|
str
|
Verification method controller ID |
required |
public_key_der
|
str
|
Verification method public key encoded in DER format |
required |
type_
|
SupportedKeyType
|
Verification method key type |
required |
Source code in hiero_did_sdk_python/did/hedera_did.py
update_verification_relationship(id_, controller, public_key_der, relationship_type, type_)
async
¶
Update existing DID document verification relationship
Parameters:
Name | Type | Description | Default |
---|---|---|---|
id_
|
str
|
Verification relationship ID to update |
required |
controller
|
str
|
Verification relationship controller ID |
required |
public_key_der
|
str
|
Verification relationship public key encoded in DER format |
required |
relationship_type
|
VerificationRelationshipType
|
Verification relationship type |
required |
type_
|
SupportedKeyType
|
Verification relationship key type |
required |
Source code in hiero_did_sdk_python/did/hedera_did.py
Models and types¶
DidDocument
¶
Bases: Serializable
DID document representation
Attributes:
Name | Type | Description |
---|---|---|
created |
float | None
|
Creation timestamp |
updated |
float | None
|
Last update timestamp |
version_id |
str | None
|
DID document version ID (equals to last update timestamp) |
deactivated |
bool
|
DID document deactivation status |
controller |
dict | None
|
Dictionary representing DID document controller info |
services |
dict
|
DID document services dictionary |
verification_methods |
dict
|
DID document verification methods dictionary |
verification_methods |
dict
|
DID document verification relationships dictionary |
Source code in hiero_did_sdk_python/did/did_document.py
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 |
|
process_messages(messages)
async
¶
Process HCS DID messages - apply DID document state changes according to events.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
messages
|
list[HcsDidMessage]
|
HCS DID messages to process |
required |
Source code in hiero_did_sdk_python/did/did_document.py
DidErrorCode
¶
Bases: StrEnum
Enum for DID-related error codes
Source code in hiero_did_sdk_python/did/did_error.py
GENERIC = 'generic'
class-attribute
instance-attribute
¶
Invalid DID identifier string. Can be caused by non-Hedera DID method prefix, invalid or missing Topic ID and generally incorrect format
INVALID_DID_STRING = 'invalid_did_string'
class-attribute
instance-attribute
¶
Invalid Hedera network specified in DID identifier
INVALID_NETWORK = 'invalid_network'
class-attribute
instance-attribute
¶
Specified DID is not found
DidException
¶
Bases: Exception
Class for DID-related exceptions
Parameters:
Name | Type | Description | Default |
---|---|---|---|
message
|
str
|
Error message |
required |
code
|
DidErrorCode
|
DID Error code |
GENERIC
|