simple-crypto / SCALib

Side-Channel Analysis Library
GNU Affero General Public License v3.0
74 stars 19 forks source link

RLDA provides nan probabilities on corner cases #176

Open Bbalon-a opened 1 month ago

Bbalon-a commented 1 month ago

If training and attack datasets are quite different, the RLDA provides nan when evaluating the probabilities instead of uniform distribution.

To Reproduce

from scalib.modeling import RLDAClassifier
import numpy as np
traces_model = np.random.randint(0,256,(5000,10),dtype=np.int16)
labels_model = np.random.randint(0,256,(5000,1),dtype=np.uint64)
rlda = RLDAClassifier(8, 3)
rlda.fit_u(traces_model, labels_model)
rlda.solve()
traces_test = np.random.randint(-30000,-29000,(5000,10),dtype=np.int16) #Really different datasets
prs = rlda.predict_proba(traces_test, 0)