5. Command: key

5.1. Command: key new

Generate new mitum keypair (privatekey and publickey)

$ ./mitum-example key new --help
 Usage: a key new [<seed>]

 generate new key

 Arguments:
   [<seed>]    seed for generating key

 Flags:
   -h, --help    Show context-sensitive help.

 logging
   --log.out="stderr"         log output file: {stdout, stderr, <file>}
   --log.format="terminal"    log format: {json, terminal}
   --log.level=debug          log level: {trace, debug, info, warn, error}
   --[no-]log.force-color     log force color


$ ./mitum-example key new
 {
   "privatekey": "EGGQu4bCWDy1p4RhEZCdE7vP4hP1UeN2jS8U8s7zAomhmpr",
   "publickey": "29Zrw2ZgWyeeHapnxc6cU8D19f5exjqkB4Mk2Bc2ACYyrmpu",
   "hint": "mpr-v0.0.1",
   "seed": "",
   "type": "privatekey"
 }

5.1.1. Arguments

  • seed

    Optional. With seed string, new kepair is generated from seed. As you expected, same seed will generated same keypair.

    Without seed, different keypair will be generated in each time.

5.2. Command: key load

Load mitum key (privatekey or publickey) and validate it.

$ ./mitum-example key load --help
 Usage: a key load <key string>

 load key

 Arguments:
   <key string>    key string

 Flags:
   -h, --help    Show context-sensitive help.

 logging
   --log.out="stderr"         log output file: {stdout, stderr, <file>}
   --log.format="terminal"    log format: {json, terminal}
   --log.level=debug          log level: {trace, debug, info, warn, error}
   --[no-]log.force-color     log force color

# load the privatekey, EGGQu4bCWDy1p4RhEZCdE7vP4hP1UeN2jS8U8s7zAomhmpr
$ ./mitum-example key load EGGQu4bCWDy1p4RhEZCdE7vP4hP1UeN2jS8U8s7zAomhmpr
 {
   "privatekey": "EGGQu4bCWDy1p4RhEZCdE7vP4hP1UeN2jS8U8s7zAomhmpr",
   "publickey": "29Zrw2ZgWyeeHapnxc6cU8D19f5exjqkB4Mk2Bc2ACYyrmpu",
   "hint": "mpr-v0.0.1",
   "string": "EGGQu4bCWDy1p4RhEZCdE7vP4hP1UeN2jS8U8s7zAomhmpr",
   "type": "privatekey"
 }

# load the publickey, 29Zrw2ZgWyeeHapnxc6cU8D19f5exjqkB4Mk2Bc2ACYyrmpu
$ ./mitum-example key load 29Zrw2ZgWyeeHapnxc6cU8D19f5exjqkB4Mk2Bc2ACYyrmpu
 {
   "publickey": "29Zrw2ZgWyeeHapnxc6cU8D19f5exjqkB4Mk2Bc2ACYyrmpu",
   "hint": "mpu-v0.0.1",
   "string": "29Zrw2ZgWyeeHapnxc6cU8D19f5exjqkB4Mk2Bc2ACYyrmpu",
   "type": "publickey"
 }

5.2.1. Arguments

  • key string

    Load key, parse and validate it. Key can be privatekey or publickey.

5.3. Command: key sign

Sign message by the given privatekey

$ ./mitum-example key sign --help
 Usage: a key sign <privatekey> <network-id> <body>

 sign

 Arguments:
   <privatekey>    privatekey string
   <network-id>    network-id
   <body>          body

 Flags:
   -h, --help                 Show context-sensitive help.

       --node=ADDRESS-FLAG    node address
       --token=STRING         set fact token

 logging
   --log.out="stderr"         log output file: {stdout, stderr, <file>}
   --log.format="terminal"    log format: {json, terminal}
   --log.level=debug          log level: {trace, debug, info, warn, error}
   --[no-]log.force-color     log force color


# suffrage-candidate-no1sas.json is the oparation to be signed
$ cat ./suffrage-candidate-no1sas.json
 {
   "fact": {
     "address": "no1sas",
     "publickey": "25AZEiKTPhNkpcj6B1mofXHFyJRR8DaEMcNjc2WSvvW8Jmpu",
     "token": "6qLkX1LfSXejcuzijomt+w==",
     "_hint": "suffrage-candidate-fact-v0.0.1"
   },
   "_hint": "suffrage-candidate-operation-v0.0.1"
 }

# sign by the privatekey, CaSheUmWGeAYgAKwnwdYrDuJ5fkr2wsVXSpmGFTEUpYtmpr
$ ./mitum-example key sign \
    CaSheUmWGeAYgAKwnwdYrDuJ5fkr2wsVXSpmGFTEUpYtmpr \
    "mitum; Sat 26 Dec 2020 05:29:13 AM KST" \
    ./suffrage-candidate-no1sas.json \
    --node no1sas \
    --token findme
 {
   "hash": "9PJgJA17dtCiGkTDRTFaK1fLiD3zbPYTNrYDpQhzMcYg",
   "fact": {
     "address": "no1sas",
     "publickey": "25AZEiKTPhNkpcj6B1mofXHFyJRR8DaEMcNjc2WSvvW8Jmpu",
     "hash": "GxhAT8KoWyS8E9d1zM47c5anGrNFC8XiCwWEuAdtSexZ",
     "token": "ZmluZG1l",
     "_hint": "suffrage-candidate-fact-v0.0.1"
   },
   "signed": [
     {
       "node": "no1sas",
       "signed_at": "2022-08-07T04:00:45.499676834Z",
       "signer": "25AZEiKTPhNkpcj6B1mofXHFyJRR8DaEMcNjc2WSvvW8Jmpu",
       "signature": "AN1rKvtAWGE3APxii4jFfe6gzkTBAhqpQiMcLKKQJuSrWRgjGuMUsnG4aspLs3yJbsYgtkpsBLteVTn2vi4LhVn95GRubtWqf"
     }
   ],
   "_hint": "suffrage-candidate-operation-v0.0.1"
 }

5.3.1. Arguments

  • privatekey

    Privatekey for signing

  • network-id

    *Network ID for signing

  • body

    Message body to be signed

5.3.2. Flags

  • node

    Some message needs to be signed with node address

  • token

    Update token of operation