Skip to content

Commit 52f8847

Browse files
committed
ensure the modulus matches for scalar coercion
1 parent 38b6ce1 commit 52f8847

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

src/flint/types/fq_default.pyx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -347,14 +347,12 @@ cdef class fq_default_ctx:
347347
return 0
348348

349349
# For nmod we can convert by taking it as an int
350-
# Ignores the modulus of nmod
351-
if typecheck(obj, nmod):
350+
if typecheck(obj, nmod) and self.prime() == obj.modulus():
352351
fq_default_set_ui(fq_ele, <ulong>(<nmod>obj).val, self.val)
353352
return 0
354353

355354
# For fmpz_mod we can also convert directly
356-
# Assumes that the modulus of the ring matches the context
357-
if typecheck(obj, fmpz_mod):
355+
if typecheck(obj, fmpz_mod) and self.prime() == (<fmpz_mod>obj).ctx.modulus():
358356
fq_default_set_fmpz(fq_ele, (<fmpz_mod>obj).val, self.val)
359357
return 0
360358

0 commit comments

Comments
 (0)