Use System.Numerics instead of BC
MODIFY
WalletWasabi.Tests/UnitTests/JsonConvertersTest/UnblindedSignatureTests.cs
WalletWasabi.Tests/UnitTests/JsonConvertersTest/UnblindedSignatureTests.cs
@@ -22,7 +22,7 @@ namespace WalletWasabi.Tests.UnitTests.JsonConverters
var key = new Key();
var signer = new SchnorrBlinding.Signer(key, r);
- foreach (var i in Enumerable.Range(0, 1_000))
+ foreach (var i in Enumerable.Range(0, 100))
{
var requester = new SchnorrBlinding.Requester();
@@ -38,7 +38,6 @@ namespace WalletWasabi.Tests.UnitTests.JsonConverters
using var reader = new JsonTextReader(new StringReader(sb.ToString()));
var convertedUnblindedSignature = (UnblindedSignature)converter.ReadJson(reader, null, null, null);
-
Assert.Equal(unblindedSignature.C, convertedUnblindedSignature.C);
Assert.Equal(unblindedSignature.S, convertedUnblindedSignature.S);
}

MODIFY
WalletWasabi/JsonConverters/UnblindedSignatureJsonConverter.cs
WalletWasabi/JsonConverters/UnblindedSignatureJsonConverter.cs
-using NBitcoin.BouncyCastle.Math;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.Linq;
+using System.Numerics;
using WalletWasabi.Crypto;
namespace WalletWasabi.JsonConverters
@@ -20,11 +20,11 @@ namespace WalletWasabi.JsonConverters
{
JArray arr = JArray.Load(reader);
- var cs = new BigInteger(arr[0].Value<string>());
- var ss = new BigInteger(arr[1].Value<string>());
+ var cs = BigInteger.Parse(arr[0].Value<string>());
+ var ss = BigInteger.Parse(arr[1].Value<string>());
- var carr = cs.ToByteArrayUnsigned();
- var sarr = ss.ToByteArrayUnsigned();
+ var carr = cs.ToByteArray(true, true);
+ var sarr = ss.ToByteArray(true, true);
carr = new byte[32 - carr.Length].Concat(carr).ToArray();
sarr = new byte[32 - sarr.Length].Concat(sarr).ToArray();
@@ -38,9 +38,9 @@ namespace WalletWasabi.JsonConverters
/// <inheritdoc />
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
{
- var signature = ((UnblindedSignature)value).ToString();
- var c = new BigInteger(signature[..64], 16);
- var s = new BigInteger(signature[64..], 16);
+ var signature = (UnblindedSignature)value;
+ var c = new BigInteger(signature.C.ToBytes(), isUnsigned: true, isBigEndian: true);
+ var s = new BigInteger(signature.S.ToBytes(), isUnsigned: true, isBigEndian: true);
writer.WriteStartArray();
writer.WriteValue(c.ToString());
writer.WriteValue(s.ToString());

Use System.Numerics instead of BC