Regarding the approved ZF grant proposal: UA parsing and construction library for .NET
This is now in progress at AArnott/Nerdbank.Cryptocurrencies: .NET libraries for processing Zcash and other cryptocurrencies. (github.com)
There is a lot to do, but I’m excited.
I’ve learned so far that to support UAs, I need to be able to at least parse transparent, sapling and orchard raw addresses, each of which have their own encoding rules and algorithms.
The C# implementations I’ve found for some of these algorithms include bugs and aren’t all that I’ve seen aren’t particularly optimized for performance. I’ve been referencing the ZIPs primarily and only using other code (in various coding languages) as a reference to see if my interpretation of the spec matches others’.
While simply parsing an address probably isn’t on a perf-critical path, my eventual goal for this library is to build it up for far more zcash use cases including potentially full lite wallet functionality, so I want everything to be well tested and performant.
13 Likes
I have all the lesser address encoding/decoding implemented, sufficiently for purposes of parsing and assembling UAs.
My attention is now focused on UA themselves. It looks like the hardest part is going to be F4Jumble, including its use of Blake2B. I’ll be referencing a rust implementation of F4Jumble as well as the spec.
The Blake2B implementation looks non-trivial, and there are several existing .NET implementations. I am planning to go with the most downloaded NuGet package option, which is MIT licensed: kmaragon/Konscious.Security.Cryptography (github.com).
1 Like
I have UA parsing and construction working! I’m just polishing up the API and adding tests now. Please send your critiques!
2 Likes
One area I’d particularly like feedback is on the naming of the properties on my receiver structs. For example the SaplingReceiver
has D
and Pkd
for property names. I got these from the spec. Are they good? Could they be improved?
Same for the other receivers.
The work is complete, modulo actually pushing packages, which I expect to do this week.
I renamed the repo to reflect that I refactored the work into two libraries: the Zcash one now depends on a more generally-targeted library for any cryptocurrency.
I want to experiment with hosting the .NET libraries in a Blazor web app to show off the Zcash address parsing and construction.
1 Like
The nuget packages are live.
I’m still interested in feedback on usability and cryptographic parameter naming in the library, per my earlier request.
See this library running live via Blazor in your web browser.
Yes, the site is ugly. Anyone good with HTML and CSS want to send a PR?
4 Likes
What follows in this and subsequent comments in this topic go beyond the original Zcash Community Grant. This is an interesting area for me and I want to learn as much as I can so I can be ready for the next round of grants
I have managed to recreate Zcash transparent addresses from a mnemonic that match those in real wallets using Nerdbank.Zcash . This required implementing BIP-32 (HD wallets) and BIP-39 (mnemonic seeds). I also implemented BIP-44 (standardized derivation paths).
I’m still working out what the appropriate abstractions are for the EC cryptographic types that this key derivation uses. I imagine shielded transactions don’t use the EC keys that transparent transactions do, and as I’m developing a pair of libraries (one for Zcash and one that it depends on with general cryptocurrency goodness), I’d like to design the API well.
Is there anyone familiar with the cryptography involved at least somewhat, who is interested in collaborating with me on this?
3 Likes