Table of Contents
- About Keychain
- Usage
- Operations
- hive_keychain
- requestHandshake
- requestEncodeMessage
- requestVerifyKey
- requestSignBuffer
- requestAddAccountAuthority
- requestRemoveAccountAuthority
- requestAddKeyAuthority
- requestRemoveKeyAuthority
- requestBroadcast
- requestSignTx
- requestSignedCall
- requestPost
- requestVote
- requestCustomJson
- requestTransfer
- requestSendToken
- requestDelegation
- requestWitnessVote
- requestProxy
- requestPowerUp
- requestPowerDown
- requestCreateClaimedAccount
- requestCreateProposal
- requestRemoveProposal
- requestUpdateProposalVote
- requestAddAccount
- requestConversion
- requestRecurrentTransfer
- hive_keychain
About Keychain
Putting private keys directly into websites is not safe or secure, even ones run by reputable community members. Yet this is currently how nearly every Hive-based site or service currently works. On top of that, most Hive users likely use their master password which is even worse.
The Vessel desktop wallet software is a secure alternative, but it is too difficult to use for the majority of Hive users and does not easily interact with websites - which is Hive's primary use case.
On Ethereum, you never have to enter your private key into a website to use a dApp. You can just use a browser extension like Metamask, which dApp websites can interface with to securely store your keys and broadcast transactions to the blockchain.
Hive Keychain aims to bring the security and ease-of-use of Metamask to the Hive blockchain platform.
Installation
You can download and install the latest published version of the extension for the following browsers:
- Google Chrome (or Opera/Brave): [on Chrome Store][62]
- Export your keys from Steem keychain (in settings)
- Download this repository as zip
- Unzip the downloaded folder
- Right click on any existing extension > Manage my extensions.
- Activate developer mode.
- Click "Load Unpacked" and select the unzipped folder.
- Import your keys (use the same master password)
- Firefox: [on Firefox Addon Store][63]
Features
The Hive Keychain extension includes the following features:
- Store an unlimited number of Hive account keys, encrypted with AES
- View balances, transaction history, voting power, and resource credits
- Send HIVE and HBD transfers, manage witness votes, and update HP delegation right from the extension
- Manage your Hive Engine tokens
- Power up or down
- Securely interact with Hive-based websites that have integrated with Hive Keychain
- Manage transaction confirmation preferences by account and by website
- Locks automatically on browser shutdown or manually using the lock button
Website Integration
Websites can currently request the Hive Keychain extension to perform the following functions / broadcast operations:
- Send a handshake to make sure the extension is installed
- Decrypt a message encrypted by a Hive account private key (commonly used for "logging in")
- Post a comment (top level or reply)
- Broadcast a vote
- Broadcast a custom JSON operation
- Send a transfer
- Send Hive Engine tokens
- Send Delegations
- Power up/down
- Vote for witnesses
- Create/Remove/Vote for proposals
- Create claimed accounts
- Sign Tx
Usage
Example
An example of a web page that interacts with the extension is included in the "example" folder in the repo. You can test it by running a local HTTP server and going to http://localhost:1337/main.html in your browser.
cd example
python -m http.server 1337 //or any other method to run a static server
NOTE: On localhost, it will run on port 1337.
Using Keychain for logins
To login, you can encode a message from your backend and verify that the user can decode it using the requestVerifyKey
method.
See an example in this project by @howo (@steempress witness):
Alternatively, you can use requestSignTx
and verify the signature on your backend.
@hiveio/keychain
This npm module makes it easy to add Keychain support within the browser. It also includes helpful functions to check whether Keychain was used before. It was developed by @therealwolf (witness).
Operations
The Hive Keychain extension will inject a "hive_keychain" JavaScript into all web pages opened in the browser while the extension is running. You can therefore check if the current user has the extension installed using the following code:
hive_keychain
Use the hive_keychain
methods listed below to issue requests to the Hive blockchain.
requestHandshake
This function is called to verify Keychain installation on a user's device
Parameters
callback
function Confirms Keychain installation
requestEncodeMessage
This function is called to verify that the user has a certain authority over an account, by requesting to decode a message
Parameters
username
String Hive account to perform the requestreceiver
String Account that will decode the stringmessage
String Message to be encryptedkey
String Type of key. Can be 'Posting','Active' or 'Memo'callback
function Keychain's response to the requestrpc
String Override user's RPC settings (optional, defaultnull
)
requestVerifyKey
This function is called to verify that the user has a certain authority over an account, by requesting to decode a message
Parameters
account
String Hive account to perform the requestmessage
String Message to be decoded by the accountkey
String Type of key. Can be 'Posting','Active' or 'Memo'callback
function Keychain's response to the requestrpc
String Override user's RPC settings (optional, defaultnull
)
requestSignBuffer
Requests a message to be signed with proper authority
Parameters
account
String Hive account to perform the request. If null, user can choose the account from a dropdown (optional, defaultnull
)message
String Message to be signed by the accountkey
String Type of key. Can be 'Posting','Active' or 'Memo'callback
function Keychain's response to the requestrpc
String Override user's RPC settings (optional, defaultnull
)title
String Override "Sign message" title (optional, defaultnull
)
requestAddAccountAuthority
Requests to add account authority over another account. For more information about multisig, please read https://peakd.com/utopian-io/@stoodkev/how-to-set-up-and-use-multisignature-accounts-on-steem-blockchain
Parameters
account
String Hive account to perform the requestauthorizedUsername
String Authorized accountrole
String Type of authority. Can be 'Posting','Active' or 'Memo'weight
number Weight of the authoritycallback
function Keychain's response to the requestrpc
String Override user's RPC settings (optional, defaultnull
)
requestRemoveAccountAuthority
Requests to remove an account authority over another account. For more information about multisig, please read https://peakd.com/utopian-io/@stoodkev/how-to-set-up-and-use-multisignature-accounts-on-steem-blockchain
Parameters
account
String Hive account to perform the requestauthorizedUsername
String Account to lose authorityrole
String Type of authority. Can be 'Posting','Active' or 'Memo'callback
function Keychain's response to the requestrpc
String Override user's RPC settings (optional, defaultnull
)
requestAddKeyAuthority
Requests to add a new key authority to an account. For more information about multisig, please read https://peakd.com/utopian-io/@stoodkev/how-to-set-up-and-use-multisignature-accounts-on-steem-blockchain
Parameters
account
String Hive account to perform the requestauthorizedKey
String New public key to be associated with the accountrole
String Type of authority. Can be 'Posting','Active' or 'Memo'weight
number Weight of the key authoritycallback
function Keychain's response to the requestrpc
String Override user's RPC settings (optional, defaultnull
)
requestRemoveKeyAuthority
Requests to remove a key to an account. For more information about multisig, please read https://peakd.com/utopian-io/@stoodkev/how-to-set-up-and-use-multisignature-accounts-on-steem-blockchain
Parameters
account
String Hive account to perform the requestauthorizedKey
String Key to be removed (public key).role
String Type of authority. Can be 'Posting','Active' or 'Memo'.callback
function Keychain's response to the requestrpc
String Override user's RPC settings (optional, defaultnull
)
requestBroadcast
Generic broadcast request
Parameters
account
String Hive account to perform the requestoperations
Array Array of operations to be broadcastedkey
String Type of key. Can be 'Posting','Active' or 'Memo'callback
function Keychain's response to the requestrpc
String Override user's RPC settings (optional, defaultnull
)
requestSignTx
Requests to sign a transaction with a given authority
Parameters
account
String Hive account to perform the requesttx
Object Unsigned transactionkey
String Type of key. Can be 'Posting','Active' or 'Memo'callback
function Keychain's response to the requestrpc
String Override user's RPC settings (optional, defaultnull
)
requestSignedCall
Requests a signed call
Parameters
account
String Hive account to perform the requestmethod
String Method of the callparams
String Parameters of the callkey
String Type of key. Can be 'Posting','Active' or 'Memo'callback
function Keychain's response to the requestrpc
String Override user's RPC settings (optional, defaultnull
)
requestPost
Requests to broadcast a blog post/comment
Parameters
account
String Hive account to perform the requesttitle
String Title of the blog postbody
String Content of the blog postparent_perm
String Permlink of the parent post. Main tag for a root postparent_account
String Author of the parent post. Pass null for root postjson_metadata
Object Parameters of the callpermlink
String Permlink of the blog postcomment_options
Object Options attached to the blog post. Consult Hive documentation to learn more about itcallback
function Keychain's response to the requestrpc
String Override user's RPC settings (optional, defaultnull
)
requestVote
Requests a vote
Parameters
account
String Hive account to perform the requestpermlink
String Permlink of the blog postauthor
String Author of the blog postweight
Number Weight of the vote, comprised between -10,000 (-100%) and 10,000 (100%)callback
function Keychain's response to the requestrpc
String Override user's RPC settings (optional, defaultnull
)
requestCustomJson
Requests a custom JSON broadcast
Parameters
account
String Hive account to perform the request. If null, user can choose the account from a dropdown (optional, defaultnull
)id
String Type of custom_json to be broadcastedkey
String Type of key. Can be 'Posting','Active' or 'Memo'json
String Stringified custom jsondisplay_msg
String Message to display to explain to the user what this broadcast is aboutcallback
function Keychain's response to the requestrpc
String Override user's RPC settings (optional, defaultnull
)
requestTransfer
Requests a transfer
Parameters
account
String Hive account to perform the requestto
String Hive account to receive the transferamount
String Amount to be transfered. Requires 3 decimals.memo
String The memo will be automatically encrypted if starting by '#' and the memo key is available on Keychain. It will also overrule the account to be enforced, regardless of the 'enforce' parametercurrency
String 'HIVE' or 'HBD'callback
function Keychain's response to the requestenforce
boolean If set to true, user cannot chose to make the transfer from another account (optional, defaultfalse
)rpc
String Override user's RPC settings (optional, defaultnull
)
requestSendToken
Requests a token transfer
Parameters
account
String Hive account to perform the requestto
String Hive account to receive the transferamount
String Amount to be transfered. Requires 3 decimals.memo
String Memo attached to the transfercurrency
String Token to be sentcallback
function Keychain's response to the requestrpc
String Override user's RPC settings (optional, defaultnull
)
requestDelegation
Requests a delegation broadcast
Parameters
username
delegatee
String Account to receive the delegationamount
String Amount to be transfered. Requires 3 decimals for HP, 6 for VESTS.unit
String HP or VESTScallback
function Keychain's response to the requestrpc
String Override user's RPC settings (optional, defaultnull
)account
String Hive account to perform the request. If null, user can choose the account from a dropdown (optional, defaultnull
)
requestWitnessVote
Requests a witness vote broadcast
Parameters
username
witness
String Account to receive the witness votevote
boolean Set to true to vote for the witness, false to unvotecallback
function Keychain's response to the requestrpc
String Override user's RPC settings (optional, defaultnull
)account
String Hive account to perform the request. If null, user can choose the account from a dropdown (optional, defaultnull
)
requestProxy
Select an account as proxy
Parameters
username
proxy
String Account to become the proxy. Empty string ('') to remove a proxycallback
function Keychain's response to the requestrpc
String Override user's RPC settings (optional, defaultnull
)account
String Hive account to perform the request. If null, user can choose the account from a dropdown (optional, defaultnull
)
requestPowerUp
Request a power up
Parameters
username
String Hive account to perform the requestrecipient
String Account to receive the power uphive
String Amount of HIVE to be powered upcallback
function Keychain's response to the requestrpc
String Override user's RPC settings (optional, defaultnull
)
requestPowerDown
Request a power down
Parameters
username
String Hive account to perform the requesthive_power
String Amount of HIVE to be powered downcallback
function Keychain's response to the requestrpc
String Override user's RPC settings (optional, defaultnull
)
requestCreateClaimedAccount
Request the creation of an account using claimed tokens
Parameters
username
String Hive account to perform the requestnew_account
String New account to be createdowner
object owner authority objectactive
object active authority objectposting
object posting authority objectmemo
String public memo keycallback
function Keychain's response to the requestrpc
String Override user's RPC settings (optional, defaultnull
)
requestCreateProposal
Request the creation of a DHF proposal
Parameters
username
String Hive account to perform the requestreceiver
String Account receiving the funding if the proposal is votedsubject
String Title of the DAOpermlink
String Permlink to the proposal descriptiondaily_pay
String Daily amount to be received byreceiver
start
String Starting dateend
String Ending dateextensions
String Stringified Array of extensionscallback
function Keychain's response to the requestrpc
String Override user's RPC settings (optional, defaultnull
)
requestRemoveProposal
Request the removal of a DHF proposal
Parameters
username
String Hive account to perform the requestproposal_ids
String Stringified Array of ids of the proposals to be removedextensions
String Stringified Array of extensionscallback
function Keychain's response to the requestrpc
String Override user's RPC settings (optional, defaultnull
)
requestUpdateProposalVote
Vote/Unvote a DHF proposal
Parameters
username
String Hive account to perform the requestproposal_ids
String Stringified Array of Ids of the proposals to be votedapprove
boolean Set to true to support the proposal, false to remove a voteextensions
String Stringified Array of extensionscallback
function Keychain's response to the requestrpc
String Override user's RPC settings (optional, defaultnull
)
requestAddAccount
Add a new account to Keychain
Parameters
username
String username of the account to be addedkeys
Object private keys of the account : {active:'...',posting:'...',memo:'...'}. At least one must be specified.callback
requestConversion
Request currency conversion
Parameters
username
String Hive account to perform the requestamount
String amount to be converted.collaterized
Boolean true to convert HIVE to HBD. false to convert HBD to HIVE.callback
function Keychain's response to the requestrpc
String Override user's RPC settings (optional, defaultnull
)
requestRecurrentTransfer
Request recurrent transfer
Parameters
username
String Hive account to perform the request (optional, defaultnull
)to
String Hive account receiving the transfers.amount
String amount to be sent on each execution.currency
String HIVE or HBD on mainnet.memo
String transfer memorecurrence
Number How often will the payment be triggered (in hours).executions
Number The times the recurrent payment will be executed.callback
function Keychain's response to the requestrpc
String Override user's RPC settings (optional, defaultnull
)
[62]:
[63]: