Summary
TaprootKeyHelper in src/shared/Angor.Shared/Protocol/Scripts/TaprootKeyHelper.cs is a workaround for a Mono JIT bug that causes TaprootFullPubKey.Create to produce all-zero output keys on Android ARM64 and Blazor WASM.
The bug only triggers when the calling assembly targets net6.0 (NBitcoin 7.0.46). NBitcoin 10.0.4+ ships a net8.0 build that avoids the Mono JIT bug and includes the span-aliasing fix (MetacoSA/NBitcoin#1300).
Task
Once NBitcoin is upgraded to 10.0.4+:
- Remove
TaprootKeyHelper.cs
- Revert all call sites to use
PubKey.GetTaprootFullPubKey() and TaprootFullPubKey.Create() directly:
InvestmentScriptBuilder.cs
SeederScriptTreeBuilder.cs
InvestorTransactionActions.cs
FounderTransactionActions.cs
TaprootScriptBuilder.cs (revert to using treeInfo.OutputPubKey directly)
- Remove
TaprootOutputKeyTests.cs (or adapt to test NBitcoin directly)
- Consider removing
TransactionGuard.RejectAllZeroP2trOutputs or keeping as defense-in-depth
Context
Summary
TaprootKeyHelperinsrc/shared/Angor.Shared/Protocol/Scripts/TaprootKeyHelper.csis a workaround for a Mono JIT bug that causesTaprootFullPubKey.Createto produce all-zero output keys on Android ARM64 and Blazor WASM.The bug only triggers when the calling assembly targets
net6.0(NBitcoin 7.0.46). NBitcoin 10.0.4+ ships anet8.0build that avoids the Mono JIT bug and includes the span-aliasing fix (MetacoSA/NBitcoin#1300).Task
Once NBitcoin is upgraded to 10.0.4+:
TaprootKeyHelper.csPubKey.GetTaprootFullPubKey()andTaprootFullPubKey.Create()directly:InvestmentScriptBuilder.csSeederScriptTreeBuilder.csInvestorTransactionActions.csFounderTransactionActions.csTaprootScriptBuilder.cs(revert to usingtreeInfo.OutputPubKeydirectly)TaprootOutputKeyTests.cs(or adapt to test NBitcoin directly)TransactionGuard.RejectAllZeroP2trOutputsor keeping as defense-in-depthContext
docs/taproot-arm64-jit-bug.md