<commit_before>package scorex.crypto.authds.avltree.batch

import com.google.common.primitives.Ints
import scorex.crypto.authds._
import scorex.crypto.hash.{Blake2b256Unsafe, ThreadUnsafeHash}
import scorex.utils.ByteArray

import scala.collection.mutable
import scala.util.{Failure, Try}

/**
  * Implements the batch AVL verifier from https://eprint.iacr.org/2016/994
  *
  * @param keyLength        - length of keys in tree
  * @param valueLengthOpt   - length of values in tree. None if it is not fixed
  * @param maxNumOperations - option the maximum number of operations that this proof
  *                         can be for, to limit running time in case of malicious proofs.
  *                         If None, running time limits will not be enforced.
  * @param maxDeletes       - at most, how many of maxNumOperations can be deletions;
  *                         for a tighter running time bound and better attack protection.
  *                         If None, defaults to maxNumOperations.
  * @param hf               - hash function
  */

class BatchAVLVerifier[HF <: ThreadUnsafeHash](startingDigest: Array[Byte],
                                               proof: ADProof,
                                               override val keyLength: Int,
                                               override val valueLengthOpt: Option[Int],
                                               maxNumOperations: Option[Int] = None,
                                               maxDeletes: Option[Int] = None
                                              )
                                              (implicit hf: HF = new Blake2b256Unsafe)
  extends AuthenticatedTreeOps with ToStringHelper {

  protected val labelLength = hf.DigestSize

  /**<commit_msg>Digest in Verifier should have type ADDigest<commit_after>package scorex.crypto.authds.avltree.batch

import com.google.common.primitives.Ints
import scorex.crypto.authds._
import scorex.crypto.hash.{Blake2b256Unsafe, ThreadUnsafeHash}
import scorex.utils.ByteArray

import scala.collection.mutable
import scala.util.{Failure, Try}

/**
  * Implements the batch AVL verifier from https://eprint.iacr.org/2016/994
  *
  * @param keyLength        - length of keys in tree
  * @param valueLengthOpt   - length of values in tree. None if it is not fixed
  * @param maxNumOperations - option the maximum number of operations that this proof
  *                         can be for, to limit running time in case of malicious proofs.
  *                         If None, running time limits will not be enforced.
  * @param maxDeletes       - at most, how many of maxNumOperations can be deletions;
  *                         for a tighter running time bound and better attack protection.
  *                         If None, defaults to maxNumOperations.
  * @param hf               - hash function
  */

class BatchAVLVerifier[HF <: ThreadUnsafeHash](startingDigest: ADDigest,
                                               proof: ADProof,
                                               override val keyLength: Int,
                                               override val valueLengthOpt: Option[Int],
                                               maxNumOperations: Option[Int] = None,
                                               maxDeletes: Option[Int] = None
                                              )
                                              (implicit hf: HF = new Blake2b256Unsafe)
  extends AuthenticatedTreeOps with ToStringHelper {

  protected val labelLength = hf.DigestSize

  /**
{'fraction_non_alphanumeric': 0.06036892118501956, 'fraction_numerical': 0.008384572386808273, 'mean_word_length': 1.5766738660907127, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 28, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3142211', 'n_tokens_mistral': 867, 'n_tokens_neox': 832, 'n_words': 282}