On Thu, 04 Jan 2007 20:12:04 -0800, David Kohel <[EMAIL PROTECTED]> wrote:
I'd like to get opinions on the following from the experts -- I am in
the process
of preparing for a cryptography course, for which I've previously used
a Magma
package that I wrote and would like to use SAGE.

Python has some special octal ('\ooo') and hexadecimal ('\xhh') string
constructors, e.g. one can see hexadecimals in action here in SAGE:

import Crypto
for i in range(256):
    x = Crypto.Util.number.long_to_bytes(i)
    print "%s: %s %s [%s]" % (i, repr(x), x, len(x))

Note that repr(x) uses hexadecimal printing for strings in some, but
not all,
ranges of the ASCII alphabet.

Thus Python strings represent the monoid \union_n {0,..,255}^n, with
special
constructors for the subsets of octals in \union_n {0,..7} and
hexadecimals in
\union_n {0,..,15}^n.

NOTE 1: I think Python also has support for unicode strings, which are
more than 8 bytes per character.  I know nothing about the details
or subtleties though.

What would you think of having SAGE classes for binary, octal,
hexadecimal,
radix64 (used by GPG) and other string monoids, which are not Python
strings?

That seems very sensible to me.

Advantages: differentiated printing, clear morphisms, efficient
embeddings
(i.e. length n binary strings can use n + O(log(n)) rather than 256n
bits),
and more general string monoids (like with alphabets {"AA",..,"ZZ"}).

Another advantage is that "+" wouldn't be defined like it stupidly
is for Python strings, and with your strings "*" would be for concatenation.
And the morphisms, efficiency, etc., are really good.

Disadvantages: performance and introduction of non-standard Python
classes.

Yes, they would likely be a lot slower at first, but you could make them
fast by (re-)writing them in Sagex at a certain point.

The alternative is to always embedd cryptographic strings in Python
strings.

That might even be how you would implement it, I don't know.  But
that sounds like a bad idea, since it is conceptually wrong and potentially
very confusing.

In Magma I did create a Hackobj cryptographic string type (CryptTxt)
for
exclusive use with my cryptography package.

V := VigenereCryptosystem(8);
M := Encoding(V,"ABCDEFGH");
ABCDEFGH
Type(M);
CryptTxt

This was meant to overcome certain disadvantages with Magma strings,
give verifiable type-checking, etc.

What do you think of such classes in SAGE would be merited?

Yes.

Is there possibly any existing string library which provides similar
features?

Yes, to some extent, though there is definitely nothing that fits
into the SAGE environment (morphisms, parent structures, categories
etc.).

William

--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to sage-devel@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/sage-devel
URLs: http://sage.scipy.org/sage/ and http://modular.math.washington.edu/sage/
-~----------~----~----~----~------~----~------~--~---

Reply via email to