src/api.js
/**
     * Checks the data truth according to identity's real data 
     * 
     * @param   {String}      identity         identity's contract address 
     * @param   {Object[]}    nodes            List of nodes to be checked 
     * @param   {String}      nodes.label      Node label
     * @param   {String}      nodes.data       Node data
     * @param   {String}      nodes.salt       Node hash's salt 
     * @returns {Object}                       An object with errors and successes
     * @memberof Api
     */
Checks the data truth according to identity's real data


Checks the data truth according to identity ' s real data
async checkDataTruth(identity, nodes) {
        const encryptedTree = await this.getIdentityData(identity, true)
        let validations = { error : [], success : [] }
        nodes.forEach( node => { 
            let treeNode = IdentityDag.dfs(encryptedTree, node.label)
            const nodeHash = Crypto.sha3_256(node.data+node.salt)
            if(nodeHash == treeNode.hash) validations.success.push({label: node.label, data: node.data})
            else validations.error.push({label: node.label, message: 'Wrong data or salt' })
        })
        return validations
    }
async checkDataTruth ( identity , nodes ) { const encryptedTree = await this . getIdentityData ( identity , true ) let validations = { error : [ ] , success : [ ] } nodes . forEach ( node => { let treeNode = IdentityDag . dfs ( encryptedTree , node . label ) const nodeHash = Crypto . sha3_256 ( node . data + node . salt ) if ( nodeHash == treeNode . hash ) validations . success . push ( { label : node . label , data : node . data } ) else validations . error . push ( { label : node . label , message : 'Wrong data or salt' } ) } ) return validations }
Checks the data truth according to identity's real data
Checks the data truth according to identity ' s real data