DSA (DSS) を使用して、Sage でテスト メッセージにデジタル署名しようとしています。コードを実行すると、次のようになります。
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'
問題のある行は次のとおりu_2 = mod(r*w,q)
です。ここでの問題は、私が乗算r
していることと、w
どこにあると思います:
r = mod(mod(g^k,p),q)
w = mod(1/s,q)
ただし、これらは両方mod q
です。それらに対して乗算を実行できないのはなぜですか? 私がしなければならないある種のキャストはありますか?
完全な (まだ小さい) セージ シートへのリンクは次のとおりです: http://i.imgur.com/dX7PKHi.png