summaryrefslogtreecommitdiffstats
path: root/bcprov/src/main/java/org/bouncycastle/math/field/GF2Polynomial.java
blob: 73be7685d8234791d626b56f63398b6c67332079 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package org.bouncycastle.math.field;

import org.bouncycastle.util.Arrays;

class GF2Polynomial implements Polynomial
{
    protected final int[] exponents;

    GF2Polynomial(int[] exponents)
    {
        this.exponents = Arrays.clone(exponents);
    }

    public int getDegree()
    {
        return exponents[exponents.length - 1];
    }

    public int[] getExponentsPresent()
    {
        return Arrays.clone(exponents);
    }

    public boolean equals(Object obj)
    {
        if (this == obj)
        {
            return true;
        }
        if (!(obj instanceof GF2Polynomial))
        {
            return false;
        }
        GF2Polynomial other = (GF2Polynomial)obj;
        return Arrays.areEqual(exponents, other.exponents);
    }

    public int hashCode()
    {
        return Arrays.hashCode(exponents);
    }
}