0% found this document useful (0 votes)
23 views17 pages

C 521 - Homomorphic Encryption With SEAL (30 Pts Extra)

Uploaded by

Amal Abid
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views17 pages

C 521 - Homomorphic Encryption With SEAL (30 Pts Extra)

Uploaded by

Amal Abid
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 17

30/09/2022 18:58 C 521: Homomorphic Encryption with SEAL (30 pts extra)

C 521: Homomorphic Encryption with SEAL (30 pts extra)


What you need:

A Windows 2016 Google Cloud Server

Purpose
To run a very basic example of homomorphic encryption: a system that performs mathematical operations on encrypted data without ever decrypting
it.

Install Git
On your Windows server, in Firefox, go to

https://git-scm.com/download/win

Click on "Click here to download manually".

Save the file. Double-click it and install Git with the default options.

Install Visual Studio


First install the Visual C++ Build Tools, as explained here.

Click Start, scroll to V, click "Visual Studio Installer".

Approve the privilege escalation.

In the Visual Studio Installer, on the Available tab, in the Visual Studio Community 2019 section, click the Install button.

On the Workloads tab, check ".NET desktop development", "Desktop development with C++", and "Universal Windows Platform development",
as shown below.

At the lower right, click the Install button.

It took 40 minutes to install when I did it.

WHen it's done, a "Visual Studio" box pops up asking you to connect to your developer services.

At the bottom, click "Not now, maybe later.". as shown below.

https://samsclass.info/141/proj/C521.htm 1/17
30/09/2022 18:58 C 521: Homomorphic Encryption with SEAL (30 pts extra)

In the "Start with a familiar environment" page, at the lower right, click the "Start Visual Studio" button.

Visual Studio 2019 opens, as shown below.

Run as Administrator
Close Visual Studio.

At the lower left of the desktop, click the Start button.

Scroll down to the "V" section.

https://samsclass.info/141/proj/C521.htm 2/17
30/09/2022 18:58 C 521: Homomorphic Encryption with SEAL (30 pts extra)
Right-click "Visual Studion 2019", point to More, and click "Run as Administrator".

Approve the privilege escalation.

Cloning SEAL from Github


On the right side of the Visual Studio 2019 window, click "Clone a repository".

In the Clone a repository page, enter this Repository Location, as shown below:

https://github.com/microsoft/SEAL.git

At the lower right, click the Clone button.

The SEAL code appears on the right side, in the Solution Explorer, as shown below:

https://samsclass.info/141/proj/C521.htm 3/17
30/09/2022 18:58 C 521: Homomorphic Encryption with SEAL (30 pts extra)

Building SEAL
In Solution Explorer, expand native. Click SEAL to select it, as shown below.

At the top center, click the leftmost white drop-down list box containing the word "Debug" and change it to Release.

Change the second box to x64.

Then right-click SEAL and click Build, as shown below.

https://samsclass.info/141/proj/C521.htm 4/17
30/09/2022 18:58 C 521: Homomorphic Encryption with SEAL (30 pts extra)

At the bottom, the Output pane shows the build progress. When it's done, it shows "Build: 1 succeeded" as shown below.

Note the path to the "seal.lib" file, outlined in red in the image below.

On my machine, the path was:

C:\Users\cnit_123d\source\repos\SEAL\lib\x64\Release

Open Windows Explorer and browse to that location. Notice the path to the "src" folder, inside the "native" folder, as shown below.

You'll need that path later.

https://samsclass.info/141/proj/C521.htm 5/17
30/09/2022 18:58 C 521: Homomorphic Encryption with SEAL (30 pts extra)

Writing an App
In Visual Studio, at the top left, click File, "Close Solution".

At the top left, click File, New, Project.

In the "Create a new project" box, in the top center, select a Language of C++.

Click "Empty Project", as shown below, and click Next.

https://samsclass.info/141/proj/C521.htm 6/17
30/09/2022 18:58 C 521: Homomorphic Encryption with SEAL (30 pts extra)

In the "Configure your new project" box, name your project SEAL1 and click Create.

https://samsclass.info/141/proj/C521.htm 7/17
30/09/2022 18:58 C 521: Homomorphic Encryption with SEAL (30 pts extra)

On the right side, in Solution Explorer, right-click SEAL1 and click Add..., "New Item".

In the Add New Item box, click "C++ File (.cpp)".

At the bottom, enter a name of Example.cpp, as shown below, and click the Add button.

https://samsclass.info/141/proj/C521.htm 8/17
30/09/2022 18:58 C 521: Homomorphic Encryption with SEAL (30 pts extra)

Linking Seal.lib to the Project


On the right side, in Solution Explorer, right-click SEAL1 and click Properties.

In the SEAL1 Property Pages box, at the top, select "All Configurations" and "All Platforms", as shown below.

In the left pane, expand C/C++ and click General on the first line that appears.

In the "Additional Include Directories", enter the path to the "src" folder you noted earlier. On my machine, the path was:

C:\Users\cnit_123d\source\repos\SEAL\native\src

as shown below.

In the left pane, click Linker.

In the "Additional Library Directories", enter the path to your "lin" folder, followed by \$(Platform)\$(Configuration)

https://samsclass.info/141/proj/C521.htm 9/17
30/09/2022 18:58 C 521: Homomorphic Encryption with SEAL (30 pts extra)
On my machine, the path was:

C:\Users\cnit_123d\source\repos\SEAL\lib\$(Platform)\$(Configuration)

as shown below.

In the left pane, expand Linker and click Input on the second line that appears.

In the "Additional Dependencies", add seal.lib; to the start of the list, as shown below.

Setting the C++ Version


In the left pane, expand C/C++ and click Language.

Set the "C++ Language Standard", to "ISO C++17 Standard (std:c++17)", as shown below.

https://samsclass.info/141/proj/C521.htm 10/17
30/09/2022 18:58 C 521: Homomorphic Encryption with SEAL (30 pts extra)

At the bottom right, click the OK button.

Entering the C++ Code


In the code area, enter this code, as shown below.

#include "seal/seal.h"
#include <iostream>

using namespace std;


using namespace seal;

int main()
{
EncryptionParameters params(scheme_type::BFV);
return 0;
}

Adjusting Build Parameters


At the top center, change the build configuration from "Debug" to Release. Also change the platform from "x86" to x64, as shown below.

https://samsclass.info/141/proj/C521.htm 11/17
30/09/2022 18:58 C 521: Homomorphic Encryption with SEAL (30 pts extra)

Compiling the Code


On the right side, in Solution Explorer, right-click SEAL1 and click Build

At the bottom, the Output pane shows the build progress. When it's done, it shows "Build: 1 succeeded".

C 521.1: Running the Example (15 pts)


From the meny bar, click Debug, "Start Without Debugging".

A Command Prompt window opens, as shown below.

The flag is covered by a green rectangle in the image below.

Opening the SEAL Project


In Visual Studio, at the top left, click File, "Close Solution".

In the "What would you like to do?" page, under the "Open recent" header, click SEAL.sln, as shown below.

https://samsclass.info/141/proj/C521.htm 12/17
30/09/2022 18:58 C 521: Homomorphic Encryption with SEAL (30 pts extra)

Building Seal_C
On the right side, in Solution Explorer, right-click SEAL_C and click Build.

Building SEALExamples
On the right side, in Solution Explorer, right-click SealExamples and click Build.

When you see the "Build: 1 succeeded" message, the build is done.

Launching SEALExamples
In Windows Explorer, navigate to the sealexamples.exe file, as shown below, and double-click it.

Viewing the Source Code


In Windows Explorer, navigate to the 1_bfv_basics.cpp file, as shown below.

Right-click 1_bfv_basics.cpp, point to "Open with", and click Notepad.

https://samsclass.info/141/proj/C521.htm 13/17
30/09/2022 18:58 C 521: Homomorphic Encryption with SEAL (30 pts extra)

Now you can run the examples while reading the source code, as shown below.

Run the first example and read the comments and the output. Find the flags below as you go.

C 521.2: Noise Budget (3 pts)


The flag is covered by a green rectangle in the image below.

https://samsclass.info/141/proj/C521.htm 14/17
30/09/2022 18:58 C 521: Homomorphic Encryption with SEAL (30 pts extra)

C 521.3: Line 418 (3 pts)


The flag is covered by a green rectangle in the image below.

C 521.4: Plain_Modulus (3 pts)


The flag is covered by a green rectangle in the image below.

https://samsclass.info/141/proj/C521.htm 15/17
30/09/2022 18:58 C 521: Homomorphic Encryption with SEAL (30 pts extra)

C 521.5: Decoded integer (3 pts)


Run example #2 and view the corresponding source file.

The flag is covered by a green rectangle in the image below.

C 521.6: Vector (3 pts)


The flag is covered by a green rectangle in the image below.

https://samsclass.info/141/proj/C521.htm 16/17
30/09/2022 18:58 C 521: Homomorphic Encryption with SEAL (30 pts extra)

References
Installing Microsoft SEAL on Windows
Podcast 3 | Homomorphic Encryption with Microsoft Open Source "SEAL" Library
Microsoft SEAL

Posted 9-10-20 by Sam Bowne

https://samsclass.info/141/proj/C521.htm 17/17

You might also like