Skip to content

Commit

Permalink
Spanization
Browse files Browse the repository at this point in the history
Rename to ElGamal from ElGamalExt
  • Loading branch information
bazzilic committed Apr 20, 2022
1 parent 6c3f7ad commit b7e9ae2
Show file tree
Hide file tree
Showing 9 changed files with 68 additions and 35 deletions.
31 changes: 30 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -261,4 +261,33 @@ __pycache__/
*.pyc

# VS Code
.vscode/
.vscode/

# MacOS junk
# General
.DS_Store
.AppleDouble
.LSOverride

# Icon must end with two \r
Icon?
![iI]con[_a-zA-Z0-9]

# Thumbnails
._*

# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent

# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk
4 changes: 2 additions & 2 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
<PackageIcon>icon.png</PackageIcon>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageIconUrl>https://i.ibb.co/SmV2V0m/aprismatic.png</PackageIconUrl>
<RepositoryUrl>https://github.com/aprismatic/elgamalext-homomorphism</RepositoryUrl>
<RepositoryUrl>https://github.com/aprismatic/elgamal-homomorphism</RepositoryUrl>
</PropertyGroup>

<ItemGroup>
<None Include="..\..\images\icon.png" Pack="true" PackagePath="\"/>
</ItemGroup>

</Project>
</Project>
3 changes: 1 addition & 2 deletions ElGamalExt-Homomorphism.sln → ElGamal-Homomorphism.sln
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ VisualStudioVersion = 16.0.29806.167
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{A6502C7E-9F34-40F1-97D8-E6631867E613}"
ProjectSection(SolutionItems) = preProject
.gitattributes = .gitattributes
.gitignore = .gitignore
Directory.Build.props = Directory.Build.props
nuget.config = nuget.config
Expand All @@ -16,7 +15,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{6E82EE2D-924
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{17A405E5-E5B7-4426-9C77-36D7B416C5FC}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Aprismatic.ElGamalExt.Homomorphism", "src\Aprismatic.ElGamalExt.Homomorphism\Aprismatic.ElGamalExt.Homomorphism.csproj", "{1C88C4DE-2866-4817-B0EE-9A7AA17542A6}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Aprismatic.ElGamal.Homomorphism", "src\Aprismatic.ElGamal.Homomorphism\Aprismatic.ElGamal.Homomorphism.csproj", "{1C88C4DE-2866-4817-B0EE-9A7AA17542A6}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ElGamalHomoTests", "test\ElGamalHomoTests\ElGamalHomoTests.csproj", "{9A9AA8CA-110F-4C86-B89C-030E7C1E4945}"
EndProject
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# ElGamalExt-Homomorphism
# Aprismatic.ElGamal.Homomorphism

![Test .NET (Windows)](https://github.com/aprismatic/elgamalext-homomorphism/workflows/Test%20.NET%20(Windows)/badge.svg?branch=master)

Basic ElGamal homomorphic functions.
Class that implements ElGamal homomorphic functions: multiplication and division. This library is a component of Aprismatic.ElGamal library.
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.1</TargetFramework>
<Description>Extension for the .NET Framework cryptography subsystem, which introduces the ElGamal public key cryptosystem with support for homomorphic multiplication.</Description>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<Nullable>enable</Nullable>
<RootNamespace>Aprismatic.ElGamalExt.Homomorphism</RootNamespace>
</PropertyGroup>

<PropertyGroup>
<DocumentationFile>bin\$(Configuration)\$(TargetFramework)\$(AssemblyName).xml</DocumentationFile>
</PropertyGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
using System;
using System.Numerics;

namespace Aprismatic.ElGamalExt.Homomorphism
namespace Aprismatic.ElGamal.Homomorphism
{
/// <summary>
/// The class implements the homomorphism of the ElGamal encryption scheme.
/// </summary>
public static class ElGamalHomomorphism
{
/// <summary>
Expand All @@ -12,18 +15,15 @@ public static class ElGamalHomomorphism
/// <param name="second">Second BigFraction to multiply</param>
/// <param name="P">ElGamal modulo</param>
/// <returns>Byte array that contains an ElGamal encryption of the product of the two BigFractions</returns>
public static byte[] MultiplyFractions(byte[] first, byte[] second, byte[] P)
public static byte[] MultiplyFractions(ReadOnlySpan<byte> first, ReadOnlySpan<byte> second, ReadOnlySpan<byte> P)
{
var hb = first.Length >> 1;

var fas = first.AsSpan();
var sas = second.AsSpan();
var firstNumerator = first.Slice(0, hb);
var firstDenominator = first.Slice(hb, hb);

var firstNumerator = fas.Slice(0, hb);
var firstDenominator = fas.Slice(hb, hb);

var secondNumerator = sas.Slice(0, hb);
var secondDenominator = sas.Slice(hb, hb);
var secondNumerator = second.Slice(0, hb);
var secondDenominator = second.Slice(hb, hb);

var res = new byte[first.Length];
var ras = res.AsSpan();
Expand All @@ -40,18 +40,15 @@ public static byte[] MultiplyFractions(byte[] first, byte[] second, byte[] P)
/// <param name="second">BigFraction to divide by</param>
/// <param name="P">ElGamal modulo</param>
/// <returns>Byte array that contains an ElGamal encryption of the quotient of the two BigFractions</returns>
public static byte[] DivideFractions(byte[] first, byte[] second, byte[] P)
public static byte[] DivideFractions(ReadOnlySpan<byte> first, ReadOnlySpan<byte> second, ReadOnlySpan<byte> P)
{
var hb = first.Length >> 1;

var fas = first.AsSpan();
var sas = second.AsSpan();

var firstNumerator = fas.Slice(0, hb);
var firstDenominator = fas.Slice(hb, hb);
var firstNumerator = first.Slice(0, hb);
var firstDenominator = first.Slice(hb, hb);

var secondNumerator = sas.Slice(0, hb);
var secondDenominator = sas.Slice(hb, hb);
var secondNumerator = second.Slice(0, hb);
var secondDenominator = second.Slice(hb, hb);

var res = new byte[first.Length];
var ras = res.AsSpan();
Expand All @@ -68,7 +65,7 @@ public static byte[] DivideFractions(byte[] first, byte[] second, byte[] P)
/// <param name="second">BigFraction to divide by</param>
/// <param name="P">ElGamal modulo</param>
/// <param name="dest">Byte span to write the ElGamal encryption of the product of the two BigIntegers to</param>
public static void MultiplyIntegers(ReadOnlySpan<byte> first, ReadOnlySpan<byte> second, byte[] P, Span<byte> dest)
public static void MultiplyIntegers(ReadOnlySpan<byte> first, ReadOnlySpan<byte> second, ReadOnlySpan<byte> P, Span<byte> dest)
{
var hb = first.Length >> 1;

Expand Down

This file was deleted.

2 changes: 1 addition & 1 deletion test/ElGamalHomoTests/ElGamalHomoTests.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Aprismatic.ElGamalExt.Homomorphism;
using Aprismatic.ElGamal.Homomorphism;
using Xunit;

namespace ElGamalHomoTests
Expand Down
7 changes: 4 additions & 3 deletions test/ElGamalHomoTests/ElGamalHomoTests.csproj
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netcoreapp3.1</TargetFrameworks>
<IsPackable>false</IsPackable>
<TargetFramework>net6.0</TargetFramework>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.1.0" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\src\Aprismatic.ElGamalExt.Homomorphism\Aprismatic.ElGamalExt.Homomorphism.csproj" />
<ProjectReference Include="..\..\src\Aprismatic.ElGamal.Homomorphism\Aprismatic.ElGamal.Homomorphism.csproj" />
</ItemGroup>
</Project>

0 comments on commit b7e9ae2

Please sign in to comment.