cryptonomex / graphene-ui

Cryptonomex Graphene front end (wallet and decentralized exchange)
https://bitshares.openledger.info
MIT License
156 stars 100 forks source link

Missing Active Authority while adding active authority #795

Closed abitmore closed 8 years ago

abitmore commented 8 years ago

This is a re-post of https://github.com/cryptonomex/graphene/issues/630, since it can be solved in GUI alone.

Exception Missing Active Authority is reported while trying to add TEST56ankGHKf6qUsQe7vPsXTSEqST6Dt1ff73aV3YQbedzRua8NLQ as another active key authority to http://testnet.bitshares.eu/#/account/testaccount1/permissions/, even if threshold set to 1 and weight of all keys set to 1. Private key of the new new public key is 5K9piFpyJ15zcYBc4R3gAeLFYb6PuRFEiDCbzLkSL9C4d7fWLyB.

Original key pairs of that account:

It turns out that the transaction which contains multiple key authorities and signed by GUI is rejected by witness_node.

As @theoreticalbts commented in https://github.com/cryptonomex/graphene/issues/630#issuecomment-199950145 and https://github.com/cryptonomex/graphene/issues/630#issuecomment-199981206, the issue can be fixed in GUI:

the key_auths are sorted when this structure is serialized. So if the GUI isn't using the same sorting as the C++, it's not going to accept the sig.

The currently used sorting mechanism is to convert the keys to addresses, then sort by address. Addresses themselves are sorted by hex value.

The branch https://github.com/cryptonomex/graphene/commit/38a0f3a9a4e611d806342e77632e1b58a1172c56 implements a sort-keys binary which creates 100 public keys and sorts them. The GUI should work if it sorts the keys in the same order. Sorting consists of converting the keys to addresses, converting the addresses to hex and then sorting the hex values. Addresses should be sorted the same way for address_auths.

abitmore commented 8 years ago

To be clearer, the method to convert a public key to address is:

       auto dat = pub.serialize();
       addr = fc::ripemd160::hash( fc::sha512::hash( dat.data, sizeof( dat ) ) );
jcalfee commented 8 years ago

The master and the stealth branch will sort public keys by the address. Sample data from @theoreticalbts's sort-keys program was used in our unit test to show the sorting is not alphabetical but instead by address..

abitmore commented 8 years ago

@jcalfee I think this code need to be reverted (addresses should be sorted in ascending order)

jcalfee commented 8 years ago

Don't revert..I fixed it...

Sorry about all the messy diff, the atom spaces plugin goes crazy changing the whole file. I have disabled it.

svk31 commented 8 years ago

Confirmed to be working in current master.