How to use the js-sha3.sha3_512.array function in js-sha3

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

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github chainpoint / chainpoint-validate-js / src / chainpointvalidate.js View on Github external
hashResult = crypto.createHash('sha384').update(hashResult).digest();
                        break;
                    case 'sha-512':
                        hashResult = crypto.createHash('sha512').update(hashResult).digest();
                        break;
                    case 'sha3-224':
                        hashResult = new Buffer(sha3_224.array(hashResult));
                        break;
                    case 'sha3-256':
                        hashResult = new Buffer(sha3_256.array(hashResult));
                        break;
                    case 'sha3-384':
                        hashResult = new Buffer(sha3_384.array(hashResult));
                        break;
                    case 'sha3-512':
                        hashResult = new Buffer(sha3_512.array(hashResult));
                        break;
                }
                return operationCallback();
            } else if (_.has(operation, 'anchors')) {
                if (!_.isArray(operation.anchors)) return operationCallback('Invalid anchors operation - ' + operation.anchors);
                if (operation.anchors.length === 0) return operationCallback('Invalid anchors operation - ' + operation.anchors);

                // Validate each anchor item contents
                for (var x = 0; x < operation.anchors.length; x++) {
                    var anchorType = operation.anchors[x].type || operation.anchors[x]['@type'];
                    if (!anchorType) return operationCallback('Missing anchor type');
                    if (_.indexOf(CHAINPOINTv2_VALID_ANCHORTYPES, anchorType) == -1) return operationCallback('Invalid anchor type - ' + anchorType);

                    var sourceId = operation.anchors[x].sourceId;
                    if (!sourceId) return operationCallback('Missing sourceId');
github Tierion / merkle-tools / merkletools.js View on Github external
var hashFunction = function (value) {
    switch (hashType) {
      case 'SHA3-224':
        return Buffer.from(sha3224.array(value))
      case 'SHA3-256':
        return Buffer.from(sha3256.array(value))
      case 'SHA3-384':
        return Buffer.from(sha3384.array(value))
      case 'SHA3-512':
        return Buffer.from(sha3512.array(value))
      default:
        return crypto.createHash(hashType).update(value).digest()
    }
  }
github BANKEX / PlasmaParentContract / lib / merkle-tools.js View on Github external
var hashFunction = function (value) {
    switch (hashType) {
      case 'SHA3-224':
        return new Buffer(sha3224.array(value))
      case 'SHA3-256':
        return new Buffer(sha3256.array(value))
      case 'SHA3-384':
        return new Buffer(sha3384.array(value))
      case 'SHA3-512':
        return new Buffer(sha3512.array(value))
      case 'sha3':
        return ethUtil.sha3(value, 256)  
      default:
        return crypto.createHash(hashType).update(value).digest()
    }
  }