bnb-chain / node-binary

Binaries for full nodes, light-weighted clients
180 stars 120 forks source link

tbnbcli ERROR: Key not found on TSS signature #306

Open fastchain opened 2 years ago

fastchain commented 2 years ago

Hello,

Using this instruction I've created script, that shares TSS secret, but when I'm trying to sign transaction with bnbcli, I get "Key not found" error.

Secret sharing

#!/bin/bash
rm -r ./tss_data/*
chan_pwd="123456789"
storage_pwd="123456789"
parties=3
threshold=2

for i in `seq 1 $parties`;
do
  ./tss init --vault_name 1 --password $storage_pwd --home ./tss_data/$i --kdf.iterations 13 --kdf.key_length 48  --kdf.memory 65536 --kdf.parallelism 4 --kdf.salt_length 16 --moniker v$i --p2p.listen  /ip4/127.0.0.1/tcp/3000$i  #--log_level debug
done

chan_id=$(./tss channel  --vault_name 1  --password $storage_pwd --home ./tss_data/$i --channel_expire 30 | grep ":" | awk '{print $3}')

echo $chan_id
for i in `seq 1 $parties`;
do
  ./tss describe --vault_name 1 --password $storage_pwd --home ./tss_data/$i
  ./tss keygen --vault_name 1 --password $storage_pwd --home ./tss_data/$i --address_prefix tst --channel_id $chan_id --channel_password $chan_pwd  --parties $parties --threshold $threshold &
done

Result of the script execution is the following data in bnbcli keystore

./tbnbcli keys list
NAME:   TYPE:   ADDRESS:                        PUBKEY:
tss_v1_1    tss tbnb1nl3e2xlqw8rwwqfznsyjw2pzazkeftmzud5y0h bnbp1addwnpepqdk4myeyv6sfvfkw5zvlvhq3t9ynncj4gdjhd2nfl55zhu3562hcc4c88d3
tss_v2_1    tss tbnb1nl3e2xlqw8rwwqfznsyjw2pzazkeftmzud5y0h bnbp1addwnpepqdk4myeyv6sfvfkw5zvlvhq3t9ynncj4gdjhd2nfl55zhu3562hcc4c88d3
tss_v3_1    tss tbnb1nl3e2xlqw8rwwqfznsyjw2pzazkeftmzud5y0h bnbp1addwnpepqdk4myeyv6sfvfkw5zvlvhq3t9ynncj4gdjhd2nfl55zhu3562hcc4c88d3

Thansaction

Then I create transaction to sign

./tbnbcli send  --generate-only  --chain-id Binance-Chain-Ganges  --amount 1000000:BNB --to tbnb1mh3w2kxmdmnvctt7t5nu7hhz9jnp422edqdw2d  --offline     > tnx.json

here it is

{"type":"auth/StdTx","value":{"msg":[{"type":"cosmos-sdk/Send","value":{"inputs":[{"address":"tbnb1nl3e2xlqw8rwwqfznsyjw2pzazkeftmzud5y0h","coins":[{"denom":"BNB","amount":"1000000"}]}],"outputs":[{"address":"tbnb1mh3w2kxmdmnvctt7t5nu7hhz9jnp422edqdw2d","coins":[{"denom":"BNB","amount":"1000000"}]}]}}],"signatures":null,"memo":"","source":"0","data":null}}

Signing

and when I'm trying to sign it with

./tbnbcli sign   --chain-id Binance-Chain-Ganges --tss --from tss_v1_1      tnx.json

I get ERROR: Key not found

With strace I can see, that bnbcli doesn't even trying to look into tss_data folder (with generated tss data), and fails at read operations in keys.db folder

....
newfstatat(AT_FDCWD, "/home/afx/.bnbcli/keys/keys.db/MANIFEST-000007", {st_mode=S_IFREG|0644, st_size=302, ...}, 0) = 0
openat(AT_FDCWD, "/home/afx/.bnbcli/keys/keys.db/MANIFEST-000007", O_RDONLY|O_CLOEXEC) = 5
epoll_ctl(4, EPOLL_CTL_ADD, 5, {events=EPOLLIN|EPOLLOUT|EPOLLRDHUP|EPOLLET, data={u32=4095059680, u64=140737288447712}}) = -1 EPERM (Operation not permitted)
epoll_ctl(4, EPOLL_CTL_DEL, 5, 0xc000e32c94) = -1 EPERM (Operation not permitted)
read(5, "y{\260)'\1\1\1\32leveldb.BytewiseCompara"..., 32768) = 302
read(5, "", 32466)                      = 0
close(5)                                = 0
openat(AT_FDCWD, "/home/afx/.bnbcli/keys/keys.db", O_RDONLY|O_CLOEXEC) = 5
epoll_ctl(4, EPOLL_CTL_ADD, 5, {events=EPOLLIN|EPOLLOUT|EPOLLRDHUP|EPOLLET, data={u32=4095059680, u64=140737288447712}}) = -1 EPERM (Operation not permitted)
epoll_ctl(4, EPOLL_CTL_DEL, 5, 0xc000e32bfc) = -1 EPERM (Operation not permitted)
getdents64(5, 0xc000988000 /* 10 entries */, 8192) = 296
getdents64(5, 0xc000988000 /* 0 entries */, 8192) = 0
close(5)                                = 0
openat(AT_FDCWD, "/home/afx/.bnbcli/keys/keys.db/000006.log", O_RDONLY|O_CLOEXEC) = 5
epoll_ctl(4, EPOLL_CTL_ADD, 5, {events=EPOLLIN|EPOLLOUT|EPOLLRDHUP|EPOLLET, data={u32=4095059680, u64=140737288447712}}) = -1 EPERM (Operation not permitted)
epoll_ctl(4, EPOLL_CTL_DEL, 5, 0xc000e32bf4) = -1 EPERM (Operation not permitted)
read(5, "\251w?\313d\0\1\7\0\0\0\0\0\0\0\1\0\0\0\1\rtss_v3_1.in"..., 32768) = 193
read(5, "", 32575)                      = 0
close(5)                                = 0
futex(0xc000e36148, FUTEX_WAKE_PRIVATE, 1) = 1
futex(0x2137780, FUTEX_WAKE_PRIVATE, 1) = 1
futex(0x2137760, FUTEX_WAKE_PRIVATE, 1) = 1
futex(0x2134268, FUTEX_WAIT_PRIVATE, 0, NULLERROR: Key  not found
) = ?
+++ exited with 1 +++

I can't figure out what is going on, since bnbcli sources are not available. Could you please explain what am I doing wrong and how can I generate tss signature for transaction.

Thank you!