2020-08-17 12:55:12 +00:00
|
|
|
package pigeon
|
|
|
|
|
|
|
|
import (
|
|
|
|
"crypto/ed25519"
|
|
|
|
"fmt"
|
|
|
|
"os"
|
|
|
|
)
|
|
|
|
|
|
|
|
// Version is the current version of Pigeon CLI
|
|
|
|
const Version = "0.0.0"
|
|
|
|
|
|
|
|
// CreateKeypair makes a new ED25519 key pair. Just a thin
|
|
|
|
// wrapper around crypto/ed25519.
|
2020-08-20 13:13:38 +00:00
|
|
|
func createKeypair() (ed25519.PublicKey, ed25519.PrivateKey) {
|
2020-08-17 12:55:12 +00:00
|
|
|
pub, priv, err := ed25519.GenerateKey(nil)
|
|
|
|
if err != nil {
|
|
|
|
fmt.Println(err)
|
|
|
|
os.Exit(1)
|
|
|
|
}
|
|
|
|
|
|
|
|
return pub, priv
|
|
|
|
}
|
|
|
|
|
2020-08-20 13:13:38 +00:00
|
|
|
// CreateIdentity is used by the CLI to create an ED25519
|
|
|
|
// keypair and store it to disk. It returns the private key
|
|
|
|
// as a Base32 encoded string
|
|
|
|
func CreateIdentity() (ed25519.PublicKey, ed25519.PrivateKey) {
|
|
|
|
pub, priv := createKeypair()
|
|
|
|
PutConfig(ConfigSecret, priv)
|
|
|
|
return pub, priv
|
2020-08-17 12:55:12 +00:00
|
|
|
}
|
|
|
|
|
2020-08-20 13:13:38 +00:00
|
|
|
// GetIdentity retrieves the user's signing key
|
|
|
|
func GetIdentity() []byte {
|
|
|
|
return getConfig(ConfigSecret)
|
2020-08-17 12:55:12 +00:00
|
|
|
}
|
2020-08-20 13:13:38 +00:00
|
|
|
|
|
|
|
func EncodeUserMhash() {}
|