Open keithpiong opened 6 years ago
@pixelmatrix Do you know the keystore implementation? I never worked with it directly so I don't know exactly what we would need for it.
Some questions I have are:
Ok that's it for now...If you haven't used it before I will try and search some specifications.
Hey @Ybrin, i'm not really sure about the keystore. Our keys are all managed server side so we avoid needing to use that. Is this referring to iOS Keychain or something else?
@pixelmatrix No I think he is talking about the files geth generates (also MEW I think?) if you create a new wallet.
This one: https://medium.com/@julien.m./what-is-an-ethereum-keystore-file-86c8c5917b97
Interesting… it doesn't seem like there's a json rpc method for that, so you'd need direct access to the node's filesystem somehow. Assuming you had the json file, is the request for being able to parse that file into an EthereumPrivateKey
object?
I think the assumption is that you have the json file either on your file system or already in memory as an instance of Data and want to extract the actual private key (with a given passphrase) from it to create an EthereumPrivateKey.
On Wed, May 30, 2018, 21:01 Josh Pyles notifications@github.com wrote:
Interesting… it doesn't seem like there's a json rpc method for that, so you'd need direct access to the node's filesystem somehow. Assuming you had the json file, is the request for being able to parse that file into an EthereumPrivateKey object?
— You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub https://github.com/Boilertalk/Web3.swift/issues/28#issuecomment-393279554, or mute the thread https://github.com/notifications/unsubscribe-auth/AK1JzYGJ9-83fNDkVdS5uK5CLG3MePT8ks5t3uyAgaJpZM4UTn4V .
Could you please confirm this @keithpiong
On Wed, May 30, 2018, 21:01 Josh Pyles notifications@github.com wrote:
Interesting… it doesn't seem like there's a json rpc method for that, so you'd need direct access to the node's filesystem somehow. Assuming you had the json file, is the request for being able to parse that file into an EthereumPrivateKey object?
— You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub https://github.com/Boilertalk/Web3.swift/issues/28#issuecomment-393279554, or mute the thread https://github.com/notifications/unsubscribe-auth/AK1JzYGJ9-83fNDkVdS5uK5CLG3MePT8ks5t3uyAgaJpZM4UTn4V .
Yes, @Ybrin is right. I have been using Geth to create wallet and I am able to use the export and import key function. And yes, the keystore are JSON encoded. Can be found with the link below:
https://github.com/ethereum/go-ethereum/wiki/Mobile:-Account-management
I understand that if I were to keep the keystore file, it is much more secure instead of keeping my private key. However, it gets a bit complicated when it comes to signing & sending transactions because signing the transaction requires the private key (as hex string) which is encrypted inside the JSON encoded keystore (AES - 128 - ctr).
So the clearer question to ask is: During the signing process, is there a simpler method to decrypt the keystore file (with relevant passphrase of course) and extract the private key? Can CryptoSwift able to handle this decryption process alone?
Ok I did some research and it seems like this javascript implementation is exactly what we want.
Basically recover
is the function which converts the keystore file into a private key with a given password. It also checks the MAC in order to make sure the given password is correct for the encryption.
We will need a scrypt implementation, which is not included in CryptoSwift.
I think the official C implementation is the way to go. Using C libraries in Swift is very easy and we will only need it to derive the keys from passwords so this is not a huge problem.
@Zimonzk Could you please have a look through the C library and let me know how to use it as a KDF?
@Florian-S-A-W Could you please go through the js implementation and let me know if I'm missing something?
Finally, I think this feature is something we could put into a separate repository as it really doesn't depend on anything in Web3 and nothing in Web3 depends on it. I will link it there once we decided to create it.
I think you are not missing anything in the JS implementation. Note that recover returns the private key as a buffer, I suggest you take a look at: https://nodejs.org/api/buffer.html#buffer_class_buffer
@keithpiong Check out https://github.com/Boilertalk/Keystore.swift
Thank you so much for this enhancement.. however, i couldn't install it through cocoapods. It returns:
[!] Unable to find a specification for Keystore
after pod install
Run pod repo update
and then again pod install
On Fri, Jul 6, 2018, 10:26 keithpiong notifications@github.com wrote:
Thank you so much for this enhancement.. however, i couldn't install it through cocoapods. It returns:
[!] Unable to find a specification for Keystore
after pod install
— You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub https://github.com/Boilertalk/Web3.swift/issues/28#issuecomment-402964709, or mute the thread https://github.com/notifications/unsubscribe-auth/AK1Jzb3AsgErqCdehzNr53qTFyXk3A7Iks5uDx9IgaJpZM4UTn4V .
let privateKey = try? (key.privateKey(password: password))
For above mentioned line of code to get private key it is taking almost 6minutes. please help me out here.
@vickyiosdev You'll have to production compile your app. It will greatly reduced the time it takes to encrypt/decrypt. On a normal iPhone it should be just a few seconds (1-5). This is an issue with the underlying hashing and encryption libraries we use. They are really inefficient if compiled without the optimization flags...
On Mon, Feb 18, 2019, 6:34 AM vickyiosdev <notifications@github.com wrote:
let privateKey = try? (key.privateKey(password: password))
For above mentioned line of code to get private key it is taking almost 6minutes. please help me out here.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/Boilertalk/Web3.swift/issues/28#issuecomment-464591484, or mute the thread https://github.com/notifications/unsubscribe-auth/AK1JzY6TeWmvfNijS3zi6QgNKatlruZLks5vOjtwgaJpZM4UTn4V .
@Ybrin Thanks. In release mode it is taking 10-15seconds.
You could manually add maximum optimization flags to the debug build. But you should really fix your release build at some point. Is the crash in any way related to Web3 or Keystore? I need the logs to help you...
On Mon, Feb 18, 2019, 5:46 PM vickyiosdev <notifications@github.com wrote:
@Ybrin https://github.com/Ybrin Thanks, In debug mode should we change any flags in Xcode. In release mode app is crashing. please help me out here.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/Boilertalk/Web3.swift/issues/28#issuecomment-464805942, or mute the thread https://github.com/notifications/unsubscribe-auth/AK1Jzbh4V1eSUoRna9Tyk5qMMApKXKSEks5vOtjVgaJpZM4UTn4V .
You could manually add maximum optimization flags to the debug build. But you should really fix your release build at some point. Is the crash in any way related to Web3 or Keystore? I need the logs to help you... …
Fixed Crash issues. @Ybrin Could you please provide clear idea on optimization flags, which flags i need to update in Xcode. Thanks.
@Ybrin Unable to show activity indicator while extracting private key. UI is getting freeze. Note: In main thread I'm enabling activity indicator.
Could you please help me out here.
if only there's a simpler way to extract private keys directly from keystore