docs: function checkStanza(hubClient, stanza, fields, author, opt_sigValue) {
    var sig = opt_sigValue === undefined ? stanza.sig : opt_sigValue;
    if (!sig) {
      throw new errors.AuthenticationError('No `sig` field in stanza');
    }
    if (!stanza.updatedAt || typeof(stanza.updatedAt) != 'number') {
      throw new errors.AuthenticationError('Invalid `updatedAt` field in stanza');
    }
    return hubClient.getUserProfile(author, stanza.updatedAt)
      .then(function(userProfile) {
        var verifier = ursa.createVerifier('sha1');
        updateWithFields(verifier, stanza, fields);
        var pubkeyStr = userProfile.pubkey;
        var pubkey = ursa.createPublicKey(pubkeyStr);
        var ok = verifier.verify(pubkey, stanza.sig, 'base64');
        if (ok) {
          return true;
        }
        debug('First verification failed', author);
        // The signatures do not match.  Refetch the author's profile directly
        // from the hub, then try again.
        if (Date.now() - userProfile.syncedAt < MIN_ENTITY_RESYNC_MS) {
          debug('Not refetching user profile', author);
          return false;
        }
        return hubClient.getUserProfileFromHub(author, stanza.updatedAt)
          .then(function(userProfile) {
            // The pubkeys are still the same, so don't bother re-checking.
            if (userProfile.pubkey == pubkeyStr) {
              debug('Pubkeys identical, not reverifying', author);
              return false;
            }
            // The pubkeys are different, so perhaps that's why the first check
            // failed.
            var pubkey = ursa.createPublicKey(userProfile.pubkey);
            return verifier.verify(userProfile.pubkey, sig, 'base64');
          })
      })
      .catch(errors.NotFoundError, function(err) {
        throw new errors.AuthenticationError(
            'No such user registered with the Hub: ' + author);
      })
      .then(function(ok) {
        if (!ok) {
          throw new errors.AuthenticationError('Stanza signatures do not match for user ' + author);
        }
        return ok;
      });
  }