Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Polarbear produces signature result which is different from "cetcli tx sign" #1

Open
ngugcx opened this issue Jun 1, 2020 · 1 comment
Assignees

Comments

@ngugcx
Copy link

ngugcx commented Jun 1, 2020

OS: Ubuntu 16.04.
Two issues:

  • Polarbear produces signature result which is different from "cetcli tx sign"
  • Polarbear produces different signature results with the same input.

The following python3 code can reproduce the issues on Ubuntu 16.04.

secret = 'xxxxxxxxx'
chain_id = 'coinexdex2'

# init wallet
import ctypes
from pathlib import Path
home = str(Path.home())
path = '{}/.cetcli/keys'.format(home)
lib = ctypes.CDLL('/home/ubuntu/exchanges-res/coinexdex/polarbear/sdkforpython/wallet_linux.so')
# lib = ctypes.CDLL('/home/ubuntu/exchanges-res/coinexdex/polarbear/wallet.so')
lib.BearInit(path.encode('utf-8'))
key_name = '0a542970-9fc7-11ea-a52f-00163e024c1c'

# get account_number and sequence
account_number = '339981'
sequence = '3' 

# sign and broadcast
sign = lib.SignAndBuildBroadcast
sign.restype = ctypes.c_char_p

unsigned_tx_bytes = '{"type":"cosmos-sdk/StdTx","value":{"msg":[{"type":"bankx/MsgSend","value":{"from_address":"coinexxxxxxxxxxxxx","to_address":"coinexyyyyyy","amount":[{"denom":"cet","amount":"100000000"}],"unlock_time":"0"}}],"fee":{"amount":[{"denom":"cet","amount":"4000000"}],"gas":"200000"},"signatures":null,"memo":""}}'.encode('utf-8')
print('to_sign', unsigned_tx_bytes)
bz = sign(key_name.encode('utf-8'), secret.encode('utf-8'), unsigned_tx_bytes, chain_id.encode('utf-8'),
          'block'.encode('utf-8'), int(account_number), int(sequence))
print('signed', bz)
@ngugcx
Copy link
Author

ngugcx commented Jun 1, 2020

It works OK on Ubuntu 18.04.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants