Members
number
# readonly nonzeroCoeffCount
Returns the nonzero coefficient count of the current PlainText polynomial.
ParmsIdType
# readonly parmsId
The reference to parmsId of the PlainText. The parmsId must remain zero unless the
PlainText polynomial is in NTT form.
 See:

 EncryptionParameters for more information about parmsId.
number
# readonly scale
The reference to the scale. This is only needed when using the CKKS
encryption scheme. The user should have little or no reason to ever change
the scale by hand.
number
# readonly significantCoeffCount
The significant coefficient count of the current PlainText polynomial.
Methods
# clone() → {PlainText}
Clone and return a new instance of this PlainText
Example
const plainTextA = seal.PlainText()
// ... after encoding some data ...
const plainTextB = plainTextA.clone()
// plainTextB holds a copy of plainTextA
# copy(plain)
Copy an existing PlainText and overwrite this instance
Parameters:
Name  Type  Description 

plain 
PlainText  PlainText to copy 
Example
const plainTextA = seal.PlainText()
// ... after encoding some data ...
const plainTextB = seal.PlainText()
plainTextB.copy(plainTextA)
// plainTextB holds a copy of plainTextA
# delete()
Delete the underlying WASM instance.
Should be called before dereferencing this object to prevent the
WASM heap from growing indefinitely.
# load(context, encoded)
Load a PlainText from a base64 string
Parameters:
Name  Type  Description 

context 
Context  Encryption context to enforce 
encoded 
string  Base64 encoded string 
# loadArray(context, array)
Load a PlainText from an Uint8Array holding binary data
Parameters:
Name  Type  Description 

context 
Context  Encryption context to enforce 
array 
Uint8Array  TypedArray containing binary data 
# move(plain)
Move a PlainText into this one and delete the old reference
Parameters:
Name  Type  Description 

plain 
PlainText  PlainText to move 
Example
const plainTextA = seal.PlainText()
// ... after encoding some data ...
const plainTextB = seal.PlainText()
plainTextB.move(plainTextA)
// plainTextB holds a the instance of plainTextA.
// plainTextA no longer holds an instance
# release()
Resets the PlainText. This function releases any memory allocated by the
PlainText, returning it to the memory pool.
# reserve(capacity)
Allocates enough memory to accommodate the backing array of a plaintext
with given capacity.
Parameters:
Name  Type  Description 

capacity 
number  The capacity to reserve 
# resize(coeffCount)
Resizes the PlainText to have a given coefficient count. The PlainText
is automatically reallocated if the new coefficient count does not fit in
the current capacity.
Parameters:
Name  Type  Description 

coeffCount 
number  The number of coefficients in the plaintext polynomial 
# save(compressionopt) → {string}
Save the PlainText to a base64 string
Parameters:
Name  Type  Attributes  Default  Description 

compression 
ComprModeType 
<optional> 
ComprModeType.deflate  The compression mode to use 
Base64 encoded string
string
# saveArray(compressionopt) → {Uint8Array}
Save the PlainText as a binary Uint8Array
Parameters:
Name  Type  Attributes  Default  Description 

compression 
ComprModeType 
<optional> 
ComprModeType.deflate  The compression mode to use 
A byte array containing the PlainText in binary form
Uint8Array
# setScale(scale)
Sets the PlainText scale. This is only needed when using the
CKKS encryption scheme. The user should have little or no reason to ever
change the scale by hand.
Parameters:
Name  Type  Description 

scale 
number  The scale to set 
# shrinkToFit()
Allocates enough memory to accommodate the backing array of the current
PlainText and copies it over to the new location. This function is meant
to reduce the memory use of the PlainText to smallest possible and can be
particularly important after modulus switching.
# toPolynomial() → {string}
Returns a humanreadable string description of the PlainText polynomial.
The returned string is of the form "7FFx^3 + 1x^1 + 3" with a format
summarized by the following:
1. Terms are listed in order of strictly decreasing exponent
2. Coefficient values are nonnegative and in hexadecimal format (hexadecimal
letters are in uppercase)
3. Exponents are positive and in decimal format
4. Zero coefficient terms (including the constant term) are omitted unless
the polynomial is exactly 0 (see rule 9)
5. Term with the exponent value of one is written as x^1
6. Term with the exponent value of zero (the constant term) is written as
just a hexadecimal number without x or exponent
7. Terms are separated exactly by +
8. Other than the +, no other terms have whitespace
9. If the polynomial is exactly 0, the string "0" is returned
std::invalid_argument if the PlainText is in NTT transformed form
Polynomial string
string