summaryrefslogtreecommitdiff
path: root/bcprov/src/main/java/org/bouncycastle/crypto/params/ECPublicKeyParameters.java
blob: 036bf4ae81efb08127be971949ac5bf7ecd824a3 (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
43
44
45
package org.bouncycastle.crypto.params;

import org.bouncycastle.math.ec.ECPoint;

public class ECPublicKeyParameters
    extends ECKeyParameters
{
    private final ECPoint Q;

    public ECPublicKeyParameters(
        ECPoint             Q,
        ECDomainParameters  params)
    {
        super(false, params);

        this.Q = validate(Q);
    }

    private ECPoint validate(ECPoint q)
    {
        if (q == null)
        {
            throw new IllegalArgumentException("point has null value");
        }

        if (q.isInfinity())
        {
            throw new IllegalArgumentException("point at infinity");
        }

        q = q.normalize();

        if (!q.isValid())
        {
            throw new IllegalArgumentException("point not on curve");
        }

        return q;
    }

    public ECPoint getQ()
    {
        return Q;
    }
}