| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 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 |
|
| 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 |
|
| 29 |
|
| 30 |
|
| 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 |
|
| 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 |
} |