
package fortuna.acumulator;

/**
 *
 * @author Viliam Krizan
 */

import aalg.crypto.IHashFunction;



public class Pool {
    private final IHashFunction hash;
    private long size;
    
    public Pool(IHashFunction hash){
        this.hash = hash;
    }
    
    
    public synchronized void addEntropy(byte[] entropy){
        hash.update(entropy, 0, entropy.length);
        size += entropy.length;
    }
    
    public void clear(){
        hash.initialize();
        size = 0;
    }
    
    public byte[] getEntropy(){
        byte[] result = hash.finish();
        clear();
        
        return result;
    }
    
    public long getSize(){
        return size;
    }
    
}
