Bitcoin Forum
November 15, 2024, 05:47:13 PM *
News: Check out the artwork 1Dq created to commemorate this forum's 15th anniversary
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Bitcoinj - error when signing message with UTF8 encoding  (Read 2929 times)
Amitabh S (OP)
Legendary
*
Offline Offline

Activity: 1001
Merit: 1005


View Profile
October 01, 2013, 10:21:26 AM
 #1

I have tried the latest build of bitcoinj and get error signing messages containing non-ascii characters. This problem also occurs with older versions.

Here is the string.

C'est par mon ordre et pour le bien de l'Etat que le porteur du présent a fait ce qu'il a fait.

This is the default string on brainwallet verify tab

When I use the com.google.bitcoin.core.ECKey.signMessage() method to try to sign this message. I get an exception "array index out of bound". This works nicely if the string contains only ASCII characters. So if we remove the é from the above string, things work fine.

Hope this is fixed soon.

Cheers!



Coinsecure referral ID: https://coinsecure.in/signup/refamit (use this link to signup)
Mike Hearn
Moderator
Legendary
*
Offline Offline

Activity: 1526
Merit: 1134


View Profile
October 02, 2013, 08:41:25 AM
 #2

D'oh, schoolboy error, sorry. I just pushed a fix to git master.
Amitabh S (OP)
Legendary
*
Offline Offline

Activity: 1001
Merit: 1005


View Profile
October 07, 2013, 11:39:50 AM
 #3

D'oh, schoolboy error, sorry. I just pushed a fix to git master.

Thanks! BTW can you put a compiled jar somewhere? I could not compile it with Maven (some errors I cannot remember... will post later).

PS lots of people dislike maven. Why are so many good projects hampered by Maven?

Coinsecure referral ID: https://coinsecure.in/signup/refamit (use this link to signup)
Mike Hearn
Moderator
Legendary
*
Offline Offline

Activity: 1526
Merit: 1134


View Profile
October 07, 2013, 12:02:01 PM
 #4

Maven isn't great, but it handles resolution of dependencies and is reasonably standard - lots of IDEs and tools support it.

If you were having issues with the unit tests try

mvn install -DskipTests=true

or something similar. Or just open it up with your IDE and let it handle things.

If we provided compiled JARs you'd have to grab all the dependencies by hand, which is painful.
Amitabh S (OP)
Legendary
*
Offline Offline

Activity: 1001
Merit: 1005


View Profile
October 07, 2013, 03:35:14 PM
 #5

This is the output on compile using mvn install -DskipTests=true

Code:
INFO] ------------------------------------------------------------------------
INFO] Reactor Summary:
INFO]
INFO] bitcoinj Parent ................................... SUCCESS [0.225s]
INFO] bitcoinj .......................................... FAILURE [12.582s]
INFO] bitcoinj Examples ................................. SKIPPED
INFO] bitcoinj Tools .................................... SKIPPED
INFO] ------------------------------------------------------------------------
INFO] BUILD FAILURE
INFO] ------------------------------------------------------------------------
INFO] Total time: 12.976s
INFO] Finished at: Mon Oct 07 21:03:52 IST 2013
INFO] Final Memory: 10M/62M
INFO] ------------------------------------------------------------------------
ERROR] Failed to execute goal org.apache.maven.plugins:maven-source-plugin:2.1.2:jar-no-fork (attach-sources) on project bitcoinj: Execution attach-sources of goal org.apache.maven.plugins:maven-source-plugin:2.1.2:jar-no-fork failed: Negative time -> [Help 1]

Should this work in some IDE (and which one)? (I currently only use notepad++)


If we provided compiled JARs you'd have to grab all the dependencies by hand, which is painful.

I think I can manage with the dependencies Tongue

Coinsecure referral ID: https://coinsecure.in/signup/refamit (use this link to signup)
Mike Hearn
Moderator
Legendary
*
Offline Offline

Activity: 1526
Merit: 1134


View Profile
October 07, 2013, 05:13:01 PM
 #6

Negative time?! I've never seen that error before, you're on Windows? If so, what JDK version and what filing system are you using? From a quick Googling it seems that this error can happen if you have files in your directory tree with timestamps before the UNIX epoch (1970) which obviously should never happen on a working setup.

I don't recommend doing anything in Java with just a text editor. The language is awkwardly verbose. A good IDE like IntelliJ will hide most of the uglyness from you and make it bearable. IntelliJ is free so you can go grab it and then load it up. If you tell it where to find your Maven install, it should work things out for you.

If you want to download the JARs by hand, go ahead, look inside the pom file to see what the library depends on. But it'll take a while. I'd recommend figuring out why Maven thinks time is going backwards instead. I suspect some clock issue or a filing system that doesn't store timestamps properly.

Amitabh S (OP)
Legendary
*
Offline Offline

Activity: 1001
Merit: 1005


View Profile
October 07, 2013, 06:18:38 PM
 #7

Negative time?! I've never seen that error before, you're on Windows? If so, what JDK version and what filing system are you using? From a quick Googling it seems that this error can happen if you have files in your directory tree with timestamps before the UNIX epoch (1970) which obviously should never happen on a working setup.

I don't recommend doing anything in Java with just a text editor. The language is awkwardly verbose. A good IDE like IntelliJ will hide most of the uglyness from you and make it bearable. IntelliJ is free so you can go grab it and then load it up. If you tell it where to find your Maven install, it should work things out for you.

If you want to download the JARs by hand, go ahead, look inside the pom file to see what the library depends on. But it'll take a while. I'd recommend figuring out why Maven thinks time is going backwards instead. I suspect some clock issue or a filing system that doesn't store timestamps properly.



I use windows 7 Professional 64 bit. Time has been correct.

About the IDE, I actually don't use Java directly but usually write in Scala (I consider Scala a wrapper for Java). With Scala, notepad++ is more than enough unless the project is very large.

I will try to recompile on a different PC tomorrow at work, where I have 32 bit Win 7. I have all the dependencies for the earlier version 0.10, so they should just work anyway.

Coinsecure referral ID: https://coinsecure.in/signup/refamit (use this link to signup)
Mike Hearn
Moderator
Legendary
*
Offline Offline

Activity: 1526
Merit: 1134


View Profile
October 07, 2013, 06:27:29 PM
 #8

OK, great. Let me know how you get on. If you figure out a solution for the negative time thing, that'd also be useful to know. I'd start by checking the file times in the source tree to make sure none are unrealistically early.
Amitabh S (OP)
Legendary
*
Offline Offline

Activity: 1001
Merit: 1005


View Profile
October 07, 2013, 08:08:06 PM
Last edit: October 08, 2013, 10:11:39 AM by Amitabh S
 #9

Hey Mike! Thanks for your help. The -DskipTests=true helped a lot Tongue

It was my mistake (and possibly a bug in google code repository)
I had download a zip from the repository instead of using git clone.

When I did using git clone, it worked perfectly.

Coinsecure referral ID: https://coinsecure.in/signup/refamit (use this link to signup)
Mike Hearn
Moderator
Legendary
*
Offline Offline

Activity: 1526
Merit: 1134


View Profile
October 08, 2013, 02:51:14 PM
 #10

A bug in Google Code would not surprise me, unfortunately.
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!