Skip to content

Commit 69edb66

Browse files
authored
Merge pull request #70 from shinji-san/release-v0.7.0
Release v0.7.0 Added - Added implicit casts for byte arrays in Secret class. - Added legacy mode. See README.md, section "Usage" for more details. Changed - Changed behavior of Secret class for negative secret values. - Changed calculation of maximum security level in Reconstruction method. Fixed - Fixed reopened bug #60 "Reconstruction fails at random". - Fixed assembly output path in SecretSharingDotNetFx4.6.2.csproj Removed - Removed .NET FX 4.5.2 support, because it retires on April 26, 2022. - Removed .NET FX 4.6 support, because it retires on April 26, 2022. - Removed .NET FX 4.6.1 support, because it retires on April 26, 2022.
2 parents a4d1187 + 575b718 commit 69edb66

20 files changed

+702
-189
lines changed

.github/workflows/dotnetfx.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,14 @@ jobs:
2424
nuget-version: latest
2525

2626
- name: Nuget Restore
27-
run: nuget restore $Env:GITHUB_WORKSPACE\SecretSharingDotNetFx4.5.2.sln
27+
run: nuget restore $Env:GITHUB_WORKSPACE\SecretSharingDotNetFx4.6.2.sln
2828

2929
- name: Build with mbsuild
3030
run: |
3131
cd "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin\"
32-
.\MSBuild.exe /p:Configuration=Release $Env:GITHUB_WORKSPACE\SecretSharingDotNetFx4.5.2.sln
32+
.\MSBuild.exe /p:Configuration=Release $Env:GITHUB_WORKSPACE\SecretSharingDotNetFx4.6.2.sln
3333
3434
- name: Test with xUnit.net console runner
3535
run: |
36-
cd "$Env:GITHUB_WORKSPACE\packages\xunit.runner.console.2.4.0\tools\net452"
36+
cd "$Env:GITHUB_WORKSPACE\packages\xunit.runner.console.2.4.1\tools\net462"
3737
.\xunit.console $Env:GITHUB_WORKSPACE\tests\bin\Release\SecretSharingDotNetTest.dll

CHANGELOG.md

+18
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,24 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7+
## [0.7.0] - 2022-02-09
8+
### Added
9+
- Added implicit casts for byte arrays in *Secret* class.
10+
- Added legacy mode. See README.md, section "Usage" for more details.
11+
12+
### Changed
13+
- Changed behavior of *Secret* class for negative secret values. See README.md, section "Usage" and bug report [#60](https://github.com/shinji-san/SecretSharingDotNet/issues/60) for more details.
14+
- Changed calculation of maximum security level in Reconstruction method.
15+
16+
### Fixed
17+
- Fixed reopened bug [#60](https://github.com/shinji-san/SecretSharingDotNet/issues/60) "Reconstruction fails at random".
18+
- Fixed assembly output path in `SecretSharingDotNetFx4.6.2.csproj`
19+
20+
### Removed
21+
- Removed .NET FX 4.5.2 support, because it retires on April 26, 2022. See [.NET FX Lifecycle Policy](https://docs.microsoft.com/en-us/lifecycle/products/microsoft-net-framework).
22+
- Removed .NET FX 4.6 support, because it retires on April 26, 2022. See [.NET FX Lifecycle Policy](https://docs.microsoft.com/en-us/lifecycle/products/microsoft-net-framework).
23+
- Removed .NET FX 4.6.1 support, because it retires on April 26, 2022. See [.NET FX Lifecycle Policy](https://docs.microsoft.com/en-us/lifecycle/products/microsoft-net-framework).
24+
725
## [0.6.0] - 2021-11-25
826
### Added
927
- Add .NET 6 support

README.md

+83-34
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ An C# implementation of Shamir's Secret Sharing.
1313
</thead>
1414
<tbody>
1515
<tr>
16-
<td rowspan=13><a href ="https://github.com/shinji-san/SecretSharingDotNet/actions?query=workflow%3A%22SecretSharingDotNet+%28All+supported+TFM%29%22" target="_blank"><img src="https://github.com/shinji-san/SecretSharingDotNet/workflows/SecretSharingDotNet%20(All%20supported%20TFM)/badge.svg" alt="Build status"/></a></td>
17-
<td rowspan=13><code>SecretSharingDotNet.sln</code></td>
18-
<td rowspan=13>Core</td>
16+
<td rowspan=10><a href ="https://github.com/shinji-san/SecretSharingDotNet/actions?query=workflow%3A%22SecretSharingDotNet+%28All+supported+TFM%29%22" target="_blank"><img src="https://github.com/shinji-san/SecretSharingDotNet/workflows/SecretSharingDotNet%20(All%20supported%20TFM)/badge.svg" alt="Build status"/></a></td>
17+
<td rowspan=10><code>SecretSharingDotNet.sln</code></td>
18+
<td rowspan=10>Core</td>
1919
<td>Core 3.1 (LTS)</td>
2020
</tr>
2121
<tr>
@@ -24,15 +24,6 @@ An C# implementation of Shamir's Secret Sharing.
2424
<tr>
2525
<td>Standard 2.1</td>
2626
</tr>
27-
<tr>
28-
<td>FX 4.5.2</td>
29-
</tr>
30-
<tr>
31-
<td>FX 4.6</td>
32-
</tr>
33-
<tr>
34-
<td>FX 4.6.1</td>
35-
</tr>
3627
<tr>
3728
<td>FX 4.6.2</td>
3829
</tr>
@@ -70,9 +61,9 @@ An C# implementation of Shamir's Secret Sharing.
7061
</tr>
7162
<tr>
7263
<td><a href="https://github.com/shinji-san/SecretSharingDotNet/actions?query=workflow%3A%22SecretSharingDotNet+.NET+FX%22" target="_blank"><img src="https://github.com/shinji-san/SecretSharingDotNet/workflows/SecretSharingDotNet%20.NET%20FX/badge.svg" alt="Build status"></a></td>
73-
<td><code>SecretSharingDotNetFx4.5.2.sln</code></td>
64+
<td><code>SecretSharingDotNetFx4.6.2.sln</code></td>
7465
<td>FX</td>
75-
<td>FX 4.5.2</td>
66+
<td>FX 4.6.2</td>
7667
</tr>
7768
</tbody>
7869
</table>
@@ -90,9 +81,9 @@ An C# implementation of Shamir's Secret Sharing.
9081
</thead>
9182
<tbody>
9283
<tr>
93-
<td rowspan=13><a href="https://github.com/shinji-san/SecretSharingDotNet/actions?query=workflow%3A%22SecretSharingDotNet+NuGet%22" target="_blank"><img src="https://github.com/shinji-san/SecretSharingDotNet/workflows/SecretSharingDotNet%20NuGet/badge.svg?branch=v0.6.0" alt="SecretSharingDotNet NuGet"/></a></td>
94-
<td rowspan=13><a href="https://badge.fury.io/nu/SecretSharingDotNet" target="_blank"><img src="https://badge.fury.io/nu/SecretSharingDotNet.svg" alt="NuGet Version 0.6.0"/></a></td>
95-
<td rowspan=13><a href="https://github.com/shinji-san/SecretSharingDotNet/tree/v0.6.0" target="_blank"><img src="https://img.shields.io/badge/SecretSharingDotNet-0.6.0-green.svg?logo=github&logoColor=959da5&color=2ebb4e&labelColor=2b3137" alt="Tag"/></a></td>
84+
<td rowspan=10><a href="https://github.com/shinji-san/SecretSharingDotNet/actions?query=workflow%3A%22SecretSharingDotNet+NuGet%22" target="_blank"><img src="https://github.com/shinji-san/SecretSharingDotNet/workflows/SecretSharingDotNet%20NuGet/badge.svg?branch=v0.7.0" alt="SecretSharingDotNet NuGet"/></a></td>
85+
<td rowspan=10><a href="https://badge.fury.io/nu/SecretSharingDotNet" target="_blank"><img src="https://badge.fury.io/nu/SecretSharingDotNet.svg" alt="NuGet Version 0.7.0"/></a></td>
86+
<td rowspan=10><a href="https://github.com/shinji-san/SecretSharingDotNet/tree/v0.7.0" target="_blank"><img src="https://img.shields.io/badge/SecretSharingDotNet-0.7.0-green.svg?logo=github&logoColor=959da5&color=2ebb4e&labelColor=2b3137" alt="Tag"/></a></td>
9687
<td>Core 3.1 (LTS)</td>
9788
</tr>
9889
<tr>
@@ -107,15 +98,6 @@ An C# implementation of Shamir's Secret Sharing.
10798
<tr>
10899
<td>Standard 2.1</td>
109100
</tr>
110-
<tr>
111-
<td>FX 4.5.2</td>
112-
</tr>
113-
<tr>
114-
<td>FX 4.6</td>
115-
</tr>
116-
<tr>
117-
<td>FX 4.6.1</td>
118-
</tr>
119101
<tr>
120102
<td>FX 4.6.2</td>
121103
</tr>
@@ -138,10 +120,10 @@ An C# implementation of Shamir's Secret Sharing.
138120

139121
1. Open a console and switch to the directory, containing your project file.
140122

141-
2. Use the following command to install version 0.6.0 of the SecretSharingDotNet package:
123+
2. Use the following command to install version 0.7.0 of the SecretSharingDotNet package:
142124

143125
```dotnetcli
144-
dotnet add package SecretSharingDotNet -v 0.6.0 -f <FRAMEWORK>
126+
dotnet add package SecretSharingDotNet -v 0.7.0 -f <FRAMEWORK>
145127
```
146128
147129
3. After the completition of the command, look at the project file to make sure that the package is successfuly installed.
@@ -150,7 +132,7 @@ An C# implementation of Shamir's Secret Sharing.
150132
151133
```xml
152134
<ItemGroup>
153-
<PackageReference Include="SecretSharingDotNet" Version="0.6.0" />
135+
<PackageReference Include="SecretSharingDotNet" Version="0.7.0" />
154136
</ItemGroup>
155137
```
156138
## Remove SecretSharingDotNet package
@@ -174,6 +156,73 @@ Afterwards, use the function `Reconstruction` to re-construct the original secre
174156
175157
The length of the shares is based on the security level. It's possible to pre-define a security level by `ctor` or the `SecurityLevel` property. The pre-defined security level will be overriden, if the secret size is greater than the Mersenne prime, which is calculated by means of the security level. It is not necessary to define a security level for a re-construction.
176158
159+
## Attention: Breaking change - Normal and legacy mode in v0.7.0
160+
161+
Library version 0.7.0 introduces a normal mode and a legacy mode for secrets. The normal mode is the new and default mode. The legacy mode is for backward compatibility.
162+
163+
*Why was the normal mode introduced?*
164+
165+
The normal mode supports positive secret values and also negative secret values like negative integer numbers or byte arrays with most significant byte greater than 0x7F. The legacy mode generates shares that can't be used to reconstruct negative secret values. So the original secret and the reconstructed secret aren't identical for negative secret values (e.g. `BigInetger secret = -2000`). The legacy mode only returns correct results for positive secret values.
166+
167+
*Mode overview*
168+
169+
* **Normal mode** (`Secret.LegacyMode.Value = false`):
170+
* Shares generated with v0.7.0 or later *cannot* be used with v0.6.0 or earlier to reconstruct the secret.
171+
* Shares generated with v0.6.0 or earlier *cannot* be used with v0.7.0 or later to reconstruct the secret.
172+
* This mode supports security level 13 as minimum.
173+
* **Legacy mode:** (`Secret.LegacyMode.Value = true`):
174+
* Shares generated with v0.7.0 or later *can* be used with v0.6.0 or earlier to reconstruct the secret.
175+
* Shares generated with v0.6.0 or earlier *can* be used with v0.7.0 or later to reconstruct the secret.
176+
* This mode supports security level 5 as minimum.
177+
178+
A mixed mode is not possible. It is recommended to reconstruct the secret with the old procedure and to split again with the new procedure.
179+
180+
The legacy mode is thread-safe, but not task-safe.
181+
182+
For further details see the example below:
183+
184+
```csharp
185+
using System;
186+
using System.Collections.Generic;
187+
using System.Linq;
188+
using System.Numerics;
189+
190+
using SecretSharingDotNet.Cryptography;
191+
using SecretSharingDotNet.Math;
192+
193+
namespace LegacyModeExample
194+
{
195+
public class Program
196+
{
197+
public static void Main(string[] args)
198+
{
199+
//// Legacy mode on / normal mode off
200+
Secret.LegacyMode.Value = true
201+
try
202+
{
203+
var gcd = new ExtendedEuclideanAlgorithm<BigInteger>();
204+
205+
var split = new ShamirsSecretSharing<BigInteger>(gcd);
206+
207+
string password = "Hello World!!";
208+
209+
var shares = split.MakeShares(3, 7, password);
210+
211+
var combine = new ShamirsSecretSharing<BigInteger>(gcd);
212+
var subSet = shares.Where(p => p.X.IsEven).ToList();
213+
var recoveredSecret = combine.Reconstruction(subSet.ToArray());
214+
215+
}
216+
finally
217+
{
218+
//// Legacy mode off / normal mode on
219+
Secret.LegacyMode.Value = false
220+
}
221+
}
222+
}
223+
}
224+
```
225+
177226
## Random secret
178227
Create a random secret in conjunction with the generation of shares. The length of the generated shares and of the secret are based on the security level. Here is an example with a pre-defined security level of 127:
179228
```csharp
@@ -339,25 +388,25 @@ dotnet test -c Debug SecretSharingDotNet5.sln
339388
dotnet test -c Release SecretSharingDotNet5.sln
340389
```
341390

342-
## Using MSBuild to build for .NET FX 4.5.2
391+
## Using MSBuild to build for .NET FX 4.6.2
343392
Use one of the following solutions with `msbuild` to build [SecretSharingDotNet](#secretsharingdotnet):
344-
* `SecretSharingDotNetFx4.5.2.sln`
393+
* `SecretSharingDotNetFx4.6.2.sln`
345394

346395
Currently unit testing with MSBuild isn't possible.
347396

348397
The syntax is:
349398
```dotnetcli
350-
msbuild /p:RestorePackagesConfig=true;Configuration={Debug|Release} /t:restore;build SecretSharingDotNetFx4.5.2.sln
399+
msbuild /p:RestorePackagesConfig=true;Configuration={Debug|Release} /t:restore;build SecretSharingDotNetFx4.6.2.sln
351400
```
352401

353402
### Build Debug configuration
354403

355404
```dotnetcli
356-
msbuild /p:RestorePackagesConfig=true;Configuration=Debug /t:restore;build SecretSharingDotNetFx4.5.2.sln
405+
msbuild /p:RestorePackagesConfig=true;Configuration=Debug /t:restore;build SecretSharingDotNetFx4.6.2.sln
357406
```
358407

359408
### Build Release configuration
360409

361410
```dotnetcli
362-
msbuild /p:RestorePackagesConfig=true;Configuration=Release /t:restore;build SecretSharingDotNetFx4.5.2.sln
411+
msbuild /p:RestorePackagesConfig=true;Configuration=Release /t:restore;build SecretSharingDotNetFx4.6.2.sln
363412
```

SecretSharingDotNetFx4.5.2.sln SecretSharingDotNetFx4.6.2.sln

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ Microsoft Visual Studio Solution File, Format Version 12.00
33
# Visual Studio Version 16
44
VisualStudioVersion = 16.0.29102.190
55
MinimumVisualStudioVersion = 10.0.40219.1
6-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SecretSharingDotNetFx4.5.2", "src\SecretSharingDotNetFx4.5.2.csproj", "{1C21B99C-2DE4-4CA5-B4CE-BC95CF89369E}"
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SecretSharingDotNetFx4.6.2", "src\SecretSharingDotNetFx4.6.2.csproj", "{1C21B99C-2DE4-4CA5-B4CE-BC95CF89369E}"
77
EndProject
8-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SecretSharingDotNetFx4.5.2Test", "tests\SecretSharingDotNetFx4.5.2Test.csproj", "{70290CC4-75A1-4609-AFCA-F1343D889A0E}"
8+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SecretSharingDotNetFx4.6.2Test", "tests\SecretSharingDotNetFx4.6.2Test.csproj", "{70290CC4-75A1-4609-AFCA-F1343D889A0E}"
99
EndProject
1010
Global
1111
GlobalSection(SolutionConfigurationPlatforms) = preSolution

src/Cryptography/FinitePoint.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ public FinitePoint(Calculator<TNumber> x, Calculator<TNumber> y)
165165
/// <returns></returns>
166166
public int CompareTo(FinitePoint<TNumber> other)
167167
{
168-
return ((this.X * this.X + this.Y * this.Y).Sqrt - (other.X * other.X + other.Y * other.Y).Sqrt).Sign;
168+
return ((this.X.Pow(2) + this.Y.Pow(2)).Sqrt - (other.X.Pow(2) + other.Y.Pow(2)).Sqrt).Sign;
169169
}
170170

171171
/// <summary>

0 commit comments

Comments
 (0)