Skip to content

KeyChain sample commands

Avvrik edited this page Dec 3, 2018 · 23 revisions

This is a shortcut to the commands that help you interact with KeyChain. You can find full comprehensive descriptions of all the commands in the Protocol.

Create command

// I have removed "cipher' parameter as a user does not need to state it explicitly as the parameter, keychain will decide it for the user, so that if someone writes an instruction how to use this parameter when creating key, another user would read the instruction when it gets outdated and choose an outdated cipher for securing her keys.
{
  "command": "create",
  "params":
   {
      "keyname": "test1",
      "encrypted": true,
      "curve": "secp256k1",
      "cipher": "aes256"
  }
}

Params curve and cipher are saved in the key file during creation. So later when the key file is used, compatibility of curve with kind is compared during sign, public_key commands, etc. List values of blockchain_type: bitshares, array, ethereum, bitcoin.

Sign transaction from hex form command

{
  "command": "sign_hex",
  "params":
  {
    "chainid": "de5f4d8974715e20f47c8bb609547c9e66b0b9e31d521199b3d8d6af6da74cb1",
    "transaction": "871689d060721b5cec5a010080841e00000000000011130065cd1d0000000000000000",
    "blockchain_type": "array",
    "keyname": "test1@be5f6e75878b84ba"
  }
}

Sign some hash (possible hash of transaction) command

{
  "command": "sign_hash",
  "params":
  {
    "sign_type": "VRS_canonical",//default RSV_noncanonical
    "hash": "fe5e4a8974715e20f47c8bb609547c9e66b0b9e31d521199b3d8d6af6da74cb1",
    "keyname": "test1@be5f6e75878b84ba"
  }
}

Parameter sign_type determines the signature structure and whether the signature is canonical. List of values sign_type: VRS_canonical , RSV_noncanonical - default value.

Prefix RSV/VRS means signature struct: [R, S, v] or [v, R, S]

List command

{
  "command": "list"
}

Remove command

{ 
  "command": "remove",
  "params": 
  {
    "keyname": "test1@be5f6e75878b84ba"
  }
}

Public_key command

{ 
  "command": "public_key",
  "params": 
  {
    "keyname": "test1@be5f6e75878b84ba"
  }
}

Set_unlock_time command

{
  "command": "set_unlock_time", 
  "params": 
  {
    "seconds": 100
  }
}

This command sets unlock time for unlocked keys. After passphrase entry the decrypted private key is stored in the memory during this time. Default unlock time = 0.

Unlock command

{  
  "command": "unlock", 
  "params": 
  { 
    "keyname": "test1@e08a1dee52cc68ee"
  }
}

Unlock private key. This allows to sign a transaction without passphrase entry. For this, you must first perform set_unlock_time command to set nonzero unlock time. Also, implicit unlocking will be performed after the commands sign_hex and sign_hash.

Lock command

{  
  "command": "lock"
}

Locks all unlocked keys.

Clone this wiki locally