fix: add optional namespace in signature and params

This commit is contained in:
0x330a 2023-01-20 10:27:34 +11:00
parent 39bd0bba22
commit edb5ff09e9
No known key found for this signature in database
GPG Key ID: 267811D6E6A2698C

View File

@ -373,7 +373,8 @@ object SnodeAPI {
val ed25519PublicKey = userEd25519KeyPair.publicKey.asHexString
val timestamp = System.currentTimeMillis() + clockOffset
val signature = ByteArray(Sign.BYTES)
val verificationData = "retrieve$namespace$timestamp".toByteArray()
val verificationData = if (namespace == 0) "retrieve$timestamp".toByteArray()
else "retrieve$namespace$timestamp".toByteArray()
try {
sodium.cryptoSignDetached(
signature,
@ -385,8 +386,11 @@ object SnodeAPI {
return null
}
params["timestamp"] = timestamp
// params["pubkey_ed25519"] = ed25519PublicKey
params["pubkey_ed25519"] = ed25519PublicKey
params["signature"] = Base64.encodeBytes(signature)
if (namespace != 0) {
params["namespace"] = namespace
}
return SnodeBatchRequestInfo(
Snode.Method.Retrieve.rawValue,
params