Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: WalletWasabi/NWabiSabi
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: master
Choose a base ref
...
head repository: trezor/NWabiSabi
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref
Able to merge. These branches can be automatically merged.
  • 1 commit
  • 7 files changed
  • 1 contributor

Commits on May 2, 2023

  1. Copy the full SHA
    7ee3856 View commit details
5 changes: 5 additions & 0 deletions WabiSabi/Collections/ImmutableValueSequence.cs
Original file line number Diff line number Diff line change
@@ -12,6 +12,11 @@ namespace WabiSabi.Collections;
{
private readonly ImmutableArray<T> _elements;

public ImmutableValueSequence()
{
_elements = ImmutableArray<T>.Empty;
}

public ImmutableValueSequence(IEnumerable<T> sequence)
{
_elements = sequence.ToImmutableArray();
2 changes: 2 additions & 0 deletions WabiSabi/CredentialRequesting/CredentialsResponse.cs
Original file line number Diff line number Diff line change
@@ -2,6 +2,7 @@ namespace WabiSabi.CredentialRequesting;

using Crypto;
using Crypto.ZeroKnowledge;
using Newtonsoft.Json;

/// <summary>
/// Represents a response message for the WabiSabi unified registration protocol.
@@ -13,6 +14,7 @@ namespace WabiSabi.CredentialRequesting;
/// </remarks>
public class CredentialsResponse
{
[JsonConstructor]
public CredentialsResponse(IEnumerable<MAC> issuedCredentials, IEnumerable<Proof> proofs)
{
IssuedCredentials = issuedCredentials;
Original file line number Diff line number Diff line change
@@ -2,13 +2,15 @@ namespace WabiSabi.CredentialRequesting;

using Crypto;
using Crypto.ZeroKnowledge;
using Newtonsoft.Json;

/// <summary>
/// Maintains the state needed to validate the credentials once the coordinator
/// issues them.
/// </summary>
public record CredentialsResponseValidation
{
[JsonConstructor]
internal CredentialsResponseValidation(
Transcript transcript,
IEnumerable<Credential> presented,
@@ -22,6 +24,7 @@ internal CredentialsResponseValidation(
/// <summary>
/// The transcript in the correct state that must be used to validate the proofs presented by the coordinator.
/// </summary>
[JsonProperty("transcript")]
internal Transcript Transcript { get; }

/// <summary>
13 changes: 11 additions & 2 deletions WabiSabi/Crypto/StrobeProtocol/Strobe.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using Newtonsoft.Json;
using System.Runtime.InteropServices;
using System.Text;
using WabiSabi.Helpers;
@@ -15,9 +16,16 @@ public sealed class Strobe128
// Let ˆr=r/8−2. This is the portion of the rate which is used for user data, measured in bytes.
private const byte SpongeRate = 166;

[JsonProperty("state")]
private readonly byte[] _state = new byte[25 * 8]; // this is the block size used by keccak-f1600.

[JsonProperty("position")]
private byte _position = 0;

[JsonProperty("beginPosition")]
private byte _beginPosition = 0;

[JsonProperty("currentFlags")]
private StrobeFlags _currentFlags = 0;

public Strobe128(string procotol)
@@ -32,6 +40,7 @@ public Strobe128(string procotol)
AddAssociatedMetaData(Encoding.UTF8.GetBytes(procotol), false);
}

[JsonConstructor]
private Strobe128(byte[] state, StrobeFlags flags, byte beginPosition, byte position)
{
Buffer.BlockCopy(state, 0, _state, 0, _state.Length);
@@ -74,12 +83,12 @@ public void Key(byte[] data, bool more)
BeginOperation(StrobeFlags.A | StrobeFlags.C, more);
Override(data);
}

public Strobe128 MakeCopy()
{
return new Strobe128(_state, _currentFlags, _beginPosition, _position);
}

internal string DumpState()
{
return ByteHelpers.ToHex(_state);
3 changes: 3 additions & 0 deletions WabiSabi/Crypto/ZeroKnowledge/Transcript.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
namespace WabiSabi.Crypto.ZeroKnowledge;

using NBitcoin.Secp256k1;
using Newtonsoft.Json;
using System.Collections.Generic;
using System.Linq;
using System.Text;
@@ -16,6 +17,7 @@ public sealed class Transcript
{
private const int KeySizeInBytes = 32;

[JsonProperty("strobe")]
private Strobe128 _strobe;

private static readonly byte[] StatementTag = Encoding.UTF8.GetBytes("statement");
@@ -41,6 +43,7 @@ public Transcript(byte[] label)
}

// Private constructor used for cloning.
[JsonConstructor]
private Transcript(Strobe128 strobe)
{
_strobe = strobe;
6 changes: 4 additions & 2 deletions WabiSabi/IssuanceValidationData.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
namespace WabiSabi;

using NBitcoin.Secp256k1;
using Newtonsoft.Json;
using Crypto.Groups;

public record IssuanceValidationData
{
internal IssuanceValidationData(long value, Scalar r, GroupElement ma)
[JsonConstructor]
internal IssuanceValidationData(long value, Scalar randomness, GroupElement ma)
{
Value = value;
Randomness = r;
Randomness = randomness;
Ma = ma;
}

3 changes: 2 additions & 1 deletion WabiSabi/WabiSabi.csproj
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net7.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="NBitcoin.Secp256k1" Version="3.1.0" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="7.0.0" />
</ItemGroup>
<ItemGroup>
<None Include="../LICENSE" Pack="true" PackagePath=""/>