Program: 85850
Project: 85850
Buggy source:
/** 
 * <p>Constructs a new Bloom Filter which will provide approximately the given false positive rate when the given number of elements have been inserted.</p> <p>If the filter would otherwise be larger than the maximum allowed size, it will be automatically downsized to the maximum size.</p> <p>To check the theoretical false positive rate of a given filter, use   {@link BloomFilter#getFalsePositiveRate(int)}</p> <p>The anonymity of which coins are yours to any peer which you send a BloomFilter to is controlled by the false positive rate.</p> <p>For reference, as of block 187,000, the total number of addresses used in the chain was roughly 4.5 million.</p> <p>Thus, if you use a false positive rate of 0.001 (0.1%), there will be, on average, 4,500 distinct public keys/addresses which will be thought to be yours by nodes which have your bloom filter, but which are not actually yours.</p> <p>Keep in mind that a remote node can do a pretty good job estimating the order of magnitude of the false positive rate of a given filter you provide it when considering the anonymity of a given filter.</p> <p>In order for filtered block download to function efficiently, the number of matched transactions in any given block should be less than (with some headroom) the maximum size of the MemoryPool used by the Peer doing the downloading (default is   {@link MemoryPool#MAX_SIZE}). See the comment in processBlock(FilteredBlock) for more information on this restriction.</p> <p>randomNonce is a tweak for the hash function used to prevent some theoretical DoS attacks. It should be a random value, however secureness of the random value is of no great consequence.</p> <p>updateFlag is used to control filter behavior</p>
 */
public BloomFilter(int elements,double falsePositiveRate,long randomNonce,bloomUpdate updateFlag){
  int size=Math.min((int)(-1 / (Math.pow(Math.log(2),2)) * elements * Math.log(falsePositiveRate)),(int)MAX_FILTER_SIZE * 8) / 8;
  data=new byte[size <= 0 ? 1 : size];
  hashFuncs=Math.min((int)(data.length * 8 / elements * Math.log(2)),MAX_HASH_FUNCS);
  this.nTweak=randomNonce;
  this.nFlags=(byte)(0xff & updateFlag.ordinal());
}

Fixed version (ground truth):
/** 
 * <p>Constructs a new Bloom Filter which will provide approximately the given false positive rate when the given number of elements have been inserted.</p> <p>If the filter would otherwise be larger than the maximum allowed size, it will be automatically downsized to the maximum size.</p> <p>To check the theoretical false positive rate of a given filter, use   {@link BloomFilter#getFalsePositiveRate(int)}</p> <p>The anonymity of which coins are yours to any peer which you send a BloomFilter to is controlled by the false positive rate.</p> <p>For reference, as of block 187,000, the total number of addresses used in the chain was roughly 4.5 million.</p> <p>Thus, if you use a false positive rate of 0.001 (0.1%), there will be, on average, 4,500 distinct public keys/addresses which will be thought to be yours by nodes which have your bloom filter, but which are not actually yours.</p> <p>Keep in mind that a remote node can do a pretty good job estimating the order of magnitude of the false positive rate of a given filter you provide it when considering the anonymity of a given filter.</p> <p>In order for filtered block download to function efficiently, the number of matched transactions in any given block should be less than (with some headroom) the maximum size of the MemoryPool used by the Peer doing the downloading (default is   {@link MemoryPool#MAX_SIZE}). See the comment in processBlock(FilteredBlock) for more information on this restriction.</p> <p>randomNonce is a tweak for the hash function used to prevent some theoretical DoS attacks. It should be a random value, however secureness of the random value is of no great consequence.</p> <p>updateFlag is used to control filter behavior</p>
 */
public BloomFilter(int elements,double falsePositiveRate,long randomNonce,BloomUpdate updateFlag){
  int size=Math.min((int)(-1 / (Math.pow(Math.log(2),2)) * elements * Math.log(falsePositiveRate)),(int)MAX_FILTER_SIZE * 8) / 8;
  data=new byte[size <= 0 ? 1 : size];
  hashFuncs=Math.min((int)(data.length * 8 / (double)elements * Math.log(2)),MAX_HASH_FUNCS);
  this.nTweak=randomNonce;
  this.nFlags=(byte)(0xff & updateFlag.ordinal());
}