create account

A simple function to validate username and private key couples by emrebeyler

View this thread on: hive.blogpeakd.comecency.com
· @emrebeyler · (edited)
$2.89
A simple function to validate username and private key couples
```python

from beem.steem import Steem
from beemgraphenebase.account import PrivateKey

def validate_private_key(steem_instance, account, private_key):
    try:
        public_key = str(PrivateKey(private_key).pubkey)
    except ValueError as e:
        if 'Base58' in e.args[0]:
                raise ValueError("Invalid private key")
        raise

    accounts = steem_instance.wallet.getAccountsFromPublicKey(str(public_key))
    if not account in accounts:
        raise ValueError("Invalid private key")

if __name__ == '__main__':
    s = Steem(node=["https://api.steemit.com"])
    validate_private_key(s, '<steem_username>', '<private_key>')
```
***

This example uses Beem library but it's possible with every client/library. You need to utilize the ```get_key_references``` [call](http://steem.readthedocs.io/en/latest/steem.html#steem.steemd.Steemd.get_key_references) on steem nodes.
👍  , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , and 112 others
properties (23)
authoremrebeyler
permlinka-simple-function-to-validate-username-and-private-key-couples
categorysteem
json_metadata{"community":"busy","app":"busy/2.5.4","format":"markdown","tags":["steem","python","beem","busy"],"users":[],"links":["http://steem.readthedocs.io/en/latest/steem.html#steem.steemd.Steemd.get_key_references"],"image":[]}
created2018-07-31 11:57:21
last_update2018-07-31 11:58:06
depth0
children3
last_payout2018-08-07 11:57:21
cashout_time1969-12-31 23:59:59
total_payout_value2.552 HBD
curator_payout_value0.338 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length897
author_reputation448,528,959,341,273
root_title"A simple function to validate username and private key couples"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id66,629,505
net_rshares1,696,653,754,539
author_curate_reward""
vote details (176)
@leprechaun ·
I recently discovered how to sign in Javascript and verify in Beem, thus allowing Steem logins without SteemConnect.  Private keys do not go to the server but the private key is proven to exist via the signature
[![](https://steemitimages.com/100x200/https://cdn.steemitimages.com/DQmUzRYDJKhwo4D7CQwTPXWfQiJ6gamdkNcpHHvFna9LtyF/sign-in-javascript-verify-in-beem.png) August 6th : Sign in Steem-JS, verify in Beem!](https://steemit.com/steemdev/@leprechaun/sign-in-javascript-validate-in-beem-journal-entry-for-2018-08-august-06)
properties (22)
authorleprechaun
permlinkre-emrebeyler-a-simple-function-to-validate-username-and-private-key-couples-20180806t171109228z
categorysteem
json_metadata{"tags":["steem"],"image":["https://steemitimages.com/100x200/https://cdn.steemitimages.com/DQmUzRYDJKhwo4D7CQwTPXWfQiJ6gamdkNcpHHvFna9LtyF/sign-in-javascript-verify-in-beem.png"],"links":["https://steemit.com/steemdev/@leprechaun/sign-in-javascript-validate-in-beem-journal-entry-for-2018-08-august-06"],"app":"steemit/0.1"}
created2018-08-06 17:11:12
last_update2018-08-06 17:11:12
depth1
children2
last_payout2018-08-13 17:11:12
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length529
author_reputation42,996,623,841,345
root_title"A simple function to validate username and private key couples"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id67,319,399
net_rshares0
@emrebeyler ·
Long time, no see mr. Lepre.
properties (22)
authoremrebeyler
permlinkre-leprechaun-re-emrebeyler-a-simple-function-to-validate-username-and-private-key-couples-20180806t182606177z
categorysteem
json_metadata{"tags":["steem"],"app":"steemit/0.1"}
created2018-08-06 18:26:06
last_update2018-08-06 18:26:06
depth2
children1
last_payout2018-08-13 18:26:06
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length28
author_reputation448,528,959,341,273
root_title"A simple function to validate username and private key couples"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id67,326,325
net_rshares0
@leprechaun ·
$0.25
Yes, I have to focus on earning money and blogging on Steemit had not been working out.  So, I don't post often now.
👍  
properties (23)
authorleprechaun
permlinkre-emrebeyler-re-leprechaun-re-emrebeyler-a-simple-function-to-validate-username-and-private-key-couples-20180808t113712574z
categorysteem
json_metadata{"tags":["steem"],"app":"steemit/0.1"}
created2018-08-08 11:37:15
last_update2018-08-08 11:37:15
depth3
children0
last_payout2018-08-15 11:37:15
cashout_time1969-12-31 23:59:59
total_payout_value0.249 HBD
curator_payout_value0.005 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length116
author_reputation42,996,623,841,345
root_title"A simple function to validate username and private key couples"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id67,516,767
net_rshares176,959,779,610
author_curate_reward""
vote details (1)