I'm trying to digitally sign a test message in Sage using DSA (DSS). After running my code, I get:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "_sage_input_28.py", line 10, in <module>
exec compile(u'open("___code___.py","w").write("# -*- coding: utf-8 -*-\\n" + _support_.preparse_worksheet_cell(base64.b64decode("IyBDaGVjayB0aGUgc2lnbmF0dXJlCmNoZWNrX3NpZyhtLHAscSxnLHIscyx5KQ=="),globals())+"\\n"); execfile(os.path.abspath("___code___.py"))
File "", line 1, in <module>
File "/tmp/tmpUuKk65/___code___.py", line 3, in <module>
exec compile(u'check_sig(m,p,q,g,r,s,y)
File "", line 1, in <module>
File "/tmp/tmppjN9Gi/___code___.py", line 7, in check_sig
u_2 = mod(r*w,q)
File "element.pyx", line 1701, in sage.structure.element.RingElement.__mul__ (sage/structure/element.c:14531)
File "coerce.pyx", line 856, in sage.structure.coerce.CoercionModel_cache_maps.bin_op (sage/structure/coerce.c:8169)
TypeError: unsupported operand parent(s) for '*': 'Ring of integers modulo 98007532214006523718033513010741500921668410005086660781341579786663143142637' and 'Ring of integers modulo 44449'
The offending line is: u_2 = mod(r*w,q)
. I think the issue here is I'm multiplying r
and w
where:
r = mod(mod(g^k,p),q)
w = mod(1/s,q)
However, these are both mod q
. Why can't I perform a multiplication on them? Is there some kind of casting I have to do?
Here's a link to the full (still small) sage sheet: https://i.stack.imgur.com/Pw2qz.png