Skip to content

Synchronised RainbowSloth Swift package

Notifications You must be signed in to change notification settings

lambdapioneer/sloth-ios

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Sloth: iOS

We have implemented the SE-backed key stretching scheme RainbowSloth for iOS 15+. This folder gets synced into a designated repository to allow inclusion as a Swift package dependency.

For changes refer to the main repository here: https://github.com/lambdapioneer/sloth

Setting up

Add this repository as a dependency to your Package.swift file like so:

    dependencies: [
        // ...
        .package(url: "https://github.com/lambdapioneer/sloth-ios.git", from: "0.3.0"),
    ],
    targets: [
        .target(
            name: "YourAppTarget",
            dependencies: [
                // ...
                .product(name: "RainbowSloth", package: "sloth-ios")
            ],
            // ...
        )
        // ...
    ]

Using RainbowSloth

After adding the dependency you can import the library in the respective .swift files and use it:

import RainbowSloth

// create a new Sloth instance
let sloth = RainbowSloth(withN: 100) // see paper on how to choose `n`

// create a new key
let (storageState, key) = try sloth.keygen(
    pw: "user-passphrase",
    handle: "your-identifier",
    outputLength: 32
)

// re-derive the same key later
let key = try sloth.derive(
    storageState: storageState,
    pw: "user-passphrase",
    outputLength: 32
)