| Crates.io | mln-did |
| lib.rs | mln-did |
| version | 3.4.0 |
| created_at | 2023-05-23 09:05:23.986547+00 |
| updated_at | 2023-12-18 00:45:00.627513+00 |
| description | Derived/adapted from sol-did of Martin Riedel |
| homepage | https://www.solarti.top/ |
| repository | https://github.com/miracle-land/mln-did |
| max_upload_size | |
| id | 871823 |
| size | 74,888 |
did:mln ProgramThe anchor-based program of did:mln on Miraland.
Any Miraland public key can be a DID. This means that if you have a public key abc, then that key
corresponds to the decentralized identifier did:mln:abc.
This DID is called a generative DID, because it is generated from a public key, and has no other information associated with it.
Generative DIDs have one authority, which is the public key itself (abc in this case).
In order to add more authorities, or any other information to the DID, it must be initialised on chain,
using the initialize instruction.
Once a DID is initialized, other keys can be added to it using the add_verification_method instruction.
The information for a DID is stored on a DID Account, a PDA that is derived from the DID identifier.
In order to derive the PDA for any DID, the following function is used:
use mln_did::integrations::derive_did_account;
let (did_account, bump) = derive_did_account(key.to_bytes())
Where key is the identifier of the DID (abc in the above case)
In order to reduce the amount of calculations that are needed to derive the DID account,
you can pass the bump value as a parameter:
use mln_did::integrations::derive_did_account_with_bump;
let did_account = derive_did_account_with_bump(key.to_bytes(), bump)?;
Note, in this case, the function returns a Result, in case the bump value is incorrect.
In order to use DIDs in your program, add the DID account to your instruction accounts list.
The DID account is the that stores the DID information. Note: this can be generative (see above).
To check if a key is an authority of a DID, use the is_authority instruction.
use mln_did::integrations::is_authority;
let signer_owns_did = is_authority(
&did_account,
None,
&[],
&signer.to_bytes(),
None,
None
);
This function works in the generative and non-generative case. In the generative case, the did_account must be owned by the system program.
One DID can be a controller of another DID.
If a key a is an authority on did:mln:abc, and did:mln:abc is a controller of did:mln:def
then the following is_authority relationship is true:
use mln_did::integrations::is_authority;
let signer_owns_did = is_authority(
&abc_account,
None,
&[(def_account_info, def)],
&abc.to_bytes(),
None,
None
);
initializeArguments:
u32Accounts:
isMutisSigner, isMutisSigner, isMutresizeArguments:
u32Option<Secp256k1RawSignature>Accounts:
isMutisSignerisSigner, isMutcloseArguments:
Option<Secp256k1RawSignature>Accounts:
isMutisSignerisMutadd_verification_methodArguments:
VerificationMethodOption<Secp256k1RawSignature>Accounts:
isMutisSignerremove_verification_methodArguments:
stringOption<Secp256k1RawSignature>Accounts:
isMutisSigneradd_serviceArguments:
ServiceboolOption<Secp256k1RawSignature>Accounts:
isMutisSignerremove_serviceArguments:
stringOption<Secp256k1RawSignature>Accounts:
isMutisSignerset_vm_flagsArguments:
UpdateFlagsVerificationMethodOption<Secp256k1RawSignature>Accounts:
isMutisSignerset_controllersArguments:
SetControllersArgOption<Secp256k1RawSignature>Accounts:
isMutisSignerupdateArguments:
UpdateArgOption<Secp256k1RawSignature>Accounts:
isMutisSignermigrateArguments:
Accounts:
isMutisSigner, isMutdid:mln program on APR