Ask Your Question
0

Why do I get the "unable to find a common ring for all elements" error message?

asked 2018-04-29 16:17:28 +0100

vijay gravatar image

import hashlib

import binascii

from sage.crypto.util import ascii_integer

bin = BinaryStrings()

k1 = hashlib.sha224(b"Nobody inspects the spammish repetition").hexdigest()

k2 = hashlib.sha224(b"Nobody inspects").hexdigest()

A = bin.encoding(k1)

B = bin.encoding(k2)

A = list(A)

B = list(B)

A = Matrix([[A],[B]])

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
2

answered 2018-04-29 20:24:50 +0100

tmonteil gravatar image

updated 2018-04-29 23:23:52 +0100

The elements of your lists belong to a monoid, not a ring:

sage: type(A[0])
<class 'sage.monoids.string_monoid_element.StringMonoidElement'>
sage: A[0].parent()
Free binary string monoid

So, you can transform them into integer first:

sage: A = [ZZ(str(i)) for i in A]
sage: B = [ZZ(str(i)) for i in B]

Then, you can do:

sage: Matrix([A,B])
2 x 448 dense matrix over Integer Ring (use the '.str()' method to see the entries)

(note that you put to many brackets).

You can also trnasform 0 and 1 as elements of GF(2) if it makes more sense in your application.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2018-04-29 16:17:28 +0100

Seen: 331 times

Last updated: Apr 29 '18