Relax size contraint of Proof in InputProofModel
MODIFY
WalletWasabi.Tests/UnitTests/Crypto/OwnershipProofTest.cs
WalletWasabi.Tests/UnitTests/Crypto/OwnershipProofTest.cs
@@ -24,7 +24,7 @@ namespace WalletWasabi.Tests.UnitTests.Crypto
var ownershipProofBytes = Encoders.Hex.DecodeData("534c00190001a122407efc198211c81af4450f40b235d54775efd934d16b9e31c6ce9bad57070002483045022100e5eaf2cb0a473b4545115c7b85323809e75cb106175ace38129fd62323d73df30220363dbc7acb7afcda022b1f8d97acb8f47c42043cfe0595583aa26e30bc8b3bb50121032ef68318c8f6aaa0adec0199c69901f0db7d3485eb38d9ad235221dc3d61154b");
Assert.True(ownershipProofBytes.SequenceEqual(ownershipProof.ToBytes()));
- var deserializedOwnershipProof = OwnershipProof.FromBytes(ownershipProofBytes);;
+ var deserializedOwnershipProof = OwnershipProof.FromBytes(ownershipProofBytes);
Assert.True(ownershipProofBytes.SequenceEqual(deserializedOwnershipProof.ToBytes()));
}

ADD
WalletWasabi/CoinJoin/Common/Models/InputOwnershipProofModel.cs
+using NBitcoin;
+using Newtonsoft.Json;
+using System.ComponentModel.DataAnnotations;
+using WalletWasabi.JsonConverters;
+
+namespace WalletWasabi.CoinJoin.Common.Models
+{
+ public class InputOwnershipProofModel
+ {
+ [Required]
+ [JsonConverter(typeof(OutPointAsTxoRefJsonConverter))]
+ public OutPoint Input { get; set; }
+
+ // Minimum length of P2WPHK proof of ownership is (4 + 1 + 1 + 32) + (1 + 1 + 1 + (1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1) + 1 + 33) = 84
+ // Typical length of P2WPHK proof of ownership is (4 + 1 + 1 + 32) + (1 + 1 + 1 + (1 + 1 + 1 + 1 + 32 + 1 + 1 + 32 + 1) + 1 + 33) = 147
+ // Maximum length of P2WPHK proof of ownership is (4 + 1 + 1 + 32) + (8 + 8 + 8 + (1 + 1 + 1 + 1 + 33 + 1 + 1 + 33 + 1) + 8 + 33) = 176
+ [Required]
+ [MinLength(84, ErrorMessage = "Provided proof is invalid")]
+ [MaxLength(176, ErrorMessage = "Provided proof is invalid")]
+ [JsonConverter(typeof(ByteArrayJsonConverter))]
+ public byte[] Proof { get; set; }
+ }
+}

MODIFY
WalletWasabi/Crypto/Bip322Signature.cs
WalletWasabi/Crypto/Bip322Signature.cs
@@ -18,6 +18,10 @@ namespace WalletWasabi.Crypto
{
}
+ public Script ScriptSig => scriptSig;
+
+ public WitScript Witness => witness;
+
public void ReadWrite(BitcoinStream bitcoinStream)
{
bitcoinStream.ReadWrite(ref scriptSig);
@@ -31,33 +35,32 @@ namespace WalletWasabi.Crypto
}
}
- public Script ScriptSig => scriptSig;
-
- public WitScript Witness => witness;
-
public bool Verify(uint256 hash, Script scriptPubKey)
{
if (scriptPubKey.IsScriptType(ScriptType.P2WPKH))
{
if (ScriptSig.Length != 0)
+ {
return false;
+ }
var witnessParameters = PayToWitPubKeyHashTemplate.Instance.ExtractWitScriptParameters(Witness);
- if (witnessParameters == null)
+ if (witnessParameters is null)
+ {
return false;
+ }
if (witnessParameters.PublicKey.GetScriptPubKey(ScriptPubKeyType.Segwit) != scriptPubKey)
+ {
return false;
+ }
// if (witnessParameters.TransactionSignature.SigHash != SigHash.All)
// return false;
- if (!witnessParameters.PublicKey.Verify(hash, witnessParameters.TransactionSignature.Signature))
- return false;
-
- return true;
+ return witnessParameters.PublicKey.Verify(hash, witnessParameters.TransactionSignature.Signature);
}
- else
+
throw new NotImplementedException();
}

MODIFY
WalletWasabi/Crypto/OwnershipProof.cs
WalletWasabi/Crypto/OwnershipProof.cs
@@ -34,14 +34,14 @@ namespace WalletWasabi.Crypto
public class CoinJoinInputCommitmentData
{
private byte[] coordinatorIdentifier;
- private long roundIdentifier;
+ private byte[] roundIdentifier;
- public CoinJoinInputCommitmentData(string coordinatorIdentifier, long roundIdentifier)
- : this (Encoding.ASCII.GetBytes(coordinatorIdentifier), roundIdentifier)
+ public CoinJoinInputCommitmentData(string coordinatorIdentifier, Guid roundIdentifier)
+ : this (Encoding.ASCII.GetBytes(coordinatorIdentifier), roundIdentifier.ToByteArray())
{
}
- public CoinJoinInputCommitmentData(byte[] coordinatorIdentifier, long roundIdentifier)
+ public CoinJoinInputCommitmentData(byte[] coordinatorIdentifier, byte[] roundIdentifier)
{
this.coordinatorIdentifier = coordinatorIdentifier;
this.roundIdentifier = roundIdentifier;
@@ -50,7 +50,7 @@ namespace WalletWasabi.Crypto
public byte[] ToBytes() =>
BitConverter.GetBytes(coordinatorIdentifier.Length)
.Concat(coordinatorIdentifier)
- .Concat(BitConverter.GetBytes(roundIdentifier))
+ .Concat(roundIdentifier)
.ToArray();
}

Relax size contraint of Proof in InputProofModel