Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add an option for selecting priv key type #125

Merged
merged 9 commits into from
Oct 12, 2020

Conversation

egonspace
Copy link
Contributor

@egonspace egonspace commented Oct 6, 2020

Closes: #XXX

Description

Added an option for selecting private key type on the tendermint init command.

Usage:

$ tendermint init --help
Initialize Tendermint

Usage:
  tendermint init [flags]

Flags:
  -h, --help                   help for init
      --priv_key_type string   Specify validator's private key type (ed25519 | composite) (default "ed25519")

Global Flags:
      --home string        directory for config and data (default "/Users/user/.tendermint")
      --log_level string   Log level (default "main:info,state:info,*:error")
      --trace              print out full stack trace on errors

$ tendermint init   ## create an ed25519 key by default

$ tendermint init --priv_key_type=ed25519
$ tendermint init --priv_key_type=composite

$ tendermint init --priv_key_type=ed25518
ERROR: undefined private key type: ed25518


For contributor use:

  • Wrote tests
  • Updated CHANGELOG_PENDING.md
  • Linked to Github issue with discussion and accepted design OR link to spec that describes this work.
  • Updated relevant documentation (docs/) and code comments
  • Re-reviewed Files changed in the Github PR explorer

@egonspace egonspace changed the base branch from feat/add_metric to develop October 6, 2020 08:23
@egonspace egonspace changed the base branch from develop to feat/add_metric October 6, 2020 08:30
privval/file.go Outdated
privKey := composite.NewPrivKeyComposite(signKey, vrfKey)
func GenFilePV(keyFilePath, stateFilePath, privKeyType string) (filePV *FilePV, err error) {
var privKey crypto.PrivKey
if strings.EqualFold(privKeyType, PrevKeyTypeEd25519) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[golangci] reported by reviewdog 🐶
ifElseChain: rewrite if-else to switch statement (gocritic)

privval/file.go Outdated
@@ -26,6 +27,11 @@ const (
stepPrecommit int8 = 3
)

const (
PrevKeyTypeEd25519 string = "ed25519"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[golangci] reported by reviewdog 🐶
File is not gofmt-ed with -s (gofmt)

@egonspace egonspace force-pushed the feat/select_val_key branch from 7a79261 to a5e6801 Compare October 7, 2020 08:31
@egonspace
Copy link
Contributor Author

About modifying of circleci config:
There was the error when we were building contract-tests with ubuntu20.10 in circleci

Hooks handler stderr: /home/circleci/.go_workspace/src/github.com/tendermint/tendermint/build/contract_tests: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.32' not found (required by /home/circleci/.go_workspace/src/github.com/tendermint/tendermint/build/contract_tests)

I don't know exactly why this error occurs, but it seems to be a problem that occurs probably because the shared library referenced by libc.so.6 in ubuntu20.10, an environment that builds contract-tests, is not present in the linux environment running contract-tests. To correct this, ubuntu19.10 was used.

@egonspace
Copy link
Contributor Author

I will switch the base branch from feat/add_metric to develop after feat/add_metric would be merged.

@egonspace egonspace requested review from torao and kukugi October 8, 2020 00:50
@egonspace egonspace self-assigned this Oct 8, 2020
@egonspace egonspace added the C: enhancement Classification: New feature or its request, or improvement in maintainability of code label Oct 8, 2020
@egonspace egonspace added this to the VRF election function test milestone Oct 8, 2020
@egonspace egonspace changed the base branch from feat/add_metric to develop October 8, 2020 00:54
Copy link

@kukugi kukugi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

Copy link
Contributor

@torao torao left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM


func AddInitFlags(cmd *cobra.Command) {
cmd.Flags().String("priv-key-type", config.PrivKeyType,
"Specify validator's private key type (ed25519 | composite)")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel the name composite seems a bit vague. What about ed25519+bls, ed25510/bls, etc., to clarify that it's an Ed25519 and BLS composite key.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are already using the name 'composite' in genesis.json and priv_validator_key.json files.
I think it is better to use the same term for unity.

  "consensus_params": {
    "block": {
      "max_bytes": "22020096",
      "max_gas": "-1",
      "time_iota_ms": "1000"
    },
    "evidence": {
      "max_age_num_blocks": "100000",
      "max_age_duration": "172800000000000"
    },
    "validator": {
      "pub_key_types": [
        "ed25519",
        "composite"
      ]
    }
{
  "address": "71463258B3E4A84F7EF1CB54473927726DAF6076",
  "pub_key": {
    "type": "tendermint/PubKeyComposite",
    "value": {
      "sign": {
        "type": "tendermint/PubKeyBLS12",
        "value": "hgq9S306jqNyqQeSX6YXBHV+BmNhoHG80BmuMdbRGyGWjyuDqJl83n+O8c79V9UY"
      },
      "vrf": {
        "type": "tendermint/PubKeyEd25519",
        "value": "afUwO/WEjC5l/0/DFM2OLu99n5FGz7pJtEWXqM8loOI="
      }
    }
  },
  "priv_key": {
    "type": "tendermint/PrivKeyComposite",
    "value": {
      "sign": {
        "type": "tendermint/PrivKeyBLS12",
        "value": "DiGI+49LV82oAMod+tu2P9SbqkU08soDbNc1UhsXDW8="
      },
      "vrf": {
        "type": "tendermint/PrivKeyEd25519",
        "value": "zcwkHxXUoSTxIa1lNmxA74jzEwMX+SfiIFwMkzqeycpp9TA79YSMLmX/T8MUzY4u732fkUbPukm0RZeozyWg4g=="
      }
    }
  }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C: enhancement Classification: New feature or its request, or improvement in maintainability of code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants