New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Re-target to PCL #8
Comments
I already did it for one customer, for a kick ass commercial wallet app that will release soon. (Big announcement ahead) So I can help whoever wants to try to do it. The workload for porting 80% of NBitcoin (tests included) is about 2 or 3 days.
Be careful, NBitcoin depends on Windows Crypto API for some stuff, so you'll have to use bouncy castle instead. I will help to communicate on a PCL port, can help if there is question, and would include it in Nuget, but I can't develop it myself for now. |
I see. I agree that if it has been done commercially, you should not release the code - it's been paid for, so it's not yours, per say, to release. Thing is, I do not believe I'm on a level that I could do the porting, and given I have a day job, I could not focus on learning and doing all the work, even with guidance. Though I might try. About the issues:
AFAIK WinRT includes the Crypto API, to a limited extent (though differently than WPF/desktop apps). RNG can be easily generated if you use sensor data (magnetic, light, etc.). Just spin a pseudo-RN from the platform Random(), and use that value to decide which sensor data to use for the next part of the random key. |
Porting the whole lib is considerably harder than a subset of it, so if any plan to port should be made, I think it should be released incrementally through several updates. The last % can be a real headache. For the RNG, sadly you have the same problem, because there is no unified lib accross devices to access magnetic, light and the like. It means that your solution is harder than just creating an interface around the RNG whose implementation would be plateform specific. I keep the issue open until I or someone else develop a portable lib. |
Actually, the RNG part can be solved with Win8's Sensor API. But I have a better idea for RNGs - use the camera! No need to take a picture, just run the preview for a few seconds, and use either pre-set or randomized areas (say, generate four pseudo-random numbers, from 0 to max img width and 0 to max img height of camera, then take the area pointed out by x1,y1 and x2,y2; and use the area for random numbers. As most of the cameras have pretty huge amount of noise compared to e.g. DSLRs, the noise can be random enough for truly random numbers). And indeed the darn BouncyCastle part is the biggest headache. Though as I said, the BouncyCastle-PCL package solves that issue too, and if the library only targets WinRT/WP8.1 Universal, the PCL is usable. Not so sure about WP8 Silverlight. |
Nicolas, is there any news about that commercial wallet app you mentioned? It's been almost two months and I haven't heard any big news yet :\ |
Hey, yes it will be out soon. However, I can't tell you because of non disclosure. |
Hey Nicolas... |
Fonix, I think I will soon try to work on that. I want to use the "Bait and Switch" trick, but without having to write dummy implementations. (Time waste) Also, the time I release that, their application should be shipped. Also, with a recent release I cutted the dependency on bouncycastle, so the port is easier. (I did it for performance reason actually) |
Hello, I think you should release the PCL build because this will spark the growth of Bitcoin on modern platforms (Modern in the sense of the MSFT Modern Shell) |
the shame is that mobile and modern shell does not support classical sockets. I expect people doing great stuff with gadgeteer and netduino ! :) |
Yes I do understand what you mean but I thought you had previously accomplished this? Definitely at the moment the discrepancy between sockets on WinRT and Windows Phone vs .NET does diminish this within a PCL. I in fact have a version of Bitcoinsharp which I've modified to be PCL compliant but it only generates Bitcoin addresses (I added the functionality of compressed pub key addresses as it was not supporting) but yea I had to strip the guts out of it, anything that relied on networking had to go so no transactions etc. I am thinking the future of mobile wallets involes key management on the client, with Blockchain parsing etc in the cloud. My vision is to run a service in the cloud that parses the blockchain, looks for transactions etc then send notifications back to apps on mobile devices. What are your thought? |
I agree. And yes I accomplished this for a customer which is the reason why I did not open sourced it, I basically forked NBitcoin for them. It was not very complicated. But since their wallet will soon release, I will start working on making NBitcoin on all plateform and distributable by nuget. |
Ah yes so did you create a solution for someone, like I have with just the key generation etc in a PCL? So you haven't got Block processing etc in a PCL is that right? |
I did, block processing does not depends on anything related to windows.
The rest was smooth to port. |
Nice work! Might I suggest to you to use SecureRandom in BouncyCastle as a PCL friendly method of getting crypto random bytes? I see you know about the PCL version of BouncyCastle, but then I swe in your latest code you have gone away from using BC. Any reason for the shift away from BC? |
I am glad to say that I ported the code to Portable today. Yes, there is a reason to shift away from BC : their nuget package is from 2011, and ECC operations are 100 times more perfomant on their current master (that's not a typo), but they won't release nuget package even if I pray for it and give them the freaking powershell script to do it easily. I have not tried the PCL version, but being not from the BC team, it is surely behind. Also, I stripped a lot from BC, it made the port easier. My profile is "111", this is Xamarin.iOS, Xamarin.Android, WP 8.1, Windows 8, .NET 4.5. I intend to make plateform specific assemblies later, so I can hard code the RNG depending on the plateform. |
Congrats!!! Yes I agree with you that the PCL BouncyCastle DLL will be behind and I imagine will have the performance issue you mention. Although if you are just generating the odd key here and there I don't think it is too much of an issue? Certainly if you want to do lots of keys in bulk yes. Ah I see so your PCL is in fact a even more unified version that does Android and iOS in Xamarin. My PCLs are all for the windows platform that is why I have had success with SecureRandom. I see you are creating PCLs for Android and iOS too! That's actually really awesome! |
The performance issue is not on key generation, but on signature checking and generation, which is a big problem when you are doing a web service that lots of customer will be using, you don't want the CPU to be exhausted. I will release on nuget tomorrow, please try it then on other windows plateform. |
Ah yes I get you. Yes awesome man!!! |
I have the pleasure to consider this issue as closed : http://www.reddit.com/r/Bitcoin/comments/2ont6t/nbitcoin_mac_ios_android_windows_phone_81_windows/ |
* Support for serializing block signatures * Fixing invalid endings on block files * Checking block signatures * Fix the signature POW check * Check block regardless to context * Canonical signature checks
NBitcoin currently only targets regular .Net 4.5 - which is great for desktop apps and so, but completely useless for the new WinRT platform.
It would be great if the project would be re-targeted for Windows Universal apps PCL, even as a separate branch, it would make it easier to finally have a wallet app on WP/W8.1.
The text was updated successfully, but these errors were encountered: