Swiftpack.co -  tesseract-one/Bip39.swift as Swift Package
Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
tesseract-one/Bip39.swift
Cross-platform BIP39 mnemonic implementation for Swift.
.package(url: "https://github.com/tesseract-one/Bip39.swift.git", from: "0.1.1")

Bip39.swift

🐧 linux: ready GitHub license Build Status GitHub release SPM compatible CocoaPods version Platform macOS | iOS | tvOS | watchOS | Linux

Cross-platform BIP39 mnemonic implementation for Swift.

Installation

Bip39.swift deploys to macOS, iOS, tvOS, watchOS and Linux. It has been tested on the latest OS releases only however, as the module uses very few platform-provided APIs, there should be very few issues with earlier versions.

Setup instructions:

  • Swift Package Manager: Add this to the dependency section of your Package.swift manifest:

    .package(url: "https://github.com/tesseract-one/Bip39.swift.git", from: "0.1.0")
    
  • CocoaPods: Put this in your Podfile:

    pod 'Bip39.swift', '~> 0.1'
    

Usage Examples

Random generated mnemonic

import Bip39

// 128bit mnemonic by default
let mnemonic = try! Mnemonic()

// Obtaining phrase. English by default. Returns string array
let phrase = mnemonic.mnemonic().joined(separator: " ")

print("Mnemonic: ", phrase)

Mnemonic from Bip39 string

import Bip39

// Mnemonic phrase
let phrase = "rally speed budget undo purpose orchard hero news crunch flush wine finger"

// Creating mnemonic. English wordlist by default
let mnemonic = try! Mnemonic(mnemonic: phrase.components(separatedBy: " "))

// 128 bit entropy
print("Entropy: ", mnemonic.entropy)

Seed from Mnemonic

import Bip39

// Mnemonic phrase
let phrase = "rally speed budget undo purpose orchard hero news crunch flush wine finger"

// Creating mnemonic. English wordlist by default
let mnemonic = try! Mnemonic(mnemonic: phrase.components(separatedBy: " "))

// Empty password and English wordlist by default
let seed = mnemonic.seed()

print("Seed: ", seed)

Check Bip39 string is valid

import Bip39

// Mnemonic phrase
let phrase = "rally speed budget undo purpose orchard hero news crunch flush wine finger"

// Validation. English wordlist by default
let isValid = Mnemonic.isValid(phrase: phrase.components(separatedBy: " "))

print("Valid: ", isValid)

License

Bip39.swift can be used, distributed and modified under the Apache 2.0 license.

GitHub

link
Stars: 0
Last commit: 3 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.

Release Notes

Moved C code to the different library
3 weeks ago

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