Ask Your Question
0

Symbolically evaluate abstract cryptographic operations

asked 2022-01-23 19:40:26 +0200

itecMemory gravatar image

I would like to use simple variable substitution to show some basic properties of cryptographic constructions using Sage. For example, I want to define an encrpytion and decryption function E and D, so that for a given message m and key k

D(E(m, k), k) = m

I.e., the decrypted encrypted message is the message.

Furthermore, I want to specify that all those variables, (m, k in the above example) are vectors in GF(2) of length 128. This would allow me to use XOR so that

m + m = vector(GF(2), 128)

I.e., a block XOR itself is zero.

I cannot find a way to do this properly (i.e., that XOR terms that cancel each other out are simplified away and that I can use symbolic "encryption" function blocks). Is this possible somehow?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2022-01-23 23:12:19 +0200

Max Alekseyev gravatar image

If I got it correctly, you want to define vectors of variables over GF(2). This can be done like this

X.<mbit,kbit> = InfinitePolynomialRing(GF(2))
m = vector( [mbit[i] for i in range(128)] )
k = vector( [kbit[i] for i in range(128)] )

Then you can do operations like m+k (XOR) or accessing individual bits via m[i] etc.

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: 2022-01-23 19:40:26 +0200

Seen: 31 times

Last updated: Jan 23