How to use cryptotools to modify signatures and vefiry an existing MultiSig transaction #21
Replies: 3 comments 3 replies
-
Hey @Anynomouss, Happy to help grin since I am an old contributor and sorry for the lack of documentation If I understand correctly you want to replace 2 signatures in a 4-of-6 multisig ? or you can do it like this
Here the witness contains 6 stack items: the empty byte string, the 4 sigs and the witness script which is or (in symbolic representation)
All you have to do is replace 2 of the signatures in the witness with your new sigs Hopefully something like this will work: from cryptotools import hex_to_bytes, Transaction
EXTRA_SIG_1 = hex_to_bytes('your_signature_1_hex_including_hashcode')
EXTRA_SIG_2 = hex_to_bytes('yout_signature_2_hex_including_hashcode')
tx = Transaction.get('cfbc3792e42a6832825f5b4f9dcb264d7a84662f0365661a05c1db591546bac3')
inp = tx.inputs[0]
wit = list(inp.witness)
wit[1] = EXTRA_SIG_1
wit[2] = EXTRA_SIG_2
inp.witness = tuple(wit)
print("Modified Transaction hex:")
print(tx.hex()) |
Beta Was this translation helpful? Give feedback.
-
Finding it hard installing the script, I would love proper documentation as this is the only way I think I can recover my lost phrase. I will really appreciate if I am assisted |
Beta Was this translation helpful? Give feedback.
-
Quite new to python and I barely know my way around here lol
I have successfully cloned the script, lemme look around how to install using setup.py
I am getting this error
ERROR: Error [WinError 2] The system cannot find the file specified while executing command git clone -q https://github.com/mcdallas/cryptotools.git 'C:\Users\Dell User\AppData\Local\Temp\pip-req-build-gpf5hees'ERROR: Cannot find command 'git' - do you have 'git' installed and in your PATH?
On Friday, September 17, 2021, 12:42:03 PM GMT+1, Mike Dallas ***@***.***> wrote:
@Deramalachy what seems to be the problem? You can either clone it and run setup.py or just run pip install git+https://github.com/mcdallas/cryptotools.git
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications on the go with GitHub Mobile for iOS or Android.
|
Beta Was this translation helpful? Give feedback.
-
Dear all,
And especially @mcdallas , I want to use your library to solve a particular problem for MultiSig holders, and that problem is the need to be able to produce security proof, so accessibility of all MultiSig holders keys on a regular basis. See here the issue discussed on bitcointalk:
https://bitcointalk.org/index.php?topic=5353221.msg57646299#msg57646299
Unfortunately even when signing a transaction with all MultiSig holders, only the minimal amount of signatures are broadcasted to the network.
Therefore, I wrote a small script to parse the signatures from Partially Signed Bitcoin Transaction data shared among MultiSigHolders to extract all signatures.
Subsequently I want to use cryptotools to substitute the signature in the raw transacion hex with missing signatures.
Cryptotools can verify the transaction, and as such proof that the additional signatures I provided are valid, providing security proof that all key-holders indeed have access to their keys.
I do however missed some documentation on how to use cryptotools to modify a transaction. I can use
tx.json()
to get the transaction data and replace a signature in the witness data (P2WSH transaction), but I do not see how to modify it, or load a modified version of the json as a transaction.Alternatively I could use
'tx.hex()' to get the raw hex and swap a signature, but also here I do not see how to load the hex in a transaction and tests it validity 'using tx.verify'
Any help, suggestions or links to more elaborate documentation of the cryptotools library are greatly appreciated.
Anynomous
Beta Was this translation helpful? Give feedback.
All reactions