Pick two irreducible polynomials
over a finite field
and let
. Form the quotient ring
.
> F:=GF(3); > P<x> := PolynomialRing(F); > p:=ConwayPolynomial(3,5); > q:=ConwayPolynomial(3,4); > n:=p*q; > n; x^9 + 2*x^8 + x^5 + 2*x^4 + 2*x^3 + x + 2 > I:=ideal<P|n>; > R:=quo<P|I>; > IsFinite(R); true 19683
Next, we need to find out how many elements are
in the group
. Denote this number by
.
Note that this is
not the Euler phi function value of the integer
.
> f:=x^12+x+1; > f:=R!f; > IsUnit(f); true > L:=[f:f in R]; > U:=[f:f in R|IsUnit(f)]; > #U; 19360 > #R; 19683 > EulerPhi(#R); 13122 > Factorization(#U); [ <2, 5>, <5, 1>, <11, 2> ] >
Now, as with RSA, pick a secret encryption exponent,
.
Let
denote its inverse mod
. This is the secret
decryption exponent. Pick a message for Alice to send to
Bob, say
. (The message must
have degree less than that of
.) MAGMA uses a capital
to distinguish elements of
and those
of its quotient
.
Alice sends
to Bob. Bob decrypts Alice's cipher-text
by using that fact that
> e:=7; > R<X>:=quo<P|I>; > > m:=X^4+X+1; > m in R; true > c:=m^e; > c; X^8 + 2*X^6 + 2*X^5 + 2*X^4 + 2*X > Z_N:=ResidueClassRing(#U); > > E:=Z_N!e; > d:=E^-1; > d; 11063 > D:=Integers()!d; > D; 11063 > c^D; X^4 + X + 1 > m; X^4 + X + 1
R<x>:=PolynomialRing(Integers(),1);,
p:=x^8-1, and
Factorization(p);, find the factorization
over the integers of
R<x>:=PolynomialRing(GF(2),1);,
p:=x^8-1, and
Factorization(p);, find the factorization
over the integers of
To evaluate
at
in MAGMA, use the
Evaluate(f,x0); command. For example,
Using R<x>:=PolynomialRing(Integers(),1);,
p:=x^8-1, and Evaluate(f,3); evaluates
in MAGMA.
In MAGMA, type
R<x>:=PolynomialRing(Integers());,
a(x)^n mod m(x); to compute
. For example,
R<x>:=PolynomialRing(Integers());
x^17 mod (x^2+1);returns
In MAGMA,
R<x>:=PolynomialRing(Integers(),1);
and
the command C:=CompanionMatrix(p); gives,
for a monic polynomial
of degree
over a ring
,
the companion matrix
for
as an element of
.
In MAGMA, first type
R<x,y,z>:=PolynomialRing(Integers(),3);.
The leading monomial can be computed using the
LeadingTerm command. For example,
p:=320*x*y^2+9*x*y^4-96*x*y^4*z^2;and
LeadingTerm(p); returns
> L:=[x^i*y^j : i in [0..4],j in [0..4]];
> R<x,y>:=PolynomialRing(GF(5),2);
> L:=[x^i*y^j : i in [0..4],j in [0..4]];
> f:=function(a,b)
function> if a lt b then return -1; end if;
function> if a eq b then return 0; end if;
function> if a gt b then return 1; end if;
function> end function;
> L;
[
1,
x,
x^2,
x^3,
x^4,
y,
x*y,
x^2*y,
x^3*y,
x^4*y,
y^2,
x*y^2,
x^2*y^2,
x^3*y^2,
x^4*y^2,
y^3,
x*y^3,
x^2*y^3,
x^3*y^3,
x^4*y^3,
y^4,
x*y^4,
x^2*y^4,
x^3*y^4,
x^4*y^4
]
> Sort(L,f);
[
1,
y,
y^2,
y^3,
y^4,
x,
x*y,
x*y^2,
x*y^3,
x*y^4,
x^2,
x^2*y,
x^2*y^2,
x^2*y^3,
x^2*y^4,
x^3,
x^3*y,
x^3*y^2,
x^3*y^3,
x^3*y^4,
x^4,
x^4*y,
x^4*y^2,
x^4*y^3,
x^4*y^4
]
(2, 6)(3, 11)(4, 16)(5, 21)(8, 12)(9, 17)(10, 22)(14, 18)(15, 23)(20, 24)
>
NormalForm.)
R<x>:=PolynomialRing(Integers(),1);
and the command C:=CompanionMatrix(p); gives,
for a monic polynomial
of degree
over a ring
,
the companion matrix
for
as an element of
.