The DNSP Embedded Wallet is a Swift Package that supports the following basic features:
- Creating new keys
- Loading existing keys
- Importing keys
- Exporting keys
- Signing messages
- From XCode, select File > Add Packages. Enter
https://github.com/LibertyDSNP/dsnp-embedded-wallet-swift
as the package URL. - Once the SDK has been added to your project, import using:
import DSNPWallet
- Generate seed phrase. Example: offer work butter trick cart stereo merit direct soon leader estate hint brown hidden patch
- Get key from Secure Enclave (load existing or create new).
- Encrypt seed phrase against this key.
- Store encrypted phrase in keychain.
do {
let keys = try DSNPWallet().createKeys()
} catch {
// error
}
- Get encrypted seed phrase from keychain.
- Get key from Secure Enclave.
- Decrypt seed phrase against this key.
- Create key from seed phrase.
do {
let keys = try DSNPWallet().loadKeys()
} catch {
// error
}
- Decrypt seed phrase against Secure Enclave key.
- Create a symmetric key using a user-provided password.
- “Seal” the seed phrase with password using ChaChaPoly (a ChaCha20-Poly1305 cipher).
- Save encrypted data to file and offer user the ability to save file to desired storage.
do {
let exportData = try? DSNPWallet().exportKeys(password: PASSWORD)
} catch {
// error
}
- Provide ability to attach encrypted data file, along with password input.
- Create a symmetric key using a user-provided password.
- Decrypt the file with password using ChaChaPoly.
- Create a new key using decrypted seed phrase.
do {
let keys = try DSNPWallet().importKeys(data: ENCRYPTED_DATA, password: PASSWORD)
} catch {
// error
}
Copyright 2022 Unfinished Labs LLC
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.