func (e *Engine) Unbox(ctx context.Context, ct, nonce []byte,
	privKP *EncryptionKeyPair, pubKey []byte) ([]byte, error) {

	privKey, err := e.Unseal(ctx, privKP.Private, privKP.PNonce)
	if err != nil {
		return nil, err
	}

	nonceb := [24]byte{}
	copy(nonceb[:], nonce)

	privkb := [32]byte{}
	copy(privkb[:], privKey)

	pubkb := [32]byte{}
	copy(pubkb[:], pubKey)

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

	pt, success := box.Open([]byte{}, ct, &nonceb, &pubkb, &privkb)
	if !success {
		return nil, errors.New("Failed to decrypt ciphertext")
	}

	return pt, nil
}
// Unbox Decrypts and verifies ciphertext ct that was previously encrypted using
// the provided nonce, and the inverse parts of the provided keypairs.
Unbox Decrypts and verifies ciphertext ct that was previously encrypted using
the provided nonce, and the inverse parts of the provided keypairs.
// Unbox Decrypts and verifies ciphertext ct that was previously encrypted using // the provided nonce and the inverse parts of the provided keypairs .
func (e *Engine) Unbox(ctx context.Context, ct, nonce []byte,
	privKP *EncryptionKeyPair, pubKey []byte) ([]byte, error) {
	privKey, err := e.Unseal(ctx, privKP.Private, privKP.PNonce)
	if err != nil {
		return nil, err
	}
	nonceb := [24]byte{}
	copy(nonceb[:], nonce)
	privkb := [32]byte{}
	copy(privkb[:], privKey)
	pubkb := [32]byte{}
	copy(pubkb[:], pubKey)
	err = ctxutil.ErrIfDone(ctx)
	if err != nil {
		return nil, err
	}
	pt, success := box.Open([]byte{}, ct, &nonceb, &pubkb, &privkb)
	if !success {
		return nil, errors.New("Failed to decrypt ciphertext")
	}
	return pt, nil
}
func ( e * Engine ) Unbox ( ctx context . Context , ct , nonce [ ] byte , privKP * EncryptionKeyPair , pubKey [ ] byte ) ( [ ] byte , error ) { privKey , err := e . Unseal ( ctx , privKP . Private , privKP . PNonce ) if err != nil { return nil , err } nonceb := [ 24 ] byte { } copy ( nonceb [ : ] , nonce ) privkb := [ 32 ] byte { } copy ( privkb [ : ] , privKey ) pubkb := [ 32 ] byte { } copy ( pubkb [ : ] , pubKey ) err = ctxutil . ErrIfDone ( ctx ) if err != nil { return nil , err } pt , success := box . Open ( [ ] byte { } , ct , & nonceb , & pubkb , & privkb ) if ! success { return nil , errors . New ( " " ) } return pt , nil }
Unbox Decrypts and verifies ciphertext ct that was previously encrypted using
the provided nonce, and the inverse parts of the provided keypairs.
Unbox Decrypts and verifies ciphertext ct that was previously encrypted using the provided nonce and the inverse parts of the provided keypairs .