Skip to content

Unable to inject own Key Type  #2358

@bgrieder

Description

@bgrieder

Tendermint version 0.23.1

I would like to inject my own Public and Private key types because I do not want to use the ED25519 curve.

The embedded doc mentions it is possible to inject its own private validator as long as it implements the types.PrivValidator interface.

Unfortunately, this is currently impossible.

The typesGenesisDocrequires an array of validators which can be bootsrapped using something like

genDoc.Validators = []types.GenesisValidator{{
			PubKey: privValidator.GetPubKey(),  // <-- this pulls the "new" Public Key
			Power:  10,
		}}

The Node is instantiated using a (massive) NewNode(...) function that attempts to serialize the GenesisDoc in the state DB using a piece of code that does

	genDoc, err := loadGenesisDoc(stateDB)
	if err != nil {
		genDoc, err = genesisDocProvider()
		if err != nil {
			return nil, err
		}
		// save genesis doc to prevent a certain class of user errors (e.g. when it
		// was changed, accidentally or not). Also good for audit trail.
		saveGenesisDoc(stateDB, genDoc)  // <---- THE PROBLEMATIC CALL
	}

To serialize the doc, aminois called.
Unfortunately aminorequires all serializable "concrete" types to be pre-registered and the piece of code that does this is, is located in the wire.go file in the node package in an init() call, namely

var cdc = amino.NewCodec()

func init() {
	cryptoAmino.RegisterAmino(cdc) // <--- this registers all the types
}

As currently written, there is no way to inject custom types either by getting hold of cdc, which is private to the package, or via a provided callback.

I believe this static initialization should be revisited and cdc should be instantiated early and injected in the new node as part of the NewNode function parameters.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C:cryptoComponent: CryptoT:bugType Bug (Confirmed)T:enhancementType: Enhancement

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions