/// Creates a Did Document from the given [wallet], [pubKeys] and optional [service]. public static DidDocument fromWallet(Wallet wallet, List <PublicKey> pubKeys, List <DidDocumentService> service = null) { if (pubKeys.Count < 2) { System.ArgumentException argEx = new System.ArgumentException("Argument Exception: DidDocument fromWallet - At least two keys are required "); throw argEx; } //String authKeyId = $"{wallet.bech32Address}#keys-1"; // *** CHeck this !!! //DidDocumentPublicKey authKey = new DidDocumentPublicKey( // id: authKeyId, // type: DidDocumentPubKeyType.SECP256K1, // controller: wallet.bech32Address, // publicKeyHex: HexEncDec.ByteArrayToString(wallet.publicKey) //); //final otherKeys = mapIndexed( // pubKeys, (index, item) => _convertKey(item, index + 2, wallet)) // .toList(); // No need to have an util here, I think Linq will do List <DidDocumentPublicKey> otherKeys = pubKeys.Select(item => _convertKey(item, pubKeys.IndexOf(item) + 1, wallet)).ToList(); DidDocumentProofSignatureContent proofContent = new DidDocumentProofSignatureContent( context: "https://www.w3.org/ns/did/v1", id: wallet.bech32Address, publicKeys: otherKeys ); String verificationMethod = wallet.bech32PublicKey; DidDocumentProof proof = _computeProof(proofContent.id, verificationMethod, proofContent, wallet); return(new DidDocument( context: proofContent.context, id: proofContent.id, publicKeys: proofContent.publicKeys, proof: proof, service: service )); }
public DidDocument(String context, String id, List <DidDocumentPublicKey> publicKeys, DidDocumentProof proof, List <DidDocumentService> service) { Trace.Assert(context != null); Trace.Assert(id != null); Trace.Assert(publicKeys != null); Trace.Assert(proof != null); this.context = context; this.id = id; this.publicKeys = publicKeys; this.proof = proof; //RC - Force service as null if list is empty - to be compliant to specs, no empty list should be there. this.service = ((service?.Count > 0) ? service : null); }