Check README-SS58 for using ss58 based did
This Library is dart version of infra-did-js
-
Infra DID Method Spec
-
Infra DID Registry Smart Contract on InfraBlockchain
-
Infra DID Resolver (DIF javascript universal resolver compatible)
Feature provided by infra-did-dart Library :
- Infra DID Creation
- update DID attributes (service endpoint)
- update Pub-Key DID owner key
- revoke Pub-Key DID
- add/update/remove trusted Pub-Key DID & Account DID
- get trusted Pub-Key DID & Account DID
- VC/VP creation/verification
git clone https://github.com/InfraBlockchain/infra-did-dart
cd infra-did-dart
git lfs install
git lfs pull
- Using pub:
dart pub add infra_did_dart # this not work now cause we are not published yet
dart pub add infra_did_dart --git-url=https://github.com/InfraBlockchain/infra-did-dart.git # you can add with git url
currently secp256k1 curve is supported
InfraKey a = InfraKey();
a.generateDid("01");
print(a.toJson());
/*
{
"privateKey": "PVT_K1_tJNUdraxcUjn2rACZSWLFbUcj3DeVjDC5ZjG8Q3yztTZZg3N7",
"publicKey": "PUB_K1_5JXbkkMg4o2P9Zm7ZuSkmb4zegbygvfYPMgXTxcTTyjBuDxRgs",
"did":
"did:infra:01:PUB_K1_5JXbkkMg4o2P9Zm7ZuSkmb4zegbygvfYPMgXTxcTTyjBuDxRgs"
};
*/
Set Pub-Key DID Attribute
var infra = InfraDID(
"did:infra:01:PUB_K1_6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5BoDq63",
"PVT_K1_2bfGi9rYsXQSXXTvJbDAPhHLQUojjaNLomdm3cEJ1XTzMqUt3V",
"fmapkumrotfc",
"http://localhost:8888",
"fmapkumrotfc",
"PVT_K1_2bfGi9rYsXQSXXTvJbDAPhHLQUojjaNLomdm3cEJ1XTzMqUt3V");
await infra.setAttributePubKeyDID("key", "value");
Remove Pub-Key DID Attribute
var infra = InfraDID(
"did:infra:01:PUB_K1_6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5BoDq63",
"PVT_K1_2bfGi9rYsXQSXXTvJbDAPhHLQUojjaNLomdm3cEJ1XTzMqUt3V",
"fmapkumrotfc",
"http://localhost:8888",
"fmapkumrotfc",
"PVT_K1_2bfGi9rYsXQSXXTvJbDAPhHLQUojjaNLomdm3cEJ1XTzMqUt3V");
await infra.revokePubKeyDID();
Clear Pub-Key DID chain data
var infra = InfraDID(
"did:infra:01:PUB_K1_6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5BoDq63",
"PVT_K1_2bfGi9rYsXQSXXTvJbDAPhHLQUojjaNLomdm3cEJ1XTzMqUt3V",
"fmapkumrotfc",
"http://localhost:8888",
"fmapkumrotfc",
"PVT_K1_2bfGi9rYsXQSXXTvJbDAPhHLQUojjaNLomdm3cEJ1XTzMqUt3V");
await infra.clearPubKeyDID();
Set Account-based DID Attribute
var infra = InfraDID(
"did:infra:01:PUB_K1_6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5BoDq63",
"PVT_K1_2bfGi9rYsXQSXXTvJbDAPhHLQUojjaNLomdm3cEJ1XTzMqUt3V",
"fmapkumrotfc",
"http://localhost:8888",
"fmapkumrotfc",
"PVT_K1_2bfGi9rYsXQSXXTvJbDAPhHLQUojjaNLomdm3cEJ1XTzMqUt3V");
await infra.setAttributeAccountDID(
"svc/MessagingService", "https://infradid.com/pk/3/mysvcr90");
Update Pub-Key DID owner key
var infra = InfraDID(
"did:infra:01:PUB_K1_6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5BoDq63",
"PVT_K1_2bfGi9rYsXQSXXTvJbDAPhHLQUojjaNLomdm3cEJ1XTzMqUt3V",
"fmapkumrotfc",
"http://localhost:8888",
"fmapkumrotfc",
"PVT_K1_2bfGi9rYsXQSXXTvJbDAPhHLQUojjaNLomdm3cEJ1XTzMqUt3V");
await infra.changeOwnerPubKeyDID(
"PUB_K1_6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5BoDq63");
var infra = InfraDID(
"did:infra:01:PUB_K1_6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5BoDq63",
"PVT_K1_2bfGi9rYsXQSXXTvJbDAPhHLQUojjaNLomdm3cEJ1XTzMqUt3V",
"fmapkumrotfc",
"http://localhost:8888",
"fmapkumrotfc",
"PVT_K1_2bfGi9rYsXQSXXTvJbDAPhHLQUojjaNLomdm3cEJ1XTzMqUt3V");
await infra.revokePubKeyDID();
var infra = InfraDID(
"did:infra:01:PUB_K1_6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5BoDq63",
"PVT_K1_2bfGi9rYsXQSXXTvJbDAPhHLQUojjaNLomdm3cEJ1XTzMqUt3V",
"fmapkumrotfc",
"http://localhost:8888",
"fmapkumrotfc",
"PVT_K1_2bfGi9rYsXQSXXTvJbDAPhHLQUojjaNLomdm3cEJ1XTzMqUt3V");
await infra.registerTrustedAccountDID("fmapkumrotfc", "eosio", "?");
var infra = InfraDID(
"did:infra:01:PUB_K1_6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5BoDq63",
"PVT_K1_2bfGi9rYsXQSXXTvJbDAPhHLQUojjaNLomdm3cEJ1XTzMqUt3V",
"fmapkumrotfc",
"http://localhost:8888",
"fmapkumrotfc",
"PVT_K1_2bfGi9rYsXQSXXTvJbDAPhHLQUojjaNLomdm3cEJ1XTzMqUt3V");
await infra.updateTrustedAccountDID("fmapkumrotfc", "eosio", "?");
var infra = InfraDID(
"did:infra:01:PUB_K1_6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5BoDq63",
"PVT_K1_2bfGi9rYsXQSXXTvJbDAPhHLQUojjaNLomdm3cEJ1XTzMqUt3V",
"fmapkumrotfc",
"http://localhost:8888",
"fmapkumrotfc",
"PVT_K1_2bfGi9rYsXQSXXTvJbDAPhHLQUojjaNLomdm3cEJ1XTzMqUt3V");
await infra.removeTrustedAccountDID("fmapkumrotfc", "eosio");
var infra = InfraDID(
"did:infra:01:PUB_K1_6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5BoDq63",
"PVT_K1_2bfGi9rYsXQSXXTvJbDAPhHLQUojjaNLomdm3cEJ1XTzMqUt3V",
"fmapkumrotfc",
"http://localhost:8888",
"fmapkumrotfc",
"PVT_K1_2bfGi9rYsXQSXXTvJbDAPhHLQUojjaNLomdm3cEJ1XTzMqUt3V");
await infra.getTrustedPubKeyDIDByAuthorizer("fmapkumrotfc");
var infra = InfraDID(
"did:infra:01:PUB_K1_6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5BoDq63",
"PVT_K1_2bfGi9rYsXQSXXTvJbDAPhHLQUojjaNLomdm3cEJ1XTzMqUt3V",
"fmapkumrotfc",
"http://localhost:8888",
"fmapkumrotfc",
"PVT_K1_2bfGi9rYsXQSXXTvJbDAPhHLQUojjaNLomdm3cEJ1XTzMqUt3V");
await infra.getTrustedPubKeyDIDByTarget(
"PUB_K1_6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5BoDq63");
var infra = InfraDID(
"did:infra:01:PUB_K1_6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5BoDq63",
"PVT_K1_2bfGi9rYsXQSXXTvJbDAPhHLQUojjaNLomdm3cEJ1XTzMqUt3V",
"fmapkumrotfc",
"http://localhost:8888",
"fmapkumrotfc",
"PVT_K1_2bfGi9rYsXQSXXTvJbDAPhHLQUojjaNLomdm3cEJ1XTzMqUt3V");
await infra.getTrustedPubKeyDID("fmapkumrotfc",
"PUB_K1_6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5BoDq63");
var infra = InfraDID(
"did:infra:01:PUB_K1_6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5BoDq63",
"PVT_K1_2bfGi9rYsXQSXXTvJbDAPhHLQUojjaNLomdm3cEJ1XTzMqUt3V",
"fmapkumrotfc",
"http://localhost:8888",
"fmapkumrotfc",
"PVT_K1_2bfGi9rYsXQSXXTvJbDAPhHLQUojjaNLomdm3cEJ1XTzMqUt3V");
await infra.registerTrustedAccountDID("fmapkumrotfc", "eosio", "?");
var infra = InfraDID(
"did:infra:01:PUB_K1_6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5BoDq63",
"PVT_K1_2bfGi9rYsXQSXXTvJbDAPhHLQUojjaNLomdm3cEJ1XTzMqUt3V",
"fmapkumrotfc",
"http://localhost:8888",
"fmapkumrotfc",
"PVT_K1_2bfGi9rYsXQSXXTvJbDAPhHLQUojjaNLomdm3cEJ1XTzMqUt3V");
await infra.updateTrustedAccountDID("fmapkumrotfc", "eosio", "?");
var infra = InfraDID(
"did:infra:01:PUB_K1_6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5BoDq63",
"PVT_K1_2bfGi9rYsXQSXXTvJbDAPhHLQUojjaNLomdm3cEJ1XTzMqUt3V",
"fmapkumrotfc",
"http://localhost:8888",
"fmapkumrotfc",
"PVT_K1_2bfGi9rYsXQSXXTvJbDAPhHLQUojjaNLomdm3cEJ1XTzMqUt3V");
await infra.removeTrustedAccountDID("fmapkumrotfc", "eosio");
var infra = InfraDID(
"did:infra:01:PUB_K1_6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5BoDq63",
"PVT_K1_2bfGi9rYsXQSXXTvJbDAPhHLQUojjaNLomdm3cEJ1XTzMqUt3V",
"fmapkumrotfc",
"http://localhost:8888",
"fmapkumrotfc",
"PVT_K1_2bfGi9rYsXQSXXTvJbDAPhHLQUojjaNLomdm3cEJ1XTzMqUt3V");
await infra.getTrustedAccountDIDByAuthorizer("fmapkumrotfc");
var infra = InfraDID(
"did:infra:01:PUB_K1_6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5BoDq63",
"PVT_K1_2bfGi9rYsXQSXXTvJbDAPhHLQUojjaNLomdm3cEJ1XTzMqUt3V",
"fmapkumrotfc",
"http://localhost:8888",
"fmapkumrotfc",
"PVT_K1_2bfGi9rYsXQSXXTvJbDAPhHLQUojjaNLomdm3cEJ1XTzMqUt3V");
await infra.getTrustedAccountDIDByTarget("eosio");
var infra = InfraDID(
"did:infra:01:PUB_K1_6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5BoDq63",
"PVT_K1_2bfGi9rYsXQSXXTvJbDAPhHLQUojjaNLomdm3cEJ1XTzMqUt3V",
"fmapkumrotfc",
"http://localhost:8888",
"fmapkumrotfc",
"PVT_K1_2bfGi9rYsXQSXXTvJbDAPhHLQUojjaNLomdm3cEJ1XTzMqUt3V");
await infra.getTrustedAccountDID("fmapkumrotfc", "eosio");
Resolver a = Resolver("fmapkumrotfc", "01", "http://localhost:8888");
Resolver resolver = Resolver("fmapkumrotfc", "01", "http://localhost:8888");
Map credentials = {
"vc": {
"id":
"did:infra:01:PUB_K1_6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5BoDq63",
"@context": [
"https://www.w3.org/2018/credentials/v1",
"https://coov.io/docs/vc/personal"
],
"type": ["VerifiableCredential", "Personal"],
"credentialSubject": {"dob": "19910405"}
},
"sub":
"did:infra:01:PUB_K1_6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5BoDq63",
"ver": "0.9",
"iss":
"did:infra:01:PUB_K1_6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5BoDq63"
};
String vc = await InfraVerifiable().createVerifiableCredential(credentials,
"PVT_K1_2bfGi9rYsXQSXXTvJbDAPhHLQUojjaNLomdm3cEJ1XTzMqUt3V");
print(vc + "\n");
Map verifiedVc =
await InfraVerifiable().verifyVerifiableCredential(vc, resolver);
print(verifiedVc);
print("");
Verified Credential Result
{
"vc": {
"id":
"did:infra:01:PUB_K1_6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5BoDq63",
"@context": [
"https://www.w3.org/2018/credentials/v1",
"https://coov.io/docs/vc/personal"
],
"type": ["VerifiableCredential", "Personal"],
"credentialSubject": {"dob": "19910405"}
},
"sub":
"did:infra:01:PUB_K1_6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5BoDq63",
"ver": "0.9",
"iss":
"did:infra:01:PUB_K1_6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5BoDq63"
};
String vp = await InfraVerifiable().createVerifiablePresentation(
vc,
"PVT_K1_2bfGi9rYsXQSXXTvJbDAPhHLQUojjaNLomdm3cEJ1XTzMqUt3V",
"did:infra:01:PUB_K1_6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5BoDq63",
"did:infra:01:PUB_K1_6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5BoDq63");
print(vp + "\n");
Map verifiedVp =
await InfraVerifiable().verifyVerifiablePresentation(vp, resolver);
print(verifiedVp);
print("");
Verified Presentation Result
{
"vp": {
"@context": ["https://www.w3.org/2018/credentials/v1"],
"type": ["VerifiablePresentation"],
"verifiableCredential": [
"eyJhbGciOiJFUzI1NiJ9.eyJ2YyI6eyJpZCI6ImRpZDppbmZyYTowMTpQVUJfSzFfNk1SeUFqUXE4dWQ3aFZOWWNmblZQSnFjVnBzY041U284Qmh0SHVHWXFFVDVCb0RxNjMiLCJAY29udGV4dCI6WyJodHRwczovL3d3dy53My5vcmcvMjAxOC9jcmVkZW50aWFscy92MSIsImh0dHBzOi8vY29vdi5pby9kb2NzL3ZjL3BlcnNvbmFsIl0sInR5cGUiOlsiVmVyaWZpYWJsZUNyZWRlbnRpYWwiLCJQZXJzb25hbCJdLCJjcmVkZW50aWFsU3ViamVjdCI6eyJkb2IiOiIxOTkxMDQwNSJ9fSwic3ViIjoiZGlkOmluZnJhOjAxOlBVQl9LMV82TVJ5QWpRcTh1ZDdoVk5ZY2ZuVlBKcWNWcHNjTjVTbzhCaHRIdUdZcUVUNUJvRHE2MyIsInZlciI6IjAuOSIsImlzcyI6ImRpZDppbmZyYTowMTpQVUJfSzFfNk1SeUFqUXE4dWQ3aFZOWWNmblZQSnFjVnBzY041U284Qmh0SHVHWXFFVDVCb0RxNjMifQ.mqEdDQAmNquUvRy7XjjbeW7unlsjjP7UHhFjYzVRItLoFbiM40KG_aHLqRMiF7NjX3vuAB88ukPtkAXU7PkoKA"
]
},
"iss": "did:infra:01:PUB_K1_6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5BoDq63",
"aud": [
"did:infra:01:PUB_K1_6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5BoDq63"
],
"nbf": "1671771659477",
"exp": "1671807600000"
}
For more information visit our API reference.
Infra-DID-Dart is under MIT license. See the LICENSE file for more info.