I want to resolve the following equation for exponent n for given value v:
v≡(r⋅(b+r)n−r⋅(b−r)n)⋅(r⋅(b+r)n−1−r⋅(b−r)n−1)−1modP
with
r2=4⋅a+b2modP
and a prime P
Looking for a function f(v)=n.
The values a,b are chosen in that way that for n=[0,..,(P−1)] the results v will be all values in {0,..,P−1}=FP. That works iff there is no such root r in FP exists for a,b. If both parts in formula above are expanded only r2 is left over.
Example:
P=11;a=5;b=3−>r2=7
R.<a,b,r,v,n>=PolynomialRing(GF(11))
[ r*((b+r)^n-(b-r)^n)/ ( r*((b+r)^(n-1)-(b-r)^(n-1)) ) for n in R.base() if n>1]
[2*b,
(-5*b^2 + 2*r^2)/(4*b),
(-3*b^3 - 3*b*r^2)/(-5*b^2 + 2*r^2),
(-b^4 - 2*b^2*r^2 + 2*r^4)/(-3*b^3 - 3*b*r^2),
(b^5 - 4*b^3*r^2 + b*r^4)/(-b^4 - 2*b^2*r^2 + 2*r^4),
(3*b^6 + 4*b^4*r^2 - 2*b^2*r^4 + 2*r^6)/(b^5 - 4*b^3*r^2 + b*r^4),
(5*b^7 + 2*b^5*r^2 + 2*b^3*r^4 + 5*b*r^6)/(3*b^6 + 4*b^4*r^2 - 2*b^2*r^4 + 2*r^6),
(-4*b^8 + 3*b^6*r^2 - b^4*r^4 - 5*b^2*r^6 + 2*r^8)/(5*b^7 + 2*b^5*r^2 + 2*b^3*r^4 + 5*b*r^6),
(-2*b^9 - 2*b^7*r^2 - 2*b^5*r^4 - 2*b^3*r^6 - 2*b*r^8)/(-4*b^8 + 3*b^6*r^2 - b^4*r^4 - 5*b^2*r^6 + 2*r^8)]
There is some special case for n=1. With this the part which need to be inverted is 0. In that case v is assigned to 0.
As a alternative form without any root r: v≡∑⌊n/2⌋k=0(n2k+1)bn−2k−1(r2)k+1∑⌊(n−1)/2⌋k=0(n−12k+1)bn−2k−2(r2)k+1modP
in sagemath (not working):
a,b,r,v,k=var('a b r v k')
(sum( binomial(n, 2*k+1) * b^(n-2*k-1)*(4*a+b^2)^(k+1) , k,1,floor( n/2) ))*(sum( binomial(n-1, 2*k+1) * b^(n-2*k-2)*(4*a+b^2)^(k+1) , k,1, floor( (n-1)/2) ))^(-1)-v
There are some issues with the upper border of the sum.
How can I solve such equation in sagemath?
R.<n>=PolynomialRing(GF(11))
(2*k-8).roots(); #multiplication works
(2^k-8).roots(); #power not working
(a,b,r2 can be exchanged with current values)