Skip to content
This repository was archived by the owner on Jul 15, 2018. It is now read-only.
This repository was archived by the owner on Jul 15, 2018. It is now read-only.

helpers: provide helpers to generate keys #31

Closed
@odeke-em

Description

@odeke-em

Am currently writing code to test out the bug fix for tendermint/tendermint#514 in which we have a dishonest peer requesting a non-existent block height from a reactor and that requires a whole lot of setup.

I currently see that we have helpers for PrivKeyEd25519

go-crypto/priv_key.go

Lines 99 to 114 in 1bc8de4

func GenPrivKeyEd25519() PrivKeyEd25519 {
privKeyBytes := new([64]byte)
copy(privKeyBytes[:32], CRandBytes(32))
ed25519.MakePublicKey(privKeyBytes)
return PrivKeyEd25519(*privKeyBytes)
}
// NOTE: secret should be the output of a KDF like bcrypt,
// if it's derived from user input.
func GenPrivKeyEd25519FromSecret(secret []byte) PrivKeyEd25519 {
privKey32 := Sha256(secret) // Not Ripemd160 because we want 32 bytes.
privKeyBytes := new([64]byte)
copy(privKeyBytes[:32], privKey32)
ed25519.MakePublicKey(privKeyBytes)
return PrivKeyEd25519(*privKeyBytes)
}

However, trying to generate the public key using our package is quite a bit of work, IMHO we should make it simple to generate a public Ed25519 key that conforms to our package and not just to the Go crypto library. I suspect some other developers might need this in the future.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions