hi guys, i did a function for lagrange interpolation formula. However i`m stuck on how do i substitute values into the power
here is my code snippet
1 2 3 4 5 6 7 8 9 10 11

for(int i=1;i<getSecretShare+1;i++)
{
//calculateValue=getSecret+(10*p)+(2 * pow(p,2));
int storeThreshold=getThreshold;
calculateValue=getSecret+(10*i)+(2 * pow(i,2));
calculateFinalValue=calculateValue % 17 ;
cout<<"the calculated value is "<<calculateFinalValue<<endl;
}
 
the formula that i want to implement is that a + a1x^1 + a2x^2 + a(t1) ^t1
i have gotten the substitution of the x value out.
However, i am stuck on how do i calculate the values according to the threshold which the user keys in
for example if the user keys in 3
it will into account the no. of shares to generate which is for example 5 in this case, then it will then take into account the threshold keyed in , which is 3, i will then calculate using the formula using the no. of shares and also threshold.
if the threshold is 3 and the number of shares to generate is 5
i should have the following
y(1) = 13 + a1(1)^1 +a2(1)^2
y(2) = 13 + a2(2)^1 +a2(2)^2
the power depends on the threshold which is t1, 31 =2
so i will have to generate two a values based on that and also calculate them according to the power that is dependent on the threshold
the first value being to the power of 1 and the 2nd being to the power of 2
if the threshold is 4.
then i will generate 3 a values and then calculate them
y(1) = 13 + a1(1)^1 + a2(1)^1 + a3(1)^3
and so on..
Hope you guys can help me with this problem. Thanks in advance!