Bitcoin Forum
May 27, 2024, 03:10:31 AM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Verifying mrkl root from two children nodes in JAVA  (Read 1302 times)
tyrick (OP)
Newbie
*
Offline Offline

Activity: 9
Merit: 0


View Profile WWW
December 03, 2013, 03:03:52 AM
 #1

I have a better formatted version of my issue here:
http://bitcoin.stackexchange.com/questions/17676/verifying-mrkl-root-from-two-children-nodes-in-java

I am convinced that there is a JAVA issue with my hexToAscii implementation.

Code:
	public String hexToBin(String hex) {
  StringBuilder sb = new StringBuilder();
  StringBuilder temp = new StringBuilder();
  //49204c6f7665204a617661 split into two characters 49, 20, 4c...
  for(int i = 0; i < hex.length() - 1; i += 2){
      //grab the hex in pairs
      String output = hex.substring(i, (i + 2));
      //convert hex to decimal
      int decimal = Integer.parseInt(output, 16);
      //convert the decimal to character
      temp.append(decimal);
  }
  return sb.toString();
}


Code:
d4 : parse=> Ô
9b : parse=> ›
95 : parse=> •
84 : parse=> „
9c : parse=> œ
87 : parse=> ‡
b8 : parse=> ¸
a4 : parse=> ¤

Why so many blanks? My friend's php implementation (which works) spits out characters for some of those.  Although our string lengths are the same size (32), his contains characters that mine doesn't.  (this results in the sha256 being different as well)

Some expertise would be appreciated here =/

Mike Hearn
Moderator
Legendary
*
Offline Offline

Activity: 1526
Merit: 1129


View Profile
December 04, 2013, 10:57:59 AM
 #2

Why are you trying to parse a string from another hex-encoded string? Bitcoin doesn't require such an operation anywhere. If you're trying to verify a merkle tree, bitcoinj already has code to do that.
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!