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