Developing Key Box : Journal Entry for 2018 03(March) 13

in #steemdev6 years ago

March 13th, 2018

In this developer's journal of Keybox:

  • The importance of Source control
  • The trickyness of showing the Public Keys
  • The politics of Development

The importance of Source Control

I was offered all kinds of changes so that my keybox.py program would be able to work with beem without having to create the steem object for each call. just in case though before making changes I did this:

cp keybox.py keybox-monday.py

This is source control. Probably the most primitive ignorant way to do source control is to use cp or copy. There are much more feature ways to do it but it is better than nothing.

After making the recommended changes I found my software just didn't work anymore. So, I went like this: cp keybox-monday.py keybox.py.

Actual software packages. The software change control options in order of ease of use are: Subversion, Mercurial and finally Git. It maybe that it is more familiarity that I choose Mercurial over Subversion because I used to use it alot for some project. Eventually, git will become familiar and I will want to use that over whatever is newer and in fashion I suppose.

The trickyness of showing Public Keys

My struggle was an attempt to create a show function to show the private keys.

        elif command[0] == 'show':
            try:
                action = gerund_to_system(command[1])
                password_key = PasswordKey(password)
                
                account_info = osteem.get_account(user)
                authority = account_info[action]                
                if action is None:
                    print("Following set should be one of: posting, activating, or owning")
                    return True

                if not (str(password_key.get_public()) in [key[0] for key in authority['key_auths']]):
                    print("Not the correct key")
                
                print(private_key)

This routine works well on mainnet Steem but it fails on testnet. This is a kind of problem while using these libraries I hope that the testnet works more or less the same as mainnet. If I test everything on testnet and things work but do not work in mainnet, then we have a big problem. I fear the testnet will not go to 19.4 when the rest of the network moves up to 19.4 en masse.

Instead of password_key.get_public() == authority['key_auths'][0] I used str(password_key.get_public()) in [key[0] for key in authority['key_auths']]. I needed to convert the public key to a string explicitly or it would not match. I use the in operator because an account could have more than one private/public key pair for spending. There are interesting applications here, I will exploit.

The thing is I needed to go look at the source of PasswordKey and see how it called PrivateKey() in order to see that it wasn't using the blockchain prefix of the connected node. So, by inlinining that code and adding the prefix parameter I got:

        elif command[0] == 'show':
            try:
                action = gerund_to_system(command[1])
                a = bytes(user + action + password, 'utf8')
                s = hashlib.sha256(a).digest()
                private_key = PrivateKey(hexlify(s).decode('ascii'), prefix=pubkey_prefix)
                
                account_info = osteem.get_account(user)
                authority = account_info[action]                
                if action is None:
                    print("Following set should be one of: posting, activating, or owning")
                    return True

                if pubkey_prefix != 'STM':
                    print("Unable to derive public key on testnet")
                if not (str(private_key.pubkey) in [key[0] for key in authority['key_auths']]):
                    print("Not the correct key")
                
                print(private_key)
                    
            except KeyError:
                print("Not enough arguments to show")
                return True

The Politics of Development

Whereas some developers get multiple hundreds of dollars for each post, I get measily pennies. I must incentive voting. While Utopian approves basic Python tutorials, I write something that truly is missing from the users that have 32-bit machines and my post doesn't get approved. That's just how it goes. There is no point in me flagging Utopian comments with my 8¢ flags! Occasionaly Utopian rewards some what parthy rewards but better than I am used to. There are other economic models that could work out better.

Previous Journal Entries:

Dash XjzjT4mr4f7T3E8G9jQQzozTgA2J1ehMkV
LTC LLXj1ZPQPaBA1LFtoU1Gkvu5ZrxYzeLGKt
BitcoinCash 1KVqnW7wZwn2cWbrXmSxsrzqYVC5Wj836u
Bitcoin 1Q1WX5gVPKxJKoQXF6pNNZmstWLR87ityw (too expensive to use for tips)

See also


Sort:  

Check my last post on steem currency :) and if you had profit on my advice, offer me an upvote ;)

I am not terribly interested in trying to trade my way up to money but first I want to provide a second factor to those who are not so careful with their keys. My compensation can be with votes of my regular posts or just by charging a flat fee.

Why is everything plummetting?

I wasn't serious about upvote! Anyone who liked a content genuinly upvotes it :)

The market is technically responding to customers' behaivor. This is the best thing happens. It means crypto market is getting mature in fluctuations and this makes risks measurable.

Coin Marketplace

STEEM 0.17
TRX 0.13
JST 0.027
BTC 61263.81
ETH 2676.81
USDT 1.00
SBD 2.59