- Struct
DID - Struct
VerificationMethodID - Struct
ServiceID - Struct
VerificationMethod - Struct
Service - Resource
DIDDocument - Resource
DIDRegistry - Struct
DIDCreatedEvent - Struct
VerificationMethodAddedEvent - Struct
VerificationMethodRemovedEvent - Struct
VerificationRelationshipModifiedEvent - Struct
ServiceAddedEvent - Struct
ServiceUpdatedEvent - Struct
ServiceRemovedEvent - Constants
- Function
verification_relationship_authentication - Function
verification_relationship_assertion_method - Function
verification_relationship_capability_invocation - Function
verification_relationship_capability_delegation - Function
verification_relationship_key_agreement - Function
verification_method_type_ed25519 - Function
verification_method_type_secp256k1 - Function
verification_method_type_secp256r1 - Function
verify_signature_by_type - Function
genesis_init - Function
init_did_registry - Function
create_did_object_for_self_entry - Function
create_did_object_for_self - Function
create_did_object_for_self_with_custom_scopes_entry - Function
create_did_object_for_self_with_custom_scopes - Function
create_did_object_via_cadop_with_did_key_entry - Function
create_did_object_via_cadop_with_did_key_and_scopes_entry - Function
create_did_object_via_cadop_with_did_key - Function
create_did_object_via_cadop_with_did_key_and_scopes - Function
create_did_object_via_cadop_with_controller_and_scopes_entry - Function
create_did_object_via_cadop_with_controller_and_scopes - Function
add_verification_method_entry - Function
add_verification_method_with_scopes_entry - Function
remove_verification_method_entry - Function
add_to_verification_relationship_entry - Function
add_to_verification_relationship_with_scope_entry - Function
remove_from_verification_relationship_entry - Function
add_service_entry - Function
add_service_with_properties_entry - Function
update_service_entry - Function
remove_service_entry - Function
exists_did_document_by_identifier - Function
exists_did_for_address - Function
get_dids_by_controller - Function
get_dids_by_controller_string - Function
has_verification_relationship_in_doc - Function
is_verification_method_valid_in_doc - Function
format_did - Function
format_verification_method_id - Function
format_service_id - Function
new_did_from_parts - Function
new_rooch_did_by_address - Function
parse_did_string - Function
get_did_identifier_string - Function
get_did_method - Function
get_did_document - Function
get_did_document_by_address - Function
get_did_document_by_object_id - Function
doc_id - Function
doc_controllers - Function
doc_verification_methods - Function
doc_verification_method - Function
verification_method_id - Function
verification_method_type - Function
verification_method_controller - Function
verification_method_public_key_multibase - Function
doc_authentication_methods - Function
doc_assertion_methods - Function
doc_capability_invocation_methods - Function
doc_capability_delegation_methods - Function
doc_key_agreement_methods - Function
doc_services - Function
doc_service - Function
service_id - Function
service_type - Function
service_endpoint - Function
service_properties - Function
doc_also_known_as - Function
get_created_timestamp_by_object_id - Function
get_updated_timestamp_by_object_id - Function
get_did_address - Function
find_verification_method_by_session_key
use 0x1::option;
use 0x1::signer;
use 0x1::string;
use 0x1::vector;
use 0x2::account;
use 0x2::address;
use 0x2::event;
use 0x2::multibase_codec;
use 0x2::multibase_key;
use 0x2::object;
use 0x2::simple_map;
use 0x2::table;
use 0x3::auth_validator;
use 0x3::bitcoin_address;
use 0x3::ecdsa_k1;
use 0x3::ecdsa_r1;
use 0x3::ed25519;
use 0x3::session_key;
DID identifier type
struct DID has copy, drop, store
Verification method ID
struct VerificationMethodID has copy, drop, store
Service ID
struct ServiceID has copy, drop, store
Verification method
struct VerificationMethod has copy, drop, store
Service definition
struct Service has copy, drop, store
DID Document containing all DID information. This is the data part of an Object.
The DIDDocuemnt only has key ability, no store, so the user can not transfer it to other accounts.
struct DIDDocument has key
Registry to store mappings. This is a Named Object.
struct DIDRegistry has key
Event emitted when a new DID document is created
#[event]
struct DIDCreatedEvent has copy, drop, store
Event emitted when a verification method is added to a DID document
#[event]
struct VerificationMethodAddedEvent has copy, drop, store
Event emitted when a verification method is removed from a DID document
#[event]
struct VerificationMethodRemovedEvent has copy, drop, store
Event emitted when a verification relationship is modified
#[event]
struct VerificationRelationshipModifiedEvent has copy, drop, store
Event emitted when a service is added to a DID document
#[event]
struct ServiceAddedEvent has copy, drop, store
Event emitted when a service is updated in a DID document
#[event]
struct ServiceUpdatedEvent has copy, drop, store
Event emitted when a service is removed from a DID document
#[event]
struct ServiceRemovedEvent has copy, drop, store
The format of the publicKeyMultibase string is invalid or cannot be parsed
const ErrorInvalidPublicKeyMultibaseFormat: u64 = 20;
Invalid signature (can be reused or made more specific)
const ErrorInvalidSignature: u64 = 11;
Associated AccountCap not found in DIDDocument when expected
const ErrorAccountCapNotFound: u64 = 14;
did:bitcoin address does not match provided public key
const ErrorControllerBitcoinAddressMismatch: u64 = 33;
Controller DID method is not supported
const ErrorControllerDIDMethodNotSupported: u64 = 31;
Missing user VM info for non did:key controller
const ErrorControllerMissingUserVMInfo: u64 = 32;
Permission denied based on controller check
const ErrorControllerPermissionDenied: u64 = 15;
Custodian DID document does not exist
const ErrorCustodianDIDNotFound: u64 = 30;
Custodian does not have CADOP service
const ErrorCustodianDoesNotHaveCADOPService: u64 = 29;
DID already exists (e.g., identifier already registered)
const ErrorDIDAlreadyExists: u64 = 2;
DID document does not exist (legacy or general not found)
const ErrorDIDDocumentNotExist: u64 = 1;
For did:key controllers, the initial verification method public key must match the key in the DID identifier
const ErrorDIDKeyControllerPublicKeyMismatch: u64 = 23;
DID Object not found for the given identifier
const ErrorDIDObjectNotFound: u64 = 13;
DIDRegistry is already initialized
const ErrorDIDRegistryAlreadyInitialized: u64 = 12;
Fragment string is too long
const ErrorFragmentTooLong: u64 = 41;
Verification method has insufficient permission for the requested operation
const ErrorInsufficientPermission: u64 = 26;
Generic invalid argument
const ErrorInvalidArgument: u64 = 17;
Invalid DID string format (should be "did:method:identifier")
const ErrorInvalidDIDStringFormat: u64 = 22;
Invalid VM type for the specified controller
const ErrorInvalidVMTypeForController: u64 = 34;
Invalid verification relationship
const ErrorInvalidVerificationRelationship: u64 = 9;
Multiple did:key controllers are not allowed during initial DID creation with a did:key controller
const ErrorMultipleDIDKeyControllersNotAllowed: u64 = 24;
No controllers specified during DID creation or update
const ErrorNoControllersSpecified: u64 = 18;
No session key found in transaction context - all DID operations must use session keys
const ErrorNoSessionKeyInContext: u64 = 28;
Mismatch in length between property keys and values for a service
const ErrorPropertyKeysValuesLengthMismatch: u64 = 16;
Service already exists
const ErrorServiceAlreadyExists: u64 = 7;
Service not found
const ErrorServiceNotFound: u64 = 6;
Session key not found in DID document's authentication methods
const ErrorSessionKeyNotFound: u64 = 25;
Failed to register key with the Rooch session key module
const ErrorSessionKeyRegistrationFailed: u64 = 21;
The signer is not the DID's associated account
const ErrorSignerNotDIDAccount: u64 = 27;
String field is too long
const ErrorStringTooLong: u64 = 42;
Exceeded maximum number of also known as aliases
const ErrorTooManyAlsoKnownAs: u64 = 39;
Exceeded maximum number of controllers
const ErrorTooManyControllers: u64 = 40;
Exceeded maximum number of verification methods allowed in a relationship
const ErrorTooManyRelationshipMethods: u64 = 36;
Exceeded maximum number of properties allowed per service
const ErrorTooManyServiceProperties: u64 = 38;
Exceeded maximum number of services allowed in a DID document
const ErrorTooManyServices: u64 = 37;
Exceeded maximum number of verification methods allowed in a DID document
const ErrorTooManyVerificationMethods: u64 = 35;
Unauthorized operation (generic, consider specific ErrorControllerPermissionDenied)
const ErrorUnauthorized: u64 = 3;
Verification method type is not supported for Rooch session key linkage (e.g., not Ed25519)
const ErrorUnsupportedAuthKeyTypeForSessionKey: u64 = 19;
Verification method already exists
const ErrorVerificationMethodAlreadyExists: u64 = 5;
Verification method has expired
const ErrorVerificationMethodExpired: u64 = 8;
Verification method not found
const ErrorVerificationMethodNotFound: u64 = 4;
Verification method not in the relationship
const ErrorVerificationMethodNotInRelationship: u64 = 10;
const MAX_ALSO_KNOWN_AS_PER_DOCUMENT: u64 = 16;
const MAX_CONTROLLERS_PER_DOCUMENT: u64 = 8;
const MAX_FRAGMENT_LENGTH: u64 = 128;
const MAX_METHODS_PER_RELATIONSHIP: u64 = 64;
const MAX_PROPERTIES_PER_SERVICE: u64 = 16;
const MAX_SERVICES_PER_DOCUMENT: u64 = 32;
const MAX_STRING_LENGTH: u64 = 512;
const MAX_VERIFICATION_METHODS_PER_DOCUMENT: u64 = 64;
const VERIFICATION_METHOD_TYPE_ED25519: vector<u8> = [69, 100, 50, 53, 53, 49, 57, 86, 101, 114, 105, 102, 105, 99, 97, 116, 105, 111, 110, 75, 101, 121, 50, 48, 50, 48];
const VERIFICATION_METHOD_TYPE_SECP256K1: vector<u8> = [69, 99, 100, 115, 97, 83, 101, 99, 112, 50, 53, 54, 107, 49, 86, 101, 114, 105, 102, 105, 99, 97, 116, 105, 111, 110, 75, 101, 121, 50, 48, 49, 57];
const VERIFICATION_METHOD_TYPE_SECP256R1: vector<u8> = [69, 99, 100, 115, 97, 83, 101, 99, 112, 50, 53, 54, 114, 49, 86, 101, 114, 105, 102, 105, 99, 97, 116, 105, 111, 110, 75, 101, 121, 50, 48, 49, 57];
const VERIFICATION_RELATIONSHIP_ASSERTION_METHOD: u8 = 1;
const VERIFICATION_RELATIONSHIP_AUTHENTICATION: u8 = 0;
const VERIFICATION_RELATIONSHIP_CAPABILITY_DELEGATION: u8 = 3;
const VERIFICATION_RELATIONSHIP_CAPABILITY_INVOCATION: u8 = 2;
const VERIFICATION_RELATIONSHIP_KEY_AGREEMENT: u8 = 4;
Get verification relationship constant for authentication
public fun verification_relationship_authentication(): u8
Get verification relationship constant for assertion method
public fun verification_relationship_assertion_method(): u8
Get verification relationship constant for capability invocation
public fun verification_relationship_capability_invocation(): u8
Get verification relationship constant for capability delegation
public fun verification_relationship_capability_delegation(): u8
Get verification relationship constant for key agreement
public fun verification_relationship_key_agreement(): u8
Get verification method type constant for Ed25519
public fun verification_method_type_ed25519(): string::String
Get verification method type constant for Secp256k1
public fun verification_method_type_secp256k1(): string::String
Get verification method type constant for Secp256r1
public fun verification_method_type_secp256r1(): string::String
Verify a signature using the specified verification method type and public key. This is a generic signature verification function that can be used across different modules.
public fun verify_signature_by_type(message: vector<u8>, signature: vector<u8>, public_key_multibase: &string::String, method_type: &string::String): bool
public(friend) fun genesis_init()
Initialize the DID system Any account can call this function to initialize the DID system
public entry fun init_did_registry()
Create a DID for oneself using account key only. This function validates that the provided public key corresponds to the creator's account. Currently only supports Secp256k1 keys.
public entry fun create_did_object_for_self_entry(creator_account_signer: &signer, account_public_key_multibase: string::String)
Internal function for self DID creation. Validates that the provided public key matches the creator's account address.
public fun create_did_object_for_self(creator_account_signer: &signer, account_public_key_multibase: string::String): object::ObjectID
Create a DID for oneself with custom session key scopes
public entry fun create_did_object_for_self_with_custom_scopes_entry(creator_account_signer: &signer, account_public_key_multibase: string::String, session_scope_strings: vector<string::String>)
Internal function for self DID creation with custom scopes
public fun create_did_object_for_self_with_custom_scopes(creator_account_signer: &signer, account_public_key_multibase: string::String, custom_session_scope_strings: option::Option<vector<string::String>>): object::ObjectID
Create a DID via CADOP (Custodian-Assisted DID Onboarding Protocol) using did:key. The custodian assists in DID creation but the user retains control. Each user gets a unique service key from the custodian. The user's public key is extracted from their did:key string. Backward-compatible non-scope entry; delegates to scoped version with default scopes.
public entry fun create_did_object_via_cadop_with_did_key_entry(custodian_signer: &signer, user_did_key_string: string::String, custodian_service_pk_multibase: string::String, custodian_service_vm_type: string::String)
Create a DID Object via CADOP with did:key and custom session key scopes This function allows custodians to create DID objects with customized scope permissions
custodian_signer- Custodian's Rooch account, pays gasuser_did_key_string- User's did:key string (e.g., "did:key:zABC...")custodian_service_pk_multibase- Custodian's service public key for this usercustodian_service_vm_type- Custodian service VM type (Ed25519 or Secp256k1)custom_scope_strings- Vector of custom scope strings in format "address::module::function"
public entry fun create_did_object_via_cadop_with_did_key_and_scopes_entry(custodian_signer: &signer, user_did_key_string: string::String, custodian_service_pk_multibase: string::String, custodian_service_vm_type: string::String, custom_scope_strings: vector<string::String>)
Internal function for CADOP DID creation with did:key. Returns the ObjectID of the created DID document for testing and verification. Backward-compatible non-scope internal; delegates to scoped version with default scopes.
public fun create_did_object_via_cadop_with_did_key(custodian_signer: &signer, user_did_key_string: string::String, custodian_service_pk_multibase: string::String, custodian_service_vm_type: string::String): object::ObjectID
Internal function for CADOP DID creation with did:key and custom scopes. Returns the ObjectID of the created DID document for testing and verification.
custodian_signer- Custodian's Rooch account, pays gasuser_did_key_string- User's did:key string (e.g., "did:key:zABC...")custodian_service_pk_multibase- Custodian's service public key for this usercustodian_service_vm_type- Custodian service VM type (Ed25519 or Secp256k1)custom_scope_strings- Optional vector of custom scope strings in format "address::module::function"
public fun create_did_object_via_cadop_with_did_key_and_scopes(custodian_signer: &signer, user_did_key_string: string::String, custodian_service_pk_multibase: string::String, custodian_service_vm_type: string::String, custom_scope_strings: option::Option<vector<string::String>>): object::ObjectID
New entry: Create a DID Object via CADOP with arbitrary controller DID and custom scopes. Supports did:key and did:bitcoin (future did:ethereum can be added similarly).
public entry fun create_did_object_via_cadop_with_controller_and_scopes_entry(custodian_signer: &signer, controller_did_string: string::String, user_vm_pk_multibase: string::String, user_vm_type: string::String, custodian_service_pk_multibase: string::String, custodian_service_vm_type: string::String, custom_scope_strings: vector<string::String>)
Internal: controller-based CADOP DID creation with custom scopes. Controller can be did:key (auto-extract VM) or did:bitcoin (require VM pk/type and verify).
public fun create_did_object_via_cadop_with_controller_and_scopes(custodian_signer: &signer, controller_did_string: string::String, user_vm_pk_multibase_opt: option::Option<string::String>, user_vm_type_opt: option::Option<string::String>, custodian_service_pk_multibase: string::String, custodian_service_vm_type: string::String, custom_scope_strings: option::Option<vector<string::String>>): object::ObjectID
public entry fun add_verification_method_entry(did_signer: &signer, fragment: string::String, method_type: string::String, public_key_multibase: string::String, verification_relationships: vector<u8>)
public entry fun add_verification_method_with_scopes_entry(did_signer: &signer, fragment: string::String, method_type: string::String, public_key_multibase: string::String, verification_relationships: vector<u8>, custom_session_scope: vector<string::String>)
public entry fun remove_verification_method_entry(did_signer: &signer, fragment: string::String)
public entry fun add_to_verification_relationship_entry(did_signer: &signer, fragment: string::String, relationship_type: u8)
public entry fun add_to_verification_relationship_with_scope_entry(did_signer: &signer, fragment: string::String, relationship_type: u8, custom_session_scope: vector<string::String>)
public entry fun remove_from_verification_relationship_entry(did_signer: &signer, fragment: string::String, relationship_type: u8)
public entry fun add_service_entry(did_signer: &signer, fragment: string::String, service_type: string::String, service_endpoint: string::String)
public entry fun add_service_with_properties_entry(did_signer: &signer, fragment: string::String, service_type: string::String, service_endpoint: string::String, property_keys: vector<string::String>, property_values: vector<string::String>)
public entry fun update_service_entry(did_signer: &signer, fragment: string::String, new_service_type: string::String, new_service_endpoint: string::String, new_property_keys: vector<string::String>, new_property_values: vector<string::String>)
public entry fun remove_service_entry(did_signer: &signer, fragment: string::String)
public fun exists_did_document_by_identifier(identifier_str: string::String): bool
public fun exists_did_for_address(addr: address): bool
Get all DID ObjectIDs controlled by a specific controller DID
public fun get_dids_by_controller(controller_did: did::DID): vector<string::String>
public fun get_dids_by_controller_string(controller_did_str: string::String): vector<string::String>
public fun has_verification_relationship_in_doc(did_document_data: &did::DIDDocument, fragment: &string::String, relationship_type: u8): bool
public fun is_verification_method_valid_in_doc(did_document_data: &did::DIDDocument, fragment: &string::String): bool
public fun format_did(did: &did::DID): string::String
public fun format_verification_method_id(id: &did::VerificationMethodID): string::String
public fun format_service_id(id: &did::ServiceID): string::String
Create a DID struct from method and identifier parts This function only constructs a DID struct, it does NOT create a DID object on-chain
public fun new_did_from_parts(method: string::String, identifier: string::String): did::DID
Create a Rooch DID struct from an address This function only constructs a DID struct, it does NOT create a DID object on-chain
public fun new_rooch_did_by_address(addr: address): did::DID
Parse a DID string in the format "did:method:identifier" into a DID struct
public fun parse_did_string(did_string: &string::String): did::DID
Get the identifier from a DID
public fun get_did_identifier_string(did: &did::DID): string::String
Get the method from a DID
public fun get_did_method(did: &did::DID): string::String
public fun get_did_document(did_str: string::String): &did::DIDDocument
Get DIDDocument by address
public fun get_did_document_by_address(addr: address): &did::DIDDocument
Get DIDDocument by ObjectID
public fun get_did_document_by_object_id(object_id: object::ObjectID): &did::DIDDocument
Get id from DIDDocument
public fun doc_id(did_doc: &did::DIDDocument): &did::DID
Get controllers from DIDDocument
public fun doc_controllers(did_doc: &did::DIDDocument): &vector<did::DID>
Get verification methods from DIDDocument
public fun doc_verification_methods(did_doc: &did::DIDDocument): &simple_map::SimpleMap<string::String, did::VerificationMethod>
Get verification method by fragment
public fun doc_verification_method(did_doc: &did::DIDDocument, fragment: &string::String): option::Option<did::VerificationMethod>
public fun verification_method_id(vm: &did::VerificationMethod): &did::VerificationMethodID
public fun verification_method_type(vm: &did::VerificationMethod): &string::String
public fun verification_method_controller(vm: &did::VerificationMethod): &did::DID
public fun verification_method_public_key_multibase(vm: &did::VerificationMethod): &string::String
Get authentication methods from DIDDocument
public fun doc_authentication_methods(did_doc: &did::DIDDocument): &vector<string::String>
Get assertion methods from DIDDocument
public fun doc_assertion_methods(did_doc: &did::DIDDocument): &vector<string::String>
Get capability invocation methods from DIDDocument
public fun doc_capability_invocation_methods(did_doc: &did::DIDDocument): &vector<string::String>
Get capability delegation methods from DIDDocument
public fun doc_capability_delegation_methods(did_doc: &did::DIDDocument): &vector<string::String>
Get key agreement methods from DIDDocument
public fun doc_key_agreement_methods(did_doc: &did::DIDDocument): &vector<string::String>
Get services from DIDDocument
public fun doc_services(did_doc: &did::DIDDocument): &simple_map::SimpleMap<string::String, did::Service>
Get service by fragment
public fun doc_service(did_doc: &did::DIDDocument, fragment: &string::String): option::Option<did::Service>
public fun service_id(service: &did::Service): &did::ServiceID
public fun service_type(service: &did::Service): &string::String
public fun service_endpoint(service: &did::Service): &string::String
public fun service_properties(service: &did::Service): &simple_map::SimpleMap<string::String, string::String>
Get also known as from DIDDocument
public fun doc_also_known_as(did_doc: &did::DIDDocument): &vector<string::String>
Get created timestamp from Object system This accesses the Object's metadata created_at timestamp
public fun get_created_timestamp_by_object_id(object_id: object::ObjectID): u64
Get updated timestamp from Object system This accesses the Object's metadata updated_at timestamp
public fun get_updated_timestamp_by_object_id(object_id: object::ObjectID): u64
public fun get_did_address(did_doc: &did::DIDDocument): address
Find the verification method fragment that corresponds to the given session key Returns None if no matching verification method is found
public fun find_verification_method_by_session_key(did_document_data: &did::DIDDocument, session_key: &vector<u8>): option::Option<string::String>