// Path: src/com/blochstech/bitcoincardterminal/Model/Communication/MerkleBranchElement.java
// public class MerkleBranchElement {
// 	public String hash; //This is the one sent to the card.
// 	public boolean rightNode; //True if property hash is on the right side of the pair. 
// 	public String otherHash; //In the first round this is the txHash.
// 	
// 	public MerkleBranchElement(String hash, boolean rightNode, String otherHash){
// 		this.hash = hash;
// 		this.rightNode = rightNode;
// 		this.otherHash = otherHash;
// 	}
// }


import java.nio.ByteBuffer;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.LinkedList;
import java.util.List;
import java.io.UnsupportedEncodingException;
import java.math.BigInteger;
import com.blochstech.bitcoincardterminal.Model.Communication.MerkleBranchElement;
	public static int[] toUnsigned(byte[] bytes) {
		if (bytes == null)
			return null;
		
		int[] res = new int[bytes.length];
		
		for(int i = 0; i < bytes.length; i++){
			res[i] = (int) (bytes[i] < 0 ? bytes[i] + 256 : bytes[i]);
		}
		
		return res;
	}
	public static int toUnsigned(byte singleByte) {
		return (int) (singleByte < 0 ? singleByte + 256 : singleByte);
	}
	
	public static byte[] hexStringToByteArray(String s) {
		if(RegexUtil.isMatch(s, RegexUtil.CommonPatterns.BYTEHEX)){
		    int len = s.length();
		    byte[] data = new byte[len / 2];
		    for (int i = 0; i < len; i += 2) {
		        data[i / 2] = (byte) ((Character.digit(s.charAt(i), 16) << 4)
		                             + Character.digit(s.charAt(i+1), 16));
		    }
		    return data;
		}else{
			return null;
		}
	}
	
// Path: src/com/blochstech/bitcoincardterminal/Model/Communication/MerkleBranchElement.java
// public class MerkleBranchElement {
// 	public String hash; //This is the one sent to the card.
// 	public boolean rightNode; //True if property hash is on the right side of the pair. 
// 	public String otherHash; //In the first round this is the txHash.
// 	
// 	public MerkleBranchElement(String hash, boolean rightNode, String otherHash){
// 		this.hash = hash;
// 		this.rightNode = rightNode;
// 		this.otherHash = otherHash;
// 	}
// }


// Path: src/com/blochstech/bitcoincardterminal/Utils/ByteConversionUtil.java
import java.nio.ByteBuffer;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.LinkedList;
import java.util.List;
import java.io.UnsupportedEncodingException;
import java.math.BigInteger;
import com.blochstech.bitcoincardterminal.Model.Communication.MerkleBranchElement;

	public static int[] toUnsigned(byte[] bytes) {
		if (bytes == null)
			return null;
		
		int[] res = new int[bytes.length];
		
		for(int i = 0; i < bytes.length; i++){
			res[i] = (int) (bytes[i] < 0 ? bytes[i] + 256 : bytes[i]);
		}
		
		return res;
	}
	public static int toUnsigned(byte singleByte) {
		return (int) (singleByte < 0 ? singleByte + 256 : singleByte);
	}
	
	public static byte[] hexStringToByteArray(String s) {
		if(RegexUtil.isMatch(s, RegexUtil.CommonPatterns.BYTEHEX)){
		    int len = s.length();
		    byte[] data = new byte[len / 2];
		    for (int i = 0; i < len; i += 2) {
		        data[i / 2] = (byte) ((Character.digit(s.charAt(i), 16) << 4)
		                             + Character.digit(s.charAt(i+1), 16));
		    }
		    return data;
		}else{
			return null;
		}
	}
	
	public static MerkleBranchElement[] MerkleListToArray(LinkedList<MerkleBranchElement> list){