Debian Codegraph @

ext/ed25519_jruby/net/i2p/crypto/eddsa/spec/EdDSAPublicKeySpec.java

raw symbols SCIP
1 /**
2 * EdDSA-Java by str4d
3 *
4 * To the extent possible under law, the person who associated CC0 with
5 * EdDSA-Java has waived all copyright and related or neighboring rights
6 * to EdDSA-Java.
7 *
8 * You should have received a copy of the CC0 legalcode along with this
9 * work. If not, see <https://creativecommons.org/publicdomain/zero/1.0/>.
10 *
11 */
12 package net.i2p.crypto.eddsa.spec;
13
14 import java.security.spec.KeySpec;
15
16 import net.i2p.crypto.eddsa.math.GroupElement;
17
18 /**
19 * @author str4d
20 *
21 */
22 public class EdDSAPublicKeySpec implements KeySpec {
23 private final GroupElement A;
24 private final GroupElement Aneg;
25 private final EdDSAParameterSpec spec;
26
27 /**
28 * @param pk the public key
29 * @param spec the parameter specification for this key
30 * @throws IllegalArgumentException if key length is wrong
31 */
32 public EdDSAPublicKeySpec(byte[] pk, EdDSAParameterSpec spec) {
33 if (pk.length != spec.getCurve().getField().getb()/8)
34 throw new IllegalArgumentException("public-key length is wrong");
35
36 this.A = new GroupElement(spec.getCurve(), pk);
37 // Precompute -A for use in verification.
38 this.Aneg = A.negate();
39 Aneg.precompute(false);
40 this.spec = spec;
41 }
42
43 public EdDSAPublicKeySpec(GroupElement A, EdDSAParameterSpec spec) {
44 this.A = A;
45 this.Aneg = A.negate();
46 Aneg.precompute(false);
47 this.spec = spec;
48 }
49
50 public GroupElement getA() {
51 return A;
52 }
53
54 public GroupElement getNegativeA() {
55 return Aneg;
56 }
57
58 public EdDSAParameterSpec getParams() {
59 return spec;
60 }
61 }