Info

Download ZIP (15.5 KB)

Testing and Issues

You can test this entry and submit issues during the testing period of the Blockchain Contest contest.

Entries with serious issues will not be able to win the contest, but even minor issues might be important for overall results.

Voting

33

Comments

Simple multisignature wallet.


wc -- workchain-id(int)
n -- number of signatures (unsigned int from 1 to 100)
k -- number of signatures for transaction sign (unsigned int from 1 to 100; k<n )
source_addr -- wallet address
dest_addr -- destination wallet address
amount -- Grams(unsigned int)
timeout -- time in seconds while contract is valid
seqno -- unsigned int
1
• new-multisig-wallet.fif — generates new wallet
[wc] [n] [k] (output-file-name)

• new-multisig-transaction.fif — generate .trans file that store signatures and transaction info and later transforms to .boc and sends to blockchain.
[source-wallet] [dest-wallet] [amount] [file-base] [k] [output-file-name] [timeout].
• result.trans —  example of generated .trans

•generate-mutlisig-query.fif — transform .trans in .boc that can be sent to blockchain
[.trans-file-name] [output-file-base] [seqno]
• result.boc — example of generated .boc file

•sign-transaction.fif — adds signature to .trans
[.trans-file-base] [keypair-file-base]

•transaction-info.fif — shows data stored in .trans 
[.trans-file-base]

•multisig-query-info.fif — shows data from .boc 
[.boc-file-base]

•mutlisig-wallet-code.fc — smart contract code
1
ALSO:
• test-multisig.fif script for smartcontract testing purposes
•TonUtil.fif — has additional functions for working with keypairs that have ids
1
User side: user creates a wallet by new-multisig-wallet.fif and gets n .pk files [ file-base-1.pk, file-base-2.pk ... file-base-n.pk ]
one .addr file and file-base-query.boc that must be sended to blockchain.

After that .pk files must be sent to other owners of this wallet or other devices.

When someone wants to send grams -- launch new-multisig-transaction.fif and generate .trans file. This file you can send to other owners with email or messengers. They launch sign-transaction.fif and signs transaction with own key and after k signatures sign transaction(you can view it with transaction-info.fif ) launch  generate-mutlisig-query.fif this script transforms .trans into .boc, you can view stored info in multisig-query-info.fif.

After that you send .boc file to blockchain and grams goes where they need)
1
PROGRAMMER SIDE:

First of all .pk files that used in multisig has some difference with .pk in simple wallet. .pk file has not only a private key but also the id of this key (1,2 ... n). In TonUtil.fif you can find additional functions to work with this.

What the difference between .trans and .boc? .boc has seqno and signatures sorted from 1 to n (thats helps smartcontract in finding signature duplicates).

How signatures/keys/data stored? we have root cell with transaction info and reference to signatures-cell. signatures-cell has 4 references
1 -- next signature-cell s 2-4 cells with data-cell (signature, public key, id(1, 2 ... n) or in case of data it's public keys and ids). This structure easy for understanding and parsing.
1
How smartcontract validate signature? First step: take signature and check it with public key stored in one cell with signature.
Second step: if check returns true take id of public key and searches in data for public key with same id.
Third step: compare public key from message with public key from data if it's equal -- signature is valid
1
This code was written in 20 hours. So I don't have enough time to make it properly. I don't hav usage info about the script. Also, I forgot about smartcontract get methods, and smartcontract may not work properly... But all other stuff works pretty nice.
1
PROBLEM: when I'm trying to get public key from data func says next:

Assertion failed: (i >= 0 && i < depth() && "invalid stack reference"), function validate, file /Users/vlad/lite-client/crypto/func/func.h, line 1351.
Abort trap: 6

I don't know what's this and why it doesn't work... Maybe it's func bug... I don't know... But I spent 2 or 3 hours(from that 20 hours) trying to fix it but... it's still doesn't work.

Try to uncomment throw_unless 38 and you will see this.

And with this thing I can't validate signature.
1
You have not added any comments yet...
by rating

Issues

Magic Python Nov 4, 2019 at 10:57
plus:
An interesting data structure is used for keys and for signatures.

minus:
Do not support partially signed queries.
Not all features are implemented
Hash does not include seqno. So anyone may replay existing messages.
11
Giant Kangaroo Nov 4, 2019 at 11:58
Thanks for your feedback)))
SeqNo is never incremented or stored in contract storage.
1
Giant Kangaroo Oct 18, 2019 at 14:49
Lol, I forgot about this... :)
It seems that "partially signed orders" feature is not implemented.
1
You are signing outgoing messages only. I can send it is many times as I want without requiring others to sign it again.
Giant Kangaroo Oct 24, 2019 at 07:50
What do you mean by "without requiring others to sign it again"? Do you mean that you can generate .trans, ask other owners to sign it and after that send it as many time as you want? But what about expiration time? After .trans expiration you can't send it to blockchain
Magic Python Oct 22, 2019 at 13:37
Can't create wallet with n=16, k=10. Probably accept_message is called too late.
It gets worse. Members sign [wc, address, amount] only which is not related to actual trans, not even seqno is signed. I can simply take previous message. Set correct seqno, expiration, leave wc, address, amount, and signatures intact to pass signature counter, and set any trans that I like.
Nobody added any issues yet...