Add support for sending using a QR code

closes #196
This commit is contained in:
Grishka
2025-08-07 04:59:01 +03:00
parent f75f5fb1f0
commit ad1c47012f
11 changed files with 426 additions and 27 deletions

View File

@@ -27,6 +27,8 @@ class OutboundNearbyConnection:NearbyConnection{
private var cancelled:Bool=false
private var textPayloadID:Int64=0
public var qrCodePrivateKey:ECPrivateKey?
enum State{
case initial, sentUkeyClientInit, sentUkeyClientFinish, sentPairedKeyEncryption, sentPairedKeyResult, sentIntroduction, sendingFiles
}
@@ -237,6 +239,12 @@ class OutboundNearbyConnection:NearbyConnection{
pairedEncryption.v1.pairedKeyEncryption=Sharing_Nearby_PairedKeyEncryptionFrame()
pairedEncryption.v1.pairedKeyEncryption.secretIDHash=Data.randomData(length: 6)
pairedEncryption.v1.pairedKeyEncryption.signedData=Data.randomData(length: 72)
if let qrKey=qrCodePrivateKey{
let signature=qrKey.sign(msg: authKey!.data())
var serializedSignature=Data(signature.r)
serializedSignature.append(Data(signature.s))
pairedEncryption.v1.pairedKeyEncryption.qrCodeHandshakeData=serializedSignature
}
try sendTransferSetupFrame(pairedEncryption)
currentState = .sentPairedKeyEncryption