Describe the bug
Generic Factor treat Public Variables as Uniformly distributed
To Reproduce
import numpy as np
import scalib.attacks
nc = 2
fg = scalib.attacks.FactorGraph(f'''
NC {nc}
PUB SINGLE A
VAR SINGLE NOT_A
GENERIC SINGLE NOT
PROPERTY NOT(A,NOT_A)
''')
NOT = []
for a in range(nc):
NOT.append([a,not a])
gen_factors = {
'NOT':scalib.attacks.GenFactor.sparse_functional(np.array(NOT,dtype=np.uint32))
}
A = 0
bp = scalib.attacks.BPState(fg,1,public_values={'A':A},gen_factors=gen_factors)
bp.bp_acyclic('NOT_A')
result = bp.get_distribution('NOT_A')
print(result)
A = 1
bp = scalib.attacks.BPState(fg,1,public_values={'A':A},gen_factors=gen_factors)
bp.bp_acyclic('NOT_A')
result = bp.get_distribution('NOT_A')
print(result)
Observed behavior
Results are
[0.5 0.5]
[0.5 0.5]
Expected behavior
If the Public whould have been respected the expected result is:
[0.0 1.0]
[1.0 0.0]
Environment (please complete the following information):
OS: GNU/Linux 11 (bullseye)
Python version: 3.8
numpy version: 1.23.5
SCALib version: 0.5.7.dev18+g5305549
How did you install SCALib? build from Xource
What CPU do you use? 2x Intel(R) Xeon(R) Gold 5317
Describe the bug Generic Factor treat Public Variables as Uniformly distributed
To Reproduce
Observed behavior
Results are
Expected behavior
If the Public whould have been respected the expected result is:
Environment (please complete the following information):