mirror of
https://github.com/fluencelabs/tendermint
synced 2025-07-30 19:51:58 +00:00
Use new go-wire; PubKey etc are interfaces; Keybase refactor
This commit is contained in:
32
keys/keys.go
Normal file
32
keys/keys.go
Normal file
@@ -0,0 +1,32 @@
|
||||
package keys
|
||||
|
||||
import "fmt"
|
||||
|
||||
type CryptoAlgo string
|
||||
|
||||
const (
|
||||
AlgoEd25519 = CryptoAlgo("ed25519")
|
||||
AlgoSecp256k1 = CryptoAlgo("secp256k1")
|
||||
)
|
||||
|
||||
func cryptoAlgoToByte(key CryptoAlgo) byte {
|
||||
switch key {
|
||||
case AlgoEd25519:
|
||||
return 0x01
|
||||
case AlgoSecp256k1:
|
||||
return 0x02
|
||||
default:
|
||||
panic(fmt.Sprintf("Unexpected type key %v", key))
|
||||
}
|
||||
}
|
||||
|
||||
func byteToCryptoAlgo(b byte) CryptoAlgo {
|
||||
switch b {
|
||||
case 0x01:
|
||||
return AlgoEd25519
|
||||
case 0x02:
|
||||
return AlgoSecp256k1
|
||||
default:
|
||||
panic(fmt.Sprintf("Unexpected type byte %X", b))
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user