8df3500571 | ||
---|---|---|
Examples/MnemonicKitExample.playground | ||
MnemonicKit | ||
Tests | ||
.gitignore | ||
.slather.yml | ||
.swiftlint.yml | ||
.travis.yml | ||
Cartfile | ||
Cartfile.resolved | ||
Gemfile | ||
LICENSE | ||
MnemonicKit.podspec | ||
README.md | ||
codecov.yml |
README.md
MnemonicKit
An implementation of BIP39 in Swift. MnemonicKit supports both English and Chinese mnemonics.
This library is a fork of CKMnemonic. This fork provides several conveniences over the original library, namely:
- Converting throwing APIs to non-throwing nullable APIs
- Additional helper methods
- Code clarity and documentation
- Additional Testing
- Support on OSX
Installation
CocoaPods
TezosKit supports installation via CocoaPods. You can depened on MnemonicKit by adding the following to your Podfile:
pod "MnemonicKit"
Carthage
If you use Carthage to manage your dependencies, simply add
MnemonicKit to your Cartfile
:
github "keefertaylor/MnemonicKit"
If you use Carthage to build your dependencies, make sure you have added CryptoSwift.framework
to the "Linked Frameworks and Libraries" section of your target, and have included them in your Carthage framework copying build phase.
Usage
Generate a Mnemonic
let englishMnemonic = Mnemonic.generateMnemonic(strength: 64, language: .english)
let chineseMnemonic = Mnemonic.generateMnemonic(strength: 128, language: .chinese)
Generate a Mnemonic from a Hex Representation
let hexRepresentation: String = ...
let mnemonic = Mnemonic.mnemonicString(from: hexRepresentation)
print("Mnemonic: \(mnemonic)\nFrom hex string: \(hexRepresentation)")
Generate a Seed String
let englishMnemonic = Mnemonic.generateMnemonic(strength: 64, language: .english)
let passphrase: String = ...
let deterministicSeedString = Mnemonic.deterministicSeedString(from: mnemonicString,
passphrase: passphrase,
language: .english)
print("Deterministic Seed String: \(deterministicSeedString)")
Contributions
I am happy to accept pull requests. If anyone is able to reach the original authors of CKMnemonic, I am happy to merge this library upstream with them.
License
MIT