-
Notifications
You must be signed in to change notification settings - Fork 8
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
privateKeyMalformed #7
Comments
@loekTheDreamer You need to use something like this to convert a hex encoded private key to a UInt8 Array. If you replace the second line with the implementation I linked or any other hex to UInt8 Array conversion, it should work out smoothly. If not, let me know. |
Good afternoon. Thank you so much for assisting me, ive been struggling with this problem for a couple of weeks now. I had a look at the link you provided. Unfortunately it seems that there are some errors i dont know how to solve: I then searched online and opted for this solution: extension StringProtocol {
var hexaData: Data { .init(hexa) }
var hexaBytes: [UInt8] { .init(hexa) }
private var hexa: UnfoldSequence<UInt8, Index> {
sequence(state: startIndex) { startIndex in
guard startIndex < self.endIndex else { return nil }
let endIndex = self.index(startIndex, offsetBy: 2, limitedBy: self.endIndex) ?? self.endIndex
defer { startIndex = endIndex }
return UInt8(self[startIndex..<endIndex], radix: 16)
}
}
} usage: let privateKey = "583e8853014aa2c53e031f213a4075efb59cb4d0541674d87bdf49d170f46eb4"
let privateKeyByteArray = privateKey.hexaBytes
let keystore = try! Keystore(privateKey: privateKeyByteArray, password: password) It then produces a keystore shape and there are no errors in xcode. But unfortunately when I try unlock it on 3rd party wallet provider I get the following error: Is there something wrong with the unit8 array passed to the keystore object or could there be something else that I am not doing correctly? Thank you for your time. |
cant create a keystore from private key: error is private key malformed
code used:
please assist.
The text was updated successfully, but these errors were encountered: