Thank you for the bitcoinj library, it's great!

I have been trying to mimic some stuff from Intel Sawtooth (another 
blockchain) in Java...I can successfully 
get the public/private EC keys to be byte-for-byte identical with their 
library, but I am
struggling to produce an ECDSA signature that is identical to theirs when 
using the bitcoinj library.

Their message signatures are 64 bytes hex encoded (so 128 bytes total),
and it looks like the 64 bytes are 32 bytes R field then 32 bytes S
field.  Can anyone help me *generate a "compact signature*"? (If that is 
what this is...)

Here is an example of theirs (python):

>>> privatekey
'5K9gBxYNbtygky5sntvXqaMLj36q4W9ibkPG1WzquBSvXpyyjo8'
>>> sawtooth_signing.sign('asdf', privatekey)
'0168026d34d6c65fd2002debec84cde2a2f90ee8c7329e28a2f5055861abb2757e0b8d1b1308c3d5f6741843e8244032617767495a52b2db26938777ae68bd02'
# 64 bytes hex

*Using bitcoinj* the w/ same private key to sign the same exact message:
(sign pk "asdf")
=> 
"eecc7b60410b2a33a3c31482c0db80f56827923c7bd116805a9f29ebe93caa4d4076efab21a763eb13054dd155d888977ed804a1269f1ba001533576a5484a96"
# 64 bytes hex

The broken code I'm using (clojure)

(defn sign
  [^ECKey pk data]
  (let [h (Sha256Hash/twiceOf data)
        sig (.sign pk h nil)
        arr (byte-array 64)]
    (System/arraycopy (Utils/bigIntegerToBytes (.-r sig) 32) 0 arr 0 32)
    (System/arraycopy (Utils/bigIntegerToBytes (.-s sig) 32) 0 arr 32 32)
    (.encode Utils/HEX arr))

Intel's documentation on transaction signing for reference
https://intelledger.github.io/_autogen/txn_submit_tutorial.html#sign-the-header

-- 
You received this message because you are subscribed to the Google Groups 
"bitcoinj" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to