Click here to Skip to main content
See more: C# .NET4
Hi,
First, I know that .NET libraries defines AES encryption but I can't use them. It is a school project.
I was trying to write some algorithm for operation polynom modulo. I have written one, but it has been too slow, can somebody help me?
 
How does it work?
Look: The input for this operation are two byte numbers. Each byte number consists of 8 bits. The idea of creating a polynom is, that every bit in it's order we multiply by x powered by the order:
 
For example: we have numbers that fits in the byte - for example 255 (11111111 in binary format) and 71 (01000111 in binary format).
The polynom for 11111111 is: 1*x^7 + 1*x^6 + 1*x^5 + 1*x^4 + 1*x^3 + 1*x^2 + 1*x^0 + 1*x^0.
The polynom for 01000111 is: 0*x^7 + 1*x^6 + 0*x^5 + 0*x^4 + 0*x^3 + 1*x^2 + 1*x^0 + 1*x^0.
 
We have to do the modulo operation with these polynoms (forget about it, that Galois field has not declared division). So we have to divide a polynom by a polynom.
 
Here is a quite fast code how to convert a byte to bits:
byte number = 255;
byte numeralSystem = 2;
string bits =  Convert.ToString(number, numeralSystem);
//completion of zeroes
while (bits.Length < 8)
{
    bits = "0" + bits;
}
 
Imagine, that you have implemented a method Polynom polynomModulo(Polynom pol1, Polynom pol2) that returns the rest after division of po1/pol2 and uses these methods:
Member divide(Member x, Member y); //Type Member is one member from a polynom (example: 1*x^5). This method gets in the parameter x the actual member with the highest power (in the first iteration it is the member of the dividend with the highest power, otherwise it is the member with the hignest power of the actual rest of division) and also it gets in the parameter y the member with the highest power of the divisor. Method divides x by y and returns the result.
Polynom multiply(Polynom divisor, Member result) //This method is used for multiplication of the divisor by the actual result, method returns value, that is used for subtract.
Polynom subtract(Polynom rest, Polynom newRest)//This subtracts the newRest from the rest, the newRest is the result of the multiply method.
 
Please write here some fast algorithm for these methods and implement assistant objects for it.
Or implement polynom modulo completly by your own algorithm.

 
Thanks a lot!
 
Pepin z Hané
Closed because The post is not clear, or is incomplete and has not been phrased in a way that allows it to be fully understood.. Reported by RyanDev on Saturday, July 27, 2013 3:04pm.
Posted 20-Apr-13 12:01pm
Edited 20-Apr-13 12:58pm
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



Advertise | Privacy | Mobile
Web03 | 2.8.141220.1 | Last Updated 20 Apr 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100