How to use the indy-sdk.keyForDid function in indy-sdk

To help you get started, we’ve selected a few indy-sdk examples, based on popular ways it is used in public projects.

github hyperledger / indy-agent / nodejs / indy / src / connections / index.js View on Github external
exports.acceptRequest = async function (theirEndpointDid, theirDid, requestNonce) {
    let [myDid, myVerkey] = await sdk.createAndStoreMyDid(await indy.wallet.get(), {});

    let theirVerkey = await sdk.keyForDid(await indy.pool.get(), await indy.wallet.get(), theirDid);

    // await sdk.storeTheirDid(await indy.wallet.get(), {
    //     did: theirDid,
    //     verkey: theirVerkey
    // });

    let meta = JSON.stringify({
        theirEndpointDid: theirEndpointDid,
        verified: false // Indicates that the owner of the agent has confirmed they want to stay connected with this person.
    });

    //FIXME: Check to see if pairwise exists
    await sdk.createPairwise(await indy.wallet.get(), theirDid, myDid, meta);

    // Send connections response
    let connectionResponse = {
github hyperledger / indy-agent / nodejs / indy / common.js View on Github external
console.log(`\"${to}\" > Authcrypt \"${to} DID info\" for \"${From}\"`);
    let didInfoJson = JSON.stringify({
        'did': toDid,
        'verkey': toKey
    });
    let authcryptedDidInfo = await indy.cryptoAuthCrypt(toWallet, toFromKey, fromToKey, Buffer.from(didInfoJson, 'utf8'));

    console.log(`\"${to}\" > Send authcrypted \"${to} DID info\" to ${From}`);

    console.log(`\"${From}\" > Authdecrypted \"${to} DID info\" from ${to}`);
    let [senderVerkey, authdecryptedDidInfo] =
        await indy.cryptoAuthDecrypt(fromWallet, fromToKey, Buffer.from(authcryptedDidInfo));

    let authdecryptedDidInfoJson = JSON.parse(Buffer.from(authdecryptedDidInfo));
    console.log(`\"${From}\" > Authenticate ${to} by comparision of Verkeys`);
    let retrievedVerkey = await indy.keyForDid(poolHandle, fromWallet, toFromDid);
    if (senderVerkey !== retrievedVerkey) {
        throw Error("Verkey is not the same");
    }
    
    console.log(`\"${From}\" > Send Nym to Ledger for \"${to} DID\" with ${role} Role`);
    await sendNym(poolHandle, fromWallet, fromDid, authdecryptedDidInfoJson['did'], authdecryptedDidInfoJson['verkey'], role);

    return toDid
};
github hyperledger / indy-agent / nodejs / indy / src / crypto / index.js View on Github external
exports.anonCrypt = async function (did, message) {
    let verkey = await sdk.keyForDid(await indy.pool.get(), await indy.wallet.get(), did);
    let buffer = await sdk.cryptoAnonCrypt(verkey, Buffer.from(message, 'utf8'));
    return Buffer.from(buffer).toString('base64')
};