Skip to content

Commit

Permalink
kernel: fix LogFFE on 32 bit systems
Browse files Browse the repository at this point in the history
Fixes #2687
  • Loading branch information
fingolfin committed Aug 11, 2018
1 parent 5aaea7a commit cbcab8e
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 9 deletions.
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

0 comments on commit cbcab8e

Please sign in to comment.