mirror of
https://github.com/permissionlesstech/bitchat-android.git
synced 2026-11-01 07:51:15 +00:00
refactor(noise): update NoiseSession for Kotlin-property accessors
External callers must use the property form for HandshakeState and CipherStatePair members that the protocol package now exposes as `val`s: - handshakeState.getLocalKeyPair() -> handshakeState.localKeyPair - handshakeState.getAction() -> handshakeState.action - handshakeState.getRemotePublicKey() -> handshakeState.remotePublicKey - handshakeState.getHandshakeHash() -> handshakeState.handshakeHash - cipherPair.getSender() / getReceiver() -> .sender / .receiver DH operations with arguments (`setPrivateKey`, `getPublicKey`, etc.) remain regular method calls. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
parent
84f70ff12d
commit
544d569708
@ -1,9 +1,8 @@
|
||||
package com.bitchat.android.noise
|
||||
|
||||
import android.util.Log
|
||||
import com.bitchat.android.noise.southernstorm.protocol.*
|
||||
import com.bitchat.android.util.toHexString
|
||||
import java.security.SecureRandom
|
||||
import com.bitchat.android.noise.southernstorm.protocol.CipherState
|
||||
import com.bitchat.android.noise.southernstorm.protocol.HandshakeState
|
||||
|
||||
|
||||
/**
|
||||
@ -251,7 +250,7 @@ class NoiseSession(
|
||||
if (handshakeState?.needsLocalKeyPair() == true) {
|
||||
Log.d(TAG, "Local static key pair is required for XX pattern")
|
||||
|
||||
val localKeyPair = handshakeState?.getLocalKeyPair()
|
||||
val localKeyPair = handshakeState?.localKeyPair
|
||||
if (localKeyPair != null) {
|
||||
// FIXED: Use the provided persistent identity keys with our local fork
|
||||
// Our local fork properly supports setting pre-existing keys
|
||||
@ -369,7 +368,7 @@ class NoiseSession(
|
||||
Log.d(TAG, "Read handshake message, payload length: $payloadLength currentPattern: $currentPattern")
|
||||
|
||||
// Check what action the handshake state wants us to take next
|
||||
val action = handshakeStateLocal.getAction()
|
||||
val action = handshakeStateLocal.action
|
||||
Log.d(TAG, "Handshake action after processing message: $action")
|
||||
|
||||
return when (action) {
|
||||
@ -380,7 +379,7 @@ class NoiseSession(
|
||||
currentPattern++
|
||||
val response = responseBuffer.copyOf(responseLength)
|
||||
|
||||
Log.d(TAG, "Generated handshake response: ${response.size} bytes, action still: ${handshakeStateLocal.getAction()} currentPattern: $currentPattern")
|
||||
Log.d(TAG, "Generated handshake response: ${response.size} bytes, action still: ${handshakeStateLocal.action} currentPattern: $currentPattern")
|
||||
completeHandshake()
|
||||
response
|
||||
}
|
||||
@ -430,12 +429,12 @@ class NoiseSession(
|
||||
// Split handshake state into transport ciphers
|
||||
val cipherPair = handshakeState?.split()
|
||||
|
||||
sendCipher = cipherPair?.getSender()
|
||||
receiveCipher = cipherPair?.getReceiver()
|
||||
sendCipher = cipherPair?.sender
|
||||
receiveCipher = cipherPair?.receiver
|
||||
|
||||
// Extract remote static key if available
|
||||
if (handshakeState?.hasRemotePublicKey() == true) {
|
||||
val remoteDH = handshakeState?.getRemotePublicKey()
|
||||
val remoteDH = handshakeState?.remotePublicKey
|
||||
if (remoteDH != null) {
|
||||
remoteStaticPublicKey = ByteArray(32)
|
||||
remoteDH.getPublicKey(remoteStaticPublicKey!!, 0)
|
||||
@ -444,7 +443,7 @@ class NoiseSession(
|
||||
}
|
||||
|
||||
// Extract handshake hash for channel binding
|
||||
handshakeHash = handshakeState?.getHandshakeHash()
|
||||
handshakeHash = handshakeState?.handshakeHash
|
||||
|
||||
// Clean up handshake state
|
||||
handshakeState?.destroy()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user