Code covered by the BSD License

### Highlights from A toolbox for simple finite field operation

5.0
5.0 | 1 rating Rate this file 5 Downloads (last 30 days) File Size: 10.9 KB File ID: #32872 Version: 1.3

# A toolbox for simple finite field operation

### Samuel Cheng (view profile)

13 Sep 2011 (Updated )

This is a toolbox providing simple operations (+,-,*,/,.*,./,inv) for finite field.

File Information
Description

This toolbox can handle simple operations (+,-,*,/,.*,./,inv) of GF(p^n) for any p and n. Examples are given below (also documented in gf_test.m).

% setup path
java_path_setup;
% create gf class of 3^2
gf9=gf(3,2);

%%%%
% Eg. 1
a=[2 1;1 0]

% compute rank
gf9.rank(a)

% compute inverse
inva = gf9.inv(a)

% Check inverse
a_times_ainva=gf9.mult(a,inva)

% matrix divide
gf9.div(a,a)

%%%%%
% Eg. 2
b=[1 2 1;1 0 1];
c=[1 1 0;2 1 1];

% compute summation

% compute subtraction
gf9.sub(b,c)

% compute dot multiplication
gf9.dmult(b,c)

% compute dot division
gf9.ddiv(b,c)

% output the primitive polynomial
gf9.return_primitive_polynomial % x^2 + 1

% show polynomial representation
gf9.return_poly_representation(5) % x + 2

%%%%
% Eg. 3

% manipulating polynomials.

a=[1 2 1 1];
b=[1 3 1];

gf9.conv(a,b)

[q,rem]=gf9.deconv(a,b)

MATLAB release MATLAB 7.11 (R2010b)
02 Jan 2015 hajer

### hajer (view profile)

when i try run the code there are problem in rank function
and what is mean obj

30 Aug 2012 Samuel Cheng

### Samuel Cheng (view profile)

Comment only
01 Aug 2012 Valentina

### Valentina (view profile)

Hi Samuel,
I'm trying to use this code to perform some AES operations... What I need is e.g. to define a polynomial which can have a max degree = 7, with coefficients 0 and 1. (i.e., over GF(2)), and then compute its inverse modulo a poly of degree 8, again with binay coeffs. I can't figure out how to declare the gf, which in your example is gf9=gf(3,2); and then how do i define the poly? what does the 2 line matrix in your example mean, a=[2 1;1 0]?
Thanks!

Comment only