Skip to content
This repository was archived by the owner on Oct 30, 2025. It is now read-only.

Commit 46bd4c2

Browse files
committed
fix: drop support for argon2 based ons
1 parent ad9fa6d commit 46bd4c2

File tree

1 file changed

+4
-37
lines changed

1 file changed

+4
-37
lines changed

ts/session/apis/snode_api/onsResolve.ts

Lines changed: 4 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ import {
66
stringToUint8Array,
77
toHex,
88
} from '../../utils/String';
9+
import { OnsResolveSubRequest } from './SnodeRequestTypes';
910
import { doSnodeBatchRequest } from './batchRequest';
1011
import { GetNetworkTime } from './getNetworkTime';
1112
import { getRandomSnode } from './snodePool';
12-
import { OnsResolveSubRequest } from './SnodeRequestTypes';
1313

1414
// ONS name can have [a-zA-Z0-9_-] except that - is not allowed as start or end
1515
// do not define a regex but rather create it on the fly to avoid https://stackoverflow.com/questions/3891641/regex-test-only-works-every-other-time
@@ -56,48 +56,15 @@ async function getSessionIDForOnsName(onsNameCase: string) {
5656
}
5757
const hexEncodedCipherText = intermediate?.encrypted_value;
5858

59-
const isArgon2Based = !intermediate?.nonce;
6059
const ciphertext = fromHexToArray(hexEncodedCipherText);
61-
let sessionIDAsData: Uint8Array;
62-
let nonce: Uint8Array;
6360
let key: Uint8Array;
61+
// we dropped support for argon2 based ons
6462

65-
if (isArgon2Based) {
66-
// Handle old Argon2-based encryption used before HF16
67-
const salt = new Uint8Array(sodium.crypto_pwhash_SALTBYTES);
68-
nonce = new Uint8Array(sodium.crypto_secretbox_NONCEBYTES);
69-
try {
70-
const keyHex = sodium.crypto_pwhash(
71-
sodium.crypto_secretbox_KEYBYTES,
72-
onsNameLowerCase,
73-
salt,
74-
sodium.crypto_pwhash_OPSLIMIT_MODERATE,
75-
sodium.crypto_pwhash_MEMLIMIT_MODERATE,
76-
sodium.crypto_pwhash_ALG_ARGON2ID13,
77-
'hex'
78-
);
79-
if (!keyHex) {
80-
throw new Error('ONSresolve: key invalid argon2');
81-
}
82-
key = fromHexToArray(keyHex);
83-
} catch (e) {
84-
throw new Error('ONSresolve: Hashing failed');
85-
}
86-
87-
sessionIDAsData = sodium.crypto_secretbox_open_easy(ciphertext, nonce, key);
88-
if (!sessionIDAsData) {
89-
throw new Error('ONSresolve: Decryption failed');
90-
}
91-
92-
return toHex(sessionIDAsData);
93-
}
94-
95-
// not argon2Based
9663
const hexEncodedNonce = intermediate.nonce as string;
9764
if (!hexEncodedNonce) {
9865
throw new Error('ONSresolve: No hexEncodedNonce');
9966
}
100-
nonce = fromHexToArray(hexEncodedNonce);
67+
const nonce = fromHexToArray(hexEncodedNonce);
10168

10269
try {
10370
key = sodium.crypto_generichash(sodium.crypto_generichash_BYTES, nameAsData, nameHash);
@@ -109,7 +76,7 @@ async function getSessionIDForOnsName(onsNameCase: string) {
10976
throw new Error('ONSresolve: Hashing failed');
11077
}
11178

112-
sessionIDAsData = sodium.crypto_aead_xchacha20poly1305_ietf_decrypt(
79+
const sessionIDAsData = sodium.crypto_aead_xchacha20poly1305_ietf_decrypt(
11380
null,
11481
ciphertext,
11582
null,

0 commit comments

Comments
 (0)