func (e *Engine) GenerateKeyPairs(ctx context.Context) (*KeyPairs, error) {
	kp := &KeyPairs{}

	err := ctxutil.ErrIfDone(ctx)
	if err != nil {
		return nil, err
	}

	pubSig, privSig, err := ed25519.GenerateKey(rand.Reader)
	if err != nil {
		return nil, err
	}

	sealedSig, nonceSig, err := e.Seal(ctx, privSig)
	if err != nil {
		return nil, err
	}

	kp.Signature.Private = sealedSig
	kp.Signature.Public = pubSig
	kp.Signature.PNonce = nonceSig

	err = ctxutil.ErrIfDone(ctx)
	if err != nil {
		return nil, err
	}

	pubEnc, privEnc, err := box.GenerateKey(rand.Reader)
	if err != nil {
		return nil, err
	}

	sealedEnc, nonceEnc, err := e.Seal(ctx, (*privEnc)[:])
	if err != nil {
		return nil, err
	}

	kp.Encryption.Private = sealedEnc
	kp.Encryption.Public = *pubEnc
	kp.Encryption.PNonce = nonceEnc

	return kp, nil
}
// GenerateKeyPairs generates and ed25519 signing key pair, and a curve25519
// encryption key pair for the user, encrypting the private keys in
// triplesec-v3 with the user's master key.
GenerateKeyPairs generates and ed25519 signing key pair, and a curve25519
encryption key pair for the user, encrypting the private keys in
triplesec-v3 with the user's master key.
// GenerateKeyPairs generates and ed25519 signing key pair and a curve25519 // encryption key pair for the user encrypting the private keys in // triplesec - v3 with the user ' s master key .
func (e *Engine) GenerateKeyPairs(ctx context.Context) (*KeyPairs, error) {
	kp := &KeyPairs{}
	err := ctxutil.ErrIfDone(ctx)
	if err != nil {
		return nil, err
	}
	pubSig, privSig, err := ed25519.GenerateKey(rand.Reader)
	if err != nil {
		return nil, err
	}
	sealedSig, nonceSig, err := e.Seal(ctx, privSig)
	if err != nil {
		return nil, err
	}
	kp.Signature.Private = sealedSig
	kp.Signature.Public = pubSig
	kp.Signature.PNonce = nonceSig
	err = ctxutil.ErrIfDone(ctx)
	if err != nil {
		return nil, err
	}
	pubEnc, privEnc, err := box.GenerateKey(rand.Reader)
	if err != nil {
		return nil, err
	}
	sealedEnc, nonceEnc, err := e.Seal(ctx, (*privEnc)[:])
	if err != nil {
		return nil, err
	}
	kp.Encryption.Private = sealedEnc
	kp.Encryption.Public = *pubEnc
	kp.Encryption.PNonce = nonceEnc
	return kp, nil
}
func ( e * Engine ) GenerateKeyPairs ( ctx context . Context ) ( * KeyPairs , error ) { kp := & KeyPairs { } err := ctxutil . ErrIfDone ( ctx ) if err != nil { return nil , err } pubSig , privSig , err := ed25519 . GenerateKey ( rand . Reader ) if err != nil { return nil , err } sealedSig , nonceSig , err := e . Seal ( ctx , privSig ) if err != nil { return nil , err } kp . Signature . Private = sealedSig kp . Signature . Public = pubSig kp . Signature . PNonce = nonceSig err = ctxutil . ErrIfDone ( ctx ) if err != nil { return nil , err } pubEnc , privEnc , err := box . GenerateKey ( rand . Reader ) if err != nil { return nil , err } sealedEnc , nonceEnc , err := e . Seal ( ctx , ( * privEnc ) [ : ] ) if err != nil { return nil , err } kp . Encryption . Private = sealedEnc kp . Encryption . Public = * pubEnc kp . Encryption . PNonce = nonceEnc return kp , nil }
GenerateKeyPairs generates and ed25519 signing key pair, and a curve25519
encryption key pair for the user, encrypting the private keys in
triplesec-v3 with the user's master key.
GenerateKeyPairs generates and ed25519 signing key pair and a curve25519 encryption key pair for the user encrypting the private keys in triplesec - v3 with the user ' s master key .