python-bitcoin-utils icon indicating copy to clipboard operation
python-bitcoin-utils copied to clipboard

There is a difference between the nodejs bitcoinjs signature text information and the python-bitcoin-utils signature text information

Open wyq000 opened this issue 1 year ago • 1 comments

The final length of the nodejs signature is 128 bits, why is the final length of the python-bitcoin-utils signature 130 bits? What causes this difference?

wyq000 avatar Jul 02 '24 12:07 wyq000

Hi @wyq000 ,

The sizes of valid signatures can vary, even for the same txs. Are the txs you are comparing legacy or segwit/toproot?

Also, I always use bitcoin-core as reference (other libraries typically to the same). Iirc, there is only one case that bitcoin-utils' library produces different (valid!) signatures than bitcoin-core.

I could try to check this further if you provide the tx for me to check.

karask avatar Jul 03 '24 11:07 karask

Yes, I am using bitcoinjs for testing.this is my code var mnemonic = "mnemonic xxxx"; var seed = bip39.mnemonicToSeedSync(mnemonic); var network = bitcoin.networks.testnet; bitcoin.initEccLib(ecc);

var root = bip32.fromSeed(seed, network); var account = root.derivePath("m/84'/1'/0'"); var keyPair = account; var message = ''; var messageHash = bitcoin.crypto.sha256(Buffer.from(message)); console.log("Signature: ",keyPair.sign(messageHash).toString('hex')); keyPair.sign keyPair.sign has a length of 128

wyq000 avatar Jul 08 '24 15:07 wyq000

Hi @wyq000 ,

Just back from holidays.

I need the signature as generated from bitcoin-utils and bitcoin-core. This is because bitcoin core is the only reference that I can use. E.g. I can investigate further if the signatures bitcoin-utils produces is different that bitcoin core.

karask avatar Jul 25 '24 13:07 karask