-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathkeygen.go
28 lines (23 loc) · 872 Bytes
/
keygen.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
package minilock
import (
"github.com/cathalgarvey/go-minilock/taber"
)
// Generate a key from an email address and passphrase, consistent
// with the miniLock algorithm. Passphrase is *not* currently checked
// for strength so it is, at present, the caller's responsibility to
// provide passphrases that don't suck!
func GenerateKey(email string, passphrase string) (*taber.Keys, error) {
return taber.FromEmailAndPassphrase(email, passphrase)
}
// Generate a fully random key, usually for ephemeral uses.
func EphemeralKey() (*taber.Keys, error) {
return taber.RandomKey()
}
// Import a miniLock ID as a public key.
func ImportID(id string) (*taber.Keys, error) {
return taber.FromID(id)
}
// Manually load a key from public and private binary strings.
func LoadKey(private, public []byte) *taber.Keys {
return &taber.Keys{Private: private, Public: public}
}