Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

kernel: fix LogFFE to not return negative results on 32 bit systems #2689

Merged
merged 1 commit into from
Aug 11, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions src/finfield.c
Original file line number Diff line number Diff line change
Expand Up @@ -1471,11 +1471,9 @@ Obj FuncLOG_FFE_DEFAULT (

while (a < 0)
a+= (qX -1)/c;
/* return the logarithm */


return INTOBJ_INT( (((Int) (vZ-1) / c) * a) % ((Int) (qX-1)) );

// return the logarithm
return INTOBJ_INT( (((UInt) (vZ-1) / c) * a) % ((UInt) (qX-1)) );
}


Expand Down
3 changes: 0 additions & 3 deletions tst/testbugfix/2011-01-16-t00231.tst

This file was deleted.

23 changes: 21 additions & 2 deletions tst/testinstall/ffe.tst
Original file line number Diff line number Diff line change
Expand Up @@ -183,10 +183,29 @@ gap> DegreeFFE( [[Z(2),Z(8)],[Z(2), Z(4)]]);
6

#
gap> n:=LogFFE(Z(25)^3, Z(25)^7);; (Z(25)^7)^n;
Z(5^2)^3
# LogFFE
#
gap> q:=25;; r:=Z(q)^7;; ForAll([0..q-2], i -> LogFFE(r^i,r)=i);
true

# test an issue reported by MN on 2009/10/06, added by AK on 2011/01/16
gap> q:=2^16;; r:=Z(q)^2;; ForAll([0..q-2], i -> LogFFE(r^i,r)=i);
true

# test an edge case on 32 bit systems, where a kernel value could overflow
# (see https://github.com/gap-system/gap/issues/2687)
gap> q:=37^3;; r:=Z(q)^1055;; ForAll([0..q-2], i -> LogFFE(r^i,r)=i);
true

# error handling
gap> LogFFE(0*Z(2), Z(2));
Error, LogFFE: <z> must be a nonzero finite field element
gap> LogFFE(Z(2), 0*Z(2));
Error, LogFFE: <r> must be a nonzero finite field element

#
# RootFFE
#
gap> Rochambeau:=function(F)
> local e,i,p,a,r;
> e:=Elements(F);
Expand Down