This is the module for the OpenID for Verifiable Presentations over BLE implementation to support sending vc/vp using Bluetooth Low Energy local channel.
- Add the github link as a spm package dependency in swift project.
- Select the appropriate branch/version.
Firstly, for establishing the secured connection over BLE the Verifier's URI needs to be exchanged between two devices. The exchange of URI can be accomplished, but is not limited to, by using a QR code.
For example use QR code generator to visually display URI and QR code scanner to read. A mobile app that displays a QR code can act as an Verifier by including its URI as data in the QR code and another device can act as Wallet which scans the QR code, it can extract the URI and initiate a BLE connection with the advertising device.
The Verifier device generates a URI using the startAdvertisement()
method and displays it as a QR code. Once the advertisement starts, the Verifier continuously advertises with a payload derived from the URI.
OPENID4VP://connect?name=STADONENTRY&key=8520f0098930a754748b7ddcb43ef75a0dbf3a0d26381af4eba4a98eaa9b4e6a
URI structure can be found in the spec. Currently the library doesnot support iOS as a verifier.But it can act as a wallet for android verifier.
The Wallet device scans the QR code, extracts the URI, and starts scanning using the startConnection
method.
class Wallet:WalletProtocol {
func startConnection(_ uri: String) {
// Implementation for starting the connection
}
The device on which app is running can destroy the connection by calling disconnect
method:
func disconnect() {
// Implementation for disconnecting
}
Once the connection is established, Wallet can send the data by:
func sendData(_ payload: String) {
// Implementation for sending data
}
}
Wallet will start sending data in a secured way to the Verifier. Note: At this moment, we currently support data transfer from Wallet to Verifier only.
import ios_tuvali_library
var wallet=Wallet()
wallet.startConnection(uri, resolver: { result in
print("Connection started: \(result)")
}, rejecter: { code, message, error in
print("Error starting connection: \(message)")
})
import ios_tuvali_library
var wallet=Wallet()
wallet.disconnect(resolver: { result in
print("Disconnected: \(result)")
}, rejecter: { code, message, error in
print("Error disconnecting: \(message)")
})
import ios_tuvali_library
let payload = "your-data-here"
var wallet=Wallet()
wallet.sendData(payload, resolver: { result in
print("Data sent: \(result)")
}, rejecter: { code, message, error in
print("Error sending data: \(message)")
})
Tuvali sends multiple events to propagate connection status, received data etc. These events can be subscribed to by calling:
WalletModule.handleDataEvents {
// implementation
}
Events which are emitted by both Wallet and Verifier
- ConnectedEvent
- on BLE connection getting established between Wallet and Verifier
- SecureChannelEstablishedEvent
- on completion of key exchange between Wallet and Verifier
- ErrorEvent
- on any error in Wallet or Verifier
- DisconnectedEvent
- on BLE disconnection between Wallet and Verifier
Currently, data transfer is supported from Wallet to Verifier only. Verifier functionalities are not available for iOS at the moment.