getPrivateKeyForCredentialDid method

Future<String?> getPrivateKeyForCredentialDid(
  1. String did
)

Returns the private key as hex-String associated with did.

Implementation

Future<String?> getPrivateKeyForCredentialDid(
  String did,
) async {
  if (did.startsWith('did:ethr') || did.startsWith('did:key:zQ3s')) {
    return _getPrivateKeyForCredentialDidEthr(did);
  } else if (did.startsWith('did:key:z6Mk')) {
    return _getPrivateKeyForCredentialDidEd(did);
  } else if (did.startsWith('did:key:zDn')) {
    return _getPrivateKeyForPCredentialDid(did, getP256());
  } else if (did.startsWith('did:key:z82')) {
    return _getPrivateKeyForPCredentialDid(did, getP384());
  } else if (did.startsWith('did:key:z2J9')) {
    return _getPrivateKeyForPCredentialDid(did, getP521());
  } else {
    throw Exception('Unknown KeyType');
  }
}