Start implementing signing
MODIFY
HiddenWallet.ChaumianTumbler/Controllers/TumblerController.cs
HiddenWallet.ChaumianTumbler/Controllers/TumblerController.cs
@@ -315,7 +315,7 @@ namespace HiddenWallet.ChaumianTumbler.Controllers
return new ObjectResult(new CoinJoinResponse
{
- Transaction = Global.StateMachine.CoinJoin.ToHex()
+ Transaction = Global.StateMachine.UnsignedCoinJoin.ToHex()
});
}
catch (Exception ex)
@@ -324,9 +324,10 @@ namespace HiddenWallet.ChaumianTumbler.Controllers
}
}
+ private readonly AsyncLock SignatureProvidedAsyncLock = new AsyncLock();
[Route("signature")]
[HttpPost]
- public IActionResult Signature(SignatureRequest request)
+ public async Task<IActionResult> SignatureAsync(SignatureRequest request)
{
try
{
@@ -336,9 +337,34 @@ namespace HiddenWallet.ChaumianTumbler.Controllers
}
if (request.UniqueId == null) return new BadRequestResult();
- if (request.Signature == null) return new BadRequestResult();
+ if (request.Signatures == null) return new BadRequestResult();
+ if (request.Signatures.Count() == 0) return new BadRequestResult();
Alice alice = Global.StateMachine.FindAlice(request.UniqueId, throwException: true);
+ using (await SignatureProvidedAsyncLock.LockAsync())
+ {
+ if (Global.StateMachine.CoinJoinToSign == null)
+ {
+ foreach(var input in Global.StateMachine.UnsignedCoinJoin.Inputs)
+ {
+ Global.StateMachine.CoinJoinToSign.AddInput(input);
+ }
+ foreach (var output in Global.StateMachine.UnsignedCoinJoin.Outputs)
+ {
+ Global.StateMachine.CoinJoinToSign.AddOutput(output);
+ }
+ }
+
+ foreach (var signatureHex in request.Signatures)
+ {
+ var signature = HexHelpers.GetBytes(signatureHex);
+
+ // todo find input
+ // add signature
+ // check if correctly signed
+ }
+ }
+
throw new NotImplementedException();
}
catch (Exception ex)

MODIFY
HiddenWallet.ChaumianTumbler/Models/SignatureRequest.cs
HiddenWallet.ChaumianTumbler/Models/SignatureRequest.cs
@@ -8,6 +8,6 @@ namespace HiddenWallet.ChaumianTumbler.Models
public class SignatureRequest
{
public string UniqueId { get; set; }
- public string Signature { get; set; }
+ public IEnumerable<string> Signatures { get; set; }
}
}

MODIFY
HiddenWallet.ChaumianTumbler/TumblerStateMachine.cs
HiddenWallet.ChaumianTumbler/TumblerStateMachine.cs
@@ -28,7 +28,8 @@ namespace HiddenWallet.ChaumianTumbler
public Stopwatch InputRegistrationStopwatch { get; private set; }
public bool FallBackRound { get; private set; } = false;
- public Transaction CoinJoin { get; private set; } = null;
+ public Transaction UnsignedCoinJoin { get; private set; } = null;
+ public Transaction CoinJoinToSign { get; set; } = null;
private SmartBitClient SmartBitClient { get; } = new SmartBitClient(Network.Main);
public ConcurrentHashSet<Alice> Alices { get; private set; }
@@ -138,7 +139,7 @@ namespace HiddenWallet.ChaumianTumbler
}
FallBackRound = false;
UpdatePhase(TumblerPhase.InputRegistration);
- CoinJoin = null;
+ UnsignedCoinJoin = null;
break;
}
default:
@@ -171,7 +172,7 @@ namespace HiddenWallet.ChaumianTumbler
}
var builder = new TransactionBuilder();
- CoinJoin = builder
+ UnsignedCoinJoin = builder
.ContinueToBuild(transaction)
.Shuffle()
.BuildTransaction(false);

Start implementing signing