Author

Topic: ECKey.ECDSASignature creation (Read 584 times)

newbie
Activity: 11
Merit: 0
January 09, 2016, 01:49:04 PM
#3
Thanks,

so the scenario trying to sign the bytes of private key is not accepted.

I made this assumption because the Sha256Hash.wrap(key.getPrivKeyBytes()); function wraps a 32 byte[] which was convenient to me to be the getPrivKeyBytes() result,as i didn't have something else to sign.

But as it gets clear to me now..that i have to sign a Transaction,which i haven't implemented in my code before.
                  
staff
Activity: 3374
Merit: 6530
Just writing some code
January 09, 2016, 12:50:58 PM
#2
When you are signing something, there must always be a message to sign, otherwise nothing is being signed. Part of signing a message is also revealing the message you signed; a standalone signature is useless since the actual message of a standalone signature cannot be known.. You should not sign your private key since that would reveal your private key in the message or simply produce a signature that you can't do anything with since you don't want to reveal the message.

You can sign whatever you want, but in the case of Bitcoin, the thing that is signed is the entire transaction. An unsigned transaction is created and something (I don't remember what) is put in place of where the signature would be and that is signed in order to create the signed transaction.
newbie
Activity: 11
Merit: 0
January 09, 2016, 12:39:53 PM
#1
Hello,



I have my ECKey key;

In order to create a ECDSASignature object with BitcoinJ we have to call the :

ECDSASignature mySignature=key.sign(Sha256Hash input);
The Sha256Hash input is my message? The Sha256Hash input is the result of Sha256(byte[] myArray)?

What if i have not message to sign!! Is it acceptable to sign the key.getPrivKeyBytes()?? in order to create an ECDSASignature or it is unacceptable because it reveals information including in getPrivKeyBytes() and as a result reveal my private key??

And if it is unacceptable which must be my message? I can sign whatever i want in order to create my ECDSASignature ?
Jump to: