/*
 * 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 anonym_signature_2017;

import java.math.BigInteger;

/**
 *
 * @author Dzurenda
 */
public class Utils {
    
    /**
     * Convertation Big Integer number to byte array without first byte specified significance
     * @param bigInt
     * @return 
     */
    public static byte[] bigIntToByteArray(BigInteger bigInt){
        
        byte[] directArray = bigInt.toByteArray();
        byte[] bigIntArray = new byte[directArray.length-1];
        
        System.arraycopy(directArray, 1, bigIntArray, 0, bigIntArray.length);
        return bigIntArray;
    }
    
     public static BigInteger byteArrayToBigInt(byte[] array){
        
        byte[] directArray = new byte[array.length+1];
        
        System.arraycopy(array, 0, directArray, 1, array.length);
        directArray[0] = (byte) 0x00;
            
        return new BigInteger(directArray);
    }
         
}
