bloat/obj.go

38 lines
690 B
Go

package bloat
import (
"crypto/rand"
"aead.dev/minisign"
"filippo.io/age"
)
type Bloat[T any] struct {
SignPub minisign.PublicKey
signPriv minisign.PrivateKey
RequireEnc bool
EncPub age.X25519Recipient
encPriv age.X25519Identity // Scrypt is the password one?
}
func NewBloat[T any](noEnc bool) (Bloat[T], error) {
pub, sign, err := minisign.GenerateKey(rand.Reader)
if err != nil {
return Bloat[T]{}, err
}
res := Bloat[T]{
SignPub: pub,
signPriv: sign,
}
if !noEnc {
enc, err := age.GenerateX25519Identity()
if err != nil {
return Bloat[T]{}, err
}
recip := enc.Recipient()
res.encPriv = *enc
res.EncPub = *recip
}
return res, nil
}