func CheckPoisonRecord(data []byte, keystorage keystore.PoisonKeyStore) (bool, error) {
	poisonKeys, err := keystorage.GetPoisonPrivateKeys()
	if err != nil {
		return true, err
	}
	defer utils.ZeroizePrivateKeys(poisonKeys)
	_, err = DecryptRotatedAcrastruct(data, poisonKeys, nil)
	return err == nil, nil
}
CheckPoisonRecord checks if AcraStruct could be decrypted using Poison Record private key.
Returns true if AcraStruct is poison record, returns false otherwise.
Returns error if Poison record key is not found.
package base
import (
	"bytes"
	"encoding/binary"
	"errors"
	"github.com/cossacklabs/acra/keystore"
	"github.com/cossacklabs/acra/utils"
	"github.com/cossacklabs/themis/gothemis/cell"
	"github.com/cossacklabs/themis/gothemis/keys"
	"github.com/cossacklabs/themis/gothemis/message"
)
func GetDataLengthFromAcraStruct(data []byte) int {
	dataLengthBlock := data[GetMinAcraStructLength()-DataLengthSize : GetMinAcraStructLength()]
	return int(binary.LittleEndian.Uint64(dataLengthBlock))
}
func GetMinAcraStructLength() int {
	return len(TagBegin) + KeyBlockLength + DataLengthSize
}
var (
	ErrIncorrectAcraStructTagBegin   = errors.New("AcraStruct has incorrect TagBegin")
	ErrIncorrectAcraStructLength     = errors.New("AcraStruct has incorrect length")
	ErrIncorrectAcraStructDataLength = errors.New("AcraStruct has incorrect data length value")
)
var ErrNoPrivateKeys = errors.New("cannot decrypt AcraStruct with empty key list")
func ValidateAcraStructLength(data []byte) error {
	baseLength := GetMinAcraStructLength()
	if len(data) < baseLength {
		return ErrIncorrectAcraStructLength
	}
	if !bytes.Equal(data[:len(TagBegin)], TagBegin) {
		return ErrIncorrectAcraStructTagBegin
	}
	dataLength := GetDataLengthFromAcraStruct(data)
	if dataLength != len(data[GetMinAcraStructLength():]) {
		return ErrIncorrectAcraStructDataLength
	}
	return nil
}
func DecryptAcrastruct(data []byte, privateKey *keys.PrivateKey, zone []byte) ([]byte, error) {
	if err := ValidateAcraStructLength(data); err != nil {
		return nil, err
	}
	innerData := data[len(TagBegin):]
	pubkey := &keys.PublicKey{Value: innerData[:PublicKeyLength]}
	smessage := message.New(privateKey, pubkey)
	symmetricKey, err := smessage.Unwrap(innerData[PublicKeyLength:KeyBlockLength])
	if err != nil {
		return []byte{}, err
	}
	var length uint64
	err = binary.Read(bytes.NewReader(innerData[KeyBlockLength:KeyBlockLength+DataLengthSize]), binary.LittleEndian, &length)
	if err != nil {
		return []byte{}, err
	}
	scell := cell.New(symmetricKey, cell.ModeSeal)
	decrypted, err := scell.Unprotect(innerData[KeyBlockLength+DataLengthSize:], nil, zone)
	utils.ZeroizeSymmetricKey(symmetricKey)
	if err != nil {
		return []byte{}, err
	}
	return decrypted, nil
}
func DecryptRotatedAcrastruct(data []byte, privateKeys []*keys.PrivateKey, zone []byte) ([]byte, error) {
	var err error = ErrNoPrivateKeys
	var decryptedData []byte
	for _, privateKey := range privateKeys {
		decryptedData, err = DecryptAcrastruct(data, privateKey, zone)
		if err == nil {
			return decryptedData, nil
		}
	}
	return nil, err
}