Using agent
    • PDF

    Using agent

    • PDF

    Article Summary

    Available in VPC

    You can download an agent and use it if you want to directly create encryption keys and encrypt data locally without going through the cloud. Data that is locally encrypted through the agent can be uploaded to the cloud for computation.

    Overall knowledge of Python commands is required to use the agent.

    The following OSes support agents.

    • Linux - RHEL/CentOS
    • Linux - Ubuntu
    • Mac OS - x86(intel)/ arm64(m1)
    • Windows

    It is recommended that the PC running the agent have at least 8 GB of memory (RAM). If the memory is insufficient, key generation and encryption/decryption operations may not be performed correctly and may be terminated.

    Install agent

    The following describes how to download and install an agent.

    1. From the VPC environment of the NAVER Cloud Platform console, click the Services > Big Data & Analytics > HEaaN Homomorphic Analytics > Key, or Data menus, in that order.
    2. Click the [Download agent] button, and then select the right version for your OS to download.
    3. Run the following command.
      pip3 install NPC_HeaanAgent-2.1.0-py3-non-any.whl
      

    Using agent

    You can use the installed agent to create encryption key, encrypt data, and decrypt data locally.

    Create encryption key

    Run the following command to create an encryption key locally using the agent.

    • Create all keys at once (encryption key, decryption key, computation key)
    python3 -m hkey -o /Users/user/key -p 7
    
    • Set the path to generate the key in o option.
    • Set the capability of the homomorphic encryption key in the p option. If you do not select that option, a bootstrapable key is generated by default, and if you select 7, a non-bootstrapable key is generated.
    reference
    • Homomorphic encryption keys are divided into three types: encryption key, decryption key, and operation key.
    • Non-bootstrapping keys have a limited number of multiplication operations and cannot be used for machine learning operations.

    Upload homomorphic encryption key

    Execute the command below to upload the locally generated homomorphic encryption key using the agent.

    python3 -m hkey -o /Users/user/key -U -ak Dn391Nasf9 -sk 3KzAKnNOZN152NdZ0M2ALLNVI31
    
    • Set the generated key path in o option.
    • Upload key with U option.
    • Set the Access Key ID of the NAVER CLOUD PLATFORM member account in the ak option.
    • Set the Secret Key of the NAVER CLOUD PLATFORM member account in the sk option.
    reference
    • Upload the encryption key and operation key, but not the decryption key.
    • If you have already uploaded a key with the same name, the upload will fail.
    • For the Access Key ID and Secret Key of your NAVER CLOUD PLATFORM member account, go to My Page > Account Management > Manage Authentication Key on the NAVER CLOUD PLATFORM portal.

    Encrypt data

    Execute the command below to encrypt data using the homogeneous encryption key generated by the agent.

    • Data encryption for general-purpose operations
    python3 -m henc -i /Users/user/CSV_sample4.csv -o /Users/user/CSV_sample4 -k /Users/user/key
    
    • Data encryption for machine learning training
    python3 -m henc -id /Users/user/CSV_sample4.csv -od /Users/user/CSV_sample4 -l label -k /Users/user/key
    
    • Data encryption for machine learning inference
    python3 -m henc -it /Users/user/CSV_sample4.csv -ot /Users/user/CSV_sample4 -l label -k /Users/user/key
    
    • Set the path to the data file for general-purpose operations in the i option.
    • In the id option, set the path to the data file for machine learning training.
    • In the it option, set the path to the data file for machine learning inference.
    • Set the path where the ciphertext will be generated in the o, -od, and -ot options.
    • In l option, set the Label column name to use for machine learning.
    • Set the path to the key to be used for encryption in the k option.
    reference
    • The file extensions that can be encrypted are csv, xlsx.
    • Please use the encryption option that suits the purpose of the calculation.
    • Encrypting data for machine learning inference does not require setting the -l option.

    data upload

    Execute the command below to upload the passphrase locally using the agent.

    python3 -m henc -o /Users/user/CSV_sample4  -k /Users/user/key -fn samplefolder -U -ak Dn391Nasf9 -sk KzAKnNOZN152NdZ0M2ALLNVI31
    
    • Set the ciphertext path in the o option.
    • Upload ciphertext with U option.
    • In the fn option, set the name of the data folder created in the NAVER CLOUD PLATFORM console.
    • Set the Access Key ID of the NAVER CLOUD PLATFORM member account in the ak option.
    • Set the Secret Key of the NAVER CLOUD PLATFORM member account in the sk option.
    reference
    • If you have already uploaded a passphrase with the same name, the upload will fail.
    • For the list of data folders, please check the Services > Big Data & Analytics > HEaaN Homomorphic Analytics > Data menu in the VPC environment of the NAVER CLOUD PLATFORM console.
    • For the Access Key ID and Secret Key of your NAVER CLOUD PLATFORM member account, go to My Page > Account Management > Manage Authentication Key on the NAVER CLOUD PLATFORM portal.

    Decrypt data

    Run the following command to decrypt data using the local decryption key file created through the agent.

    python3 -m hdec -i /Users/user/CSV_sample4_enc -o /Users/user/CSV_sample4/dec.csv -k /Users/user/key
    
    • Set the path of the ciphertext to be decrypted in the i option.
    • Set the plaintext path to be generated in the o option.
    • Set the path of the key to be used for decryption in the k option.
    reference
    • The ciphertext as a result of performing isomorphism in the NAVER CLOUD PLATFORM console is saved with a tar extension. Unpack the tar file and run the decryption command.

    Delete agent

    Enter the following to delete the agent.

    pip3 uninstall -y  NCP-HeaanAgent
    

    Was this article helpful?

    Changing your password will log you out immediately. Use the new password to log back in.
    First name must have atleast 2 characters. Numbers and special characters are not allowed.
    Last name must have atleast 1 characters. Numbers and special characters are not allowed.
    Enter a valid email
    Enter a valid password
    Your profile has been successfully updated.