Interface

PlainText

PlainText

Members

number

# readonly capacity

The capacity of the current allocation.

View Source plain-text.ts, line 150

number

# readonly coeffCount

The coefficient count of the current PlainText polynomial.

View Source plain-text.ts, line 160

boolean

# readonly isNttForm

Whether the PlainText is in NTT form.

View Source plain-text.ts, line 221

boolean

# readonly isZero

Whether the current PlainText polynomial has all zero coefficients.

View Source plain-text.ts, line 140

number

# readonly nonzeroCoeffCount

Returns the non-zero coefficient count of the current PlainText polynomial.

View Source plain-text.ts, line 180

ParmsIdType

# readonly parmsId

The reference to parmsId of the PlainText. The parmsId must remain zero unless the PlainText polynomial is in NTT form.
See:

View Source plain-text.ts, line 231

MemoryPoolHandle

# readonly pool

The currently used MemoryPoolHandle.

View Source plain-text.ts, line 270

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.

View Source plain-text.ts, line 246

number

# readonly significantCoeffCount

The significant coefficient count of the current PlainText polynomial.

View Source plain-text.ts, line 170

Methods

# clone() → {PlainText}

Clone and return a new instance of this PlainText

View Source plain-text.ts, line 361

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

View Source plain-text.ts, line 340

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.

View Source plain-text.ts, line 62

# 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

View Source plain-text.ts, line 308

# 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

View Source plain-text.ts, line 324

# move(plain)

Move a PlainText into this one and delete the old reference
Parameters:
Name Type Description
plain PlainText PlainText to move

View Source plain-text.ts, line 390

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.

View Source plain-text.ts, line 104

# 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

View Source plain-text.ts, line 76

# 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

View Source plain-text.ts, line 114

# 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

View Source plain-text.ts, line 280

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

View Source plain-text.ts, line 291

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

View Source plain-text.ts, line 258

# setZero()

Sets the PlainText polynomial to zero.

View Source plain-text.ts, line 131

# 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.

View Source plain-text.ts, line 92

# toPolynomial() → {string}

Returns a human-readable 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 non-negative and in hexadecimal format (hexadecimal letters are in upper-case) 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

View Source plain-text.ts, line 190

std::invalid_argument if the PlainText is in NTT transformed form
Polynomial string
string