java.lang.Object
net.i2p.crypto.eddsa.spec.EdDSAPrivateKeySpec
- All Implemented Interfaces:
KeySpec
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final byte[]The private scalar.private final GroupElementThe matching public point.private final byte[]The hash of the seed, from which the scalar and prefix come.private final byte[]The 32-byte seed the key was derived from.private final EdDSAParameterSpecThe curve parameters the key belongs to.Constructor Summary
ConstructorsConstructorDescriptionEdDSAPrivateKeySpec(byte[] seed, byte[] h, byte[] a, GroupElement aPoint, EdDSAParameterSpec spec) No validation of any parameters other than a.EdDSAPrivateKeySpec(byte[] a, GroupElement aPoint, EdDSAParameterSpec spec) No validation of any parameters other than a.EdDSAPrivateKeySpec(byte[] seed, EdDSAParameterSpec spec) Create a new EdDSA private key specification from a seed.EdDSAPrivateKeySpec(EdDSAParameterSpec spec, byte[] h) Initialize directly from the hash.Method Summary
Modifier and TypeMethodDescriptionprivate static byte[]copy(byte[] b) Defensive copy; null passes through unchanged.byte[]geta()Return the private key.getA()Return the public key.byte[]getH()Return the clamped hash of the seed, H(k), from which the scalar a is derived.Returns the parameter specification for this key.byte[]getSeed()Return the seed, or null if constructed from the private key directly.
Field Details
seed
private final byte[] seedThe 32-byte seed the key was derived from.h
private final byte[] hThe hash of the seed, from which the scalar and prefix come.a
private final byte[] aThe private scalar.A
The matching public point.spec
The curve parameters the key belongs to.
Constructor Details
EdDSAPrivateKeySpec
Create a new EdDSA private key specification from a seed.- Parameters:
seed- the private keyspec- the parameter specification for this key- Throws:
IllegalArgumentException- if seed length is wrong or hash algorithm is unsupported
EdDSAPrivateKeySpec
Initialize directly from the hash.getSeed()will return null if this constructor is used.- Parameters:
spec- the parameter specification for this keyh- the private key; copied and clamped on the copy, the caller's array is never modified- Throws:
IllegalArgumentException- if hash length is wrong
EdDSAPrivateKeySpec
No validation of any parameters other than a. getSeed() andgetH()will return null if this constructor is used.- Parameters:
a- must be "clamped" (for Ed) or reduced mod l (for Red); it is not validated - an invalid scalar silently yields a wrong public key. The array is copied, later changes by the caller have no effect.aPoint- if null, will be derived from a.spec- the domain parameters naming the curve and cofactor this key belongs to
EdDSAPrivateKeySpec
public EdDSAPrivateKeySpec(byte[] seed, byte[] h, byte[] a, GroupElement aPoint, EdDSAParameterSpec spec) No validation of any parameters other than a.- Parameters:
seed- may be null; copiedh- may be null; copieda- must be "clamped" (for Ed) or reduced mod l (for Red); it is not validated - an invalid scalar silently yields a wrong public key. The array is copied, later changes by the caller have no effect.aPoint- if null, will be derived from a.spec- the domain parameters naming the curve and cofactor this key belongs to
Method Details
copy
private static byte[] copy(byte[] b) Defensive copy; null passes through unchanged.- Parameters:
b- the array to copy, may be null- Returns:
- a clone of b, or null if b was null
getSeed
public byte[] getSeed()Return the seed, or null if constructed from the private key directly.- Returns:
- a copy of the seed, or null if constructed directly from the private key
getH
public byte[] getH()Return the clamped hash of the seed, H(k), from which the scalar a is derived.- Returns:
- a copy of the clamped hash of the seed, 2*bd8 bytes with the low bits of the first byte cleared and bit 6 of the last byte set
geta
public byte[] geta()Return the private key.- Returns:
- a copy of the private key
getA
getParams
Returns the parameter specification for this key.- Returns:
- the parameter specification