Swiftpack.co -  Boilertalk/Keystore.swift as Swift Package
Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
Ethereum keystore creation / private key extraction for Swift
.package(url: "https://github.com/Boilertalk/Keystore.swift.git", from: "0.2.1")

CI Status Version License Platform Carthage compatible Telegram

:alembic: Keystore

Keystore.swift makes it easy to extract private keys from Ethereum keystore files and generate keystore files from existing private keys.
This library belongs to our Swift Crypto suite. For a pure Swift Ethereum Web3 library check out Web3.swift!


Check the usage below or look through the repositories tests.



Keystore is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'Keystore'


Keystore is compatible with Carthage, a decentralized dependency manager that builds your dependencies and provides you with binary frameworks. To install it, simply add the following line to your Cartfile:

github "Boilertalk/Keystore.swift"

You will also have to install the dependencies, which can be found in our Cartfile.

Swift Package Manager

Keystore is compatible with Swift Package Manager v4 (Swift 4 and above). Simply add it to the dependencies in your Package.swift.

dependencies: [
    .package(url: "https://github.com/Boilertalk/Keystore.swift.git", from: "0.2.0")

And then add it to your target dependencies:

targets: [
        name: "MyProject",
        dependencies: ["Keystore"]),
        name: "MyProjectTests",
        dependencies: ["MyProject"])

After the installation you can import Keystore in your .swift files.

import Keystore


To extract a private key from an existing keystore file, just do the following.

import Keystore

let decoder = JSONDecoder()

let keystoreData: Data = ... // Load keystore data from file?
let keystore = try decoder.decode(Keystore.self, from: keystoreData)

let password = "your_super_secret_password"
let privateKey = try keystore.privateKey(password: password)

print(privateKey)    // Your decrypted private key

And to generate a keystore file from an existing private key, your code should look a little bit like the following.

let privateKey: [UInt8] = ... // Get your private key as a byte array

let password = "your_super_secret_password"
let keystore = try Keystore(privateKey: privateKey, password: password)

let keystoreJson = try JSONEncoder().encode(keystore)
print(String(data: keystoreJson, encoding: .utf8))       // Your encrypted keystore as a json string


The awesome guys at Boilertalk :alembic:
...and even more awesome members from the community :purple_heart:

Check out the contributors list for a complete list.


Keystore is available under the MIT license. See the LICENSE file for more info.


Stars: 12
Last commit: 2 weeks ago

Ad: Job Offers

iOS Software Engineer @ Perry Street Software
Perry Street Software is Jack’d and SCRUFF. We are two of the world’s largest gay, bi, trans and queer social dating apps on iOS and Android. Our brands reach more than 20 million members worldwide so members can connect, meet and express themselves on a platform that prioritizes privacy and security. We invest heavily into SwiftUI and using Swift Packages to modularize the codebase.

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API