# Attempting to use FIXEDMANUAL or FIXEDAUTO Scaling Technique

**URL:** <https://openfhe.discourse.group/t/attempting-to-use-fixedmanual-or-fixedauto-scaling-technique/1871>\
**Category:** Library Questions\
**Created:** [February 12, 2025, 6:36pm UTC](https://openfhe.discourse.group/t/attempting-to-use-fixedmanual-or-fixedauto-scaling-technique/1871 "2025-02-12T18:36:26Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![lawrenceklim](https://avatars.discourse-cdn.com/v4/letter/l/e95f7d/32.png) [@lawrenceklim](https://openfhe.discourse.group/u/lawrenceklim)\
**Post date:** [February 12, 2025, 6:36pm UTC](https://openfhe.discourse.group/t/attempting-to-use-fixedmanual-or-fixedauto-scaling-technique/1871/1 "2025-02-12T18:36:26Z")

</div>

Hi, I’m new to using OpenFHE. I’m having trouble using the FIXEDMANUAL or FIXEDAUTO scaling techniques with CKKS. Maybe I’m doing something wrong with the setup or something but whenever I set the scaling technique to FIXEDMANUAL or FIXEDAUTO, creating a plaintext hangs indefinitely while it does not when the scaling technique to FLEXIBLEAUTOEXT.

Below is a code sample (running on OpenFHE v1.2.3) that shows what I mean:

```auto
#include <vector>
#include <iostream>
#include <cmath>

#include "openfhe.h"

using namespace lbcrypto;

int main() {
    int ring_dim = 1 << 14;
    int num_slots = ring_dim / 2;

    // Set up encryption parameters for CKKS
    CCParams<CryptoContextCKKSRNS> parameters;
    parameters.SetMultiplicativeDepth(1);
    parameters.SetScalingModSize(40);
    parameters.SetRingDim(ring_dim);
    parameters.SetBatchSize(num_slots);
    parameters.SetSecurityLevel(HEStd_128_classic);

    // The following lines do not work because it hangs when creating a plaintext
    parameters.SetScalingTechnique(FIXEDMANUAL); 
    // parameters.SetScalingTechnique(FIXEDAUTO);

    // The following commented out line does work, however
    // parameters.SetScalingTechnique(FLEXIBLEAUTOEXT);

    std::cout << "Generating crypto context..." << std::endl;
    // Create CryptoContext
    CryptoContext<DCRTPoly> cc = GenCryptoContext(parameters);
    cc->Enable(PKE);
    cc->Enable(KEYSWITCH);
    cc->Enable(LEVELEDSHE);

    std::cout << "Generating keys..." << std::endl;
    // Generate public and secret keys
    auto keys = cc->KeyGen();
    cc->EvalMultKeyGen(keys.secretKey);

    // Scale
    double scale = pow(2.0, 40);

    // Create some plaintexts
    std::vector<double> vec1 = {1.0, 2.0, 3.0, 4.0};

    std::cout << "Creating plaintext..." << std::endl;
    // Gets stuck here when using FIXEDMANUAL scaling technique
    Plaintext ptxt1 = cc->MakeCKKSPackedPlaintext(vec1, scale);

    std::cout << "Encrypting plaintext..." << std::endl;
    // Encrypt the plaintexts
    auto ctxt1 = cc->Encrypt(keys.publicKey, ptxt1);

    std::cout << "Adding ciphertext with plaintext..." << std::endl;
    // Perform ptxt-ctxt addition
    auto ctxt_ptxt_add = cc->EvalAdd(ctxt1, ptxt1);

    std::cout << "Decrypting and printing plaintext..." << std::endl;
    // Decrypt and print results
    Plaintext result;
    cc->Decrypt(keys.secretKey, ctxt_ptxt_add, &result);
    std::cout << "ptxt-ctxt addition result: " << result->GetRealPackedValue() << std::endl;

    return 0;
}

```

I also noticed that the [ManualRescaleDemo](https://github.com/openfheorg/openfhe-development/blob/7b8346f4eac27121543e36c17237b919e03ec058/src/pke/examples/advanced-real-numbers.cpp#L312) does not set the ScalingTechnique to FIXEDMANUAL. Am I missing something for how to use the different scaling techniques?

---

<div class="post-metadata">

**Author:** ![Caesar](https://yyz1.discourse-cdn.com/flex031/user_avatar/openfhe.discourse.group/caesar/32/63_2.png) [@Caesar](https://openfhe.discourse.group/u/Caesar)\
**Post date:** [February 12, 2025, 9:12pm UTC](https://openfhe.discourse.group/t/attempting-to-use-fixedmanual-or-fixedauto-scaling-technique/1871/2 "2025-02-12T21:12:47Z")

</div>

Why are you passing the scale here?

> [@lawrenceklim](#):
>
> ```auto
> Plaintext ptxt1 = cc->MakeCKKSPackedPlaintext(vec1, scale);
> 
> ```

You should set the scale using the crypto-context parameters as follows:  
`parameters.SetScalingModSize(40);`

Please follow the example “simple-real-numbers.cpp” to use and configure CKKS properly.
