Fix ownership proofs
MODIFY
WalletWasabi.Tests/UnitTests/Crypto/OwnershipProofTest.cs
WalletWasabi.Tests/UnitTests/Crypto/OwnershipProofTest.cs
@@ -23,7 +23,7 @@ public class OwnershipProofTest
var ownershipProof = OwnershipProof.Generate(key, ownershipIdentifier, commitmentData, false, ScriptPubKeyType.Segwit);
var scriptPubKey = PayToWitPubKeyHashTemplate.Instance.GenerateScriptPubKey(key.PubKey);
- var ownershipProofBytes = Encoders.Hex.DecodeData("534c00190001a122407efc198211c81af4450f40b235d54775efd934d16b9e31c6ce9bad57070002483045022100e5eaf2cb0a473b4545115c7b85323809e75cb106175ace38129fd62323d73df30220363dbc7acb7afcda022b1f8d97acb8f47c42043cfe0595583aa26e30bc8b3bb50121032ef68318c8f6aaa0adec0199c69901f0db7d3485eb38d9ad235221dc3d61154b");
+ var ownershipProofBytes = Encoders.Hex.DecodeData("534c00190001a122407efc198211c81af4450f40b235d54775efd934d16b9e31c6ce9bad57070002483045022100c0dc28bb563fc5fea76cacff75dba9cb4122412faae01937cdebccfb065f9a7002202e980bfbd8a434a7fc4cd2ca49da476ce98ca097437f8159b1a386b41fcdfac50121032ef68318c8f6aaa0adec0199c69901f0db7d3485eb38d9ad235221dc3d61154b");
Assert.True(ownershipProofBytes.SequenceEqual(ownershipProof.ToBytes()));
var deserializedOwnershipProof = OwnershipProof.FromBytes(ownershipProofBytes);

MODIFY
WalletWasabi/Crypto/ProofBody.cs
WalletWasabi/Crypto/ProofBody.cs
using NBitcoin;
using NBitcoin.Crypto;
+using NBitcoin.Protocol;
using System.Collections.Generic;
using System.Linq;
@@ -49,8 +50,14 @@ public class ProofBody : IBitcoinSerializable, IEquatable<ProofBody>
public uint256 SignatureHash(Script scriptPubKey, byte[] commitmentData) =>
new(Hashes.SHA256(this.ToBytes().Concat(ProofFooter(scriptPubKey, commitmentData)).ToArray()));
- private static IEnumerable<byte> ProofFooter(Script scriptPubKey, byte[] commitmentData) =>
- scriptPubKey.ToBytes().Concat(commitmentData);
+ private static IEnumerable<byte> ProofFooter(Script scriptPubKey, byte[] commitmentData)
+ {
+ var scriptPubKeyBytes = scriptPubKey.ToBytes();
+ var scriptPubKeyPrefix = new VarInt((ulong)scriptPubKeyBytes.Length).ToBytes();
+ var commitmentDataPrefix = new VarInt((ulong)commitmentData.Length).ToBytes();
+
+ return scriptPubKeyPrefix.Concat(scriptPubKeyBytes).Concat(commitmentDataPrefix).Concat(commitmentData);
+ }
public override int GetHashCode()
{

Fix ownership proofs