code: function verify(publicKeys, sig, text) {
      // Parse signature.
      validateBase64(sig);
      const binsig = Buffer.from(sig, 'base64');
  
      // Check signature length.
      if (binsig.length !== 10 + nacl.sign.signatureLength) {
          throw new Error('Bad signature length');
      }
  
      // Check signature algorithm.
      if (binsig[0] !== 69 /* 'E' */ || binsig[1] !== 100 /* 'd' */) {
          throw new Error('Unknown signature algorithm');
      }
  
      // Find the appropriate key for signature based on
      // algorithm and public key fingerprint embedded into signature.
      let key = null;
      for (let i = 0; i < publicKeys.length; i++) {
          const binkey = Buffer.from(publicKeys[i], 'base64');
  
          // Check public  key format.
          if (binkey.length !== 10 + nacl.sign.publicKeyLength) {
              throw new Error('Bad public key length');
          }
  
          // If algorithm (2 bytes) and key number (8) bytes match,
          // we found the needed key.
          if (nacl.verify(binkey.subarray(0, 10), binsig.subarray(0, 10))) {
              key = binkey;
              break;
          }
      }
      if (!key) {
          throw new Error('Invalid signature: no matching key found');
      }
  
      const bintext = Buffer.from(text, 'utf8');
      if (!nacl.sign.detached.verify(bintext, binsig.subarray(10), key.subarray(10))) {
          throw new Error('Invalid signature');
      }
  }
docs: Verifies signature.
  Throws if signature is invalid.
  
  @param {Array<string>} publicKeys list of base64-encoded public key in signify format
  @param {string} sig base64-encoded signature in signify format
  @param {string} text message to verify