<commit_before>/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package bft;

import bft.BFTNode;
import bftsmart.tom.MessageContext;
import bftsmart.tom.core.messages.TOMMessage;
import com.google.protobuf.ByteString;
import java.io.BufferedReader;
import java.io.ByteArrayOutputStream;
import java.io.FileReader;
import java.io.IOException;
import java.io.StringWriter;
import java.security.InvalidKeyException;
import java.security.KeyPair;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.security.NoSuchProviderException;
import java.security.PrivateKey;
import java.security.Signature;
import java.security.SignatureException;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
import java.util.Random;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.bouncycastle.asn1.ASN1Integer;
import org.bouncycastle.asn1.ASN1OutputStream;
import org.bouncycastle.asn1.DEROctetString;
import org.bouncycastle.cert.X509CertificateHolder;
import org.bouncycastle.openssl.PEMKeyPair;
import org.bouncycastle.openssl.PEMParser;
import org.bouncycastle.openssl.jcajce.JcaPEMKeyConverter;
import org.bouncycastle.util.io.pem.PemObject;
import org.bouncycastle.util.io.pem.PemWriter;
import org.hyperledger.fabric.protos.common.Common;
import org.hyperledger.fabric.protos.msp.Identities;
import org.hyperledger.fabric.sdk.exception.CryptoException;
import org.hyperledger.fabric.sdk.exception.InvalidArgumentException;
import org.hyperledger.fabric.sdk.security.CryptoPrimitives;

/**
 *
 * @author joao
 */
public class TestSignatures {
    
    private static CryptoPrimitives crypto;
    private static final int NUM_BATCHES = 200;
    private static final int BATCH_SIZE = 10;
    private static final int ENV_SIZE = 1024;
    private static final int NUM_BLOCKS = 100;
    
    private static final String Mspid = "DEFAULT";

    private static Random rand;
    private static ExecutorService executor = null;
    private static PrivateKey privKey = null;
    private static byte[] serializedCert = null;
    private static Identities.SerializedIdentity ident;
    
    //measurements
    private static long sigsMeasurementStartTime = -1;
    private static int interval = 10000;
    private static int countSigs = 0;
    
    public static void main(String[] args) throws CryptoException, InvalidArgumentException, NoSuchAlgorithmException, NoSuchProviderException, IOException {
        
        TestSignatures.crypto = new CryptoPrimitives();
        TestSignatures.crypto.init();
        TestSignatures.rand = new Random(System.nanoTime());
        TestSignatures.executor = Executors.newFixedThreadPool(Integer.parseInt(args[0]));
        TestSignatures.privKey = getPemPrivateKey(args[1]);
        parseCertificate(args[2]);
        TestSignatures.ident = getSerializedIdentity();
        
        int interval = Integer.parseInt(args[3]);
        
        //Generate pool of batches
        System.out.print("Generating " + NUM_BATCHES + " batches with " + BATCH_SIZE + " envelopes each... ");
        byte[][][] batches = new byte[NUM_BATCHES][BATCH_SIZE][];
        for (int i = 0; i < NUM_BATCHES; i++) {
            
            for (int j = 0; j < BATCH_SIZE; j++) {<commit_msg>small experiment<commit_after>/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package bft;

import bft.BFTNode;
import bftsmart.tom.MessageContext;
import bftsmart.tom.core.messages.TOMMessage;
import com.google.protobuf.ByteString;
import java.io.BufferedReader;
import java.io.ByteArrayOutputStream;
import java.io.FileReader;
import java.io.IOException;
import java.io.StringWriter;
import java.security.InvalidKeyException;
import java.security.KeyPair;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.security.NoSuchProviderException;
import java.security.PrivateKey;
import java.security.Signature;
import java.security.SignatureException;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
import java.util.Random;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.bouncycastle.asn1.ASN1Integer;
import org.bouncycastle.asn1.ASN1OutputStream;
import org.bouncycastle.asn1.DEROctetString;
import org.bouncycastle.cert.X509CertificateHolder;
import org.bouncycastle.openssl.PEMKeyPair;
import org.bouncycastle.openssl.PEMParser;
import org.bouncycastle.openssl.jcajce.JcaPEMKeyConverter;
import org.bouncycastle.util.io.pem.PemObject;
import org.bouncycastle.util.io.pem.PemWriter;
import org.hyperledger.fabric.protos.common.Common;
import org.hyperledger.fabric.protos.msp.Identities;
import org.hyperledger.fabric.sdk.exception.CryptoException;
import org.hyperledger.fabric.sdk.exception.InvalidArgumentException;
import org.hyperledger.fabric.sdk.security.CryptoPrimitives;

/**
 *
 * @author joao
 */
public class TestSignatures {
    
    private static CryptoPrimitives crypto;
    private static final int NUM_BATCHES = 200;
    private static final int BATCH_SIZE = 10;
    private static final int ENV_SIZE = 1024;
    private static final int NUM_BLOCKS = 100;
    
    private static final String Mspid = "DEFAULT";

    private static Random rand;
    private static ExecutorService executor = null;
    private static PrivateKey privKey = null;
    private static byte[] serializedCert = null;
    private static Identities.SerializedIdentity ident;
    
    //measurements
    private static long sigsMeasurementStartTime = -1;
    private static int interval = 10000;
    private static int countSigs = 0;
    
    public static void main(String[] args) throws CryptoException, InvalidArgumentException, NoSuchAlgorithmException, NoSuchProviderException, IOException {
        
        TestSignatures.crypto = new CryptoPrimitives();
        TestSignatures.crypto.init();
        TestSignatures.rand = new Random(System.nanoTime());
        //TestSignatures.executor = Executors.newFixedThreadPool(Integer.parseInt(args[0]));
        TestSignatures.executor = Executors.newCachedThreadPool();
        TestSignatures.privKey = getPemPrivateKey(args[1]);
        parseCertificate(args[2]);
        TestSignatures.ident = getSerializedIdentity();
        
        int interval = Integer.parseInt(args[3]);
        
        //Generate pool of batches
        System.out.print("Generating " + NUM_BATCHES + " batches with " + BATCH_SIZE + " envelopes each... ");
        byte[][][] batches = new byte[NUM_BATCHES][BATCH_SIZE][];
        for (int i = 0; i < NUM_BATCHES; i++) {
            
            for (int j = 0; j < BATCH_SIZE; j++) {
{'fraction_non_alphanumeric': 0.09262920079073708, 'fraction_numerical': 0.00931940129906806, 'mean_word_length': 4.235033259423504, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6617057', 'n_tokens_mistral': 2153, 'n_tokens_neox': 2050, 'n_words': 487}