Package zeroecho.core.alg.ed448
Class Ed448PrivateKeySpec
java.lang.Object
zeroecho.core.alg.ed448.Ed448PrivateKeySpec
- All Implemented Interfaces:
AlgorithmKeySpec
Ed448 Private Key Specification
Immutable specification for an Ed448 private key in PKCS#8 encoding.
This class acts as a typed carrier for encoded private key material,
typically used with Ed448PrivateKeyBuilder to reconstruct a usable
PrivateKey. It also provides marshal/unmarshal helpers
to serialize the key into a portable PairSeq representation.
Encoding
- The byte array is expected to contain a valid PKCS#8-encoded Ed448 private key.
- Internally, the array is defensively cloned on construction and when
returned by
encoded(). - The
marshal(Ed448PrivateKeySpec)andunmarshal(PairSeq)methods wrap and unwrap the PKCS#8 bytes using base64 without padding.
Usage
// Wrap existing PKCS#8-encoded bytes
Ed448PrivateKeySpec spec = new Ed448PrivateKeySpec(pkcs8Bytes);
// Import into JCA PrivateKey via builder
PrivateKey key = new Ed448PrivateKeyBuilder().importPrivate(spec);
// Serialize to PairSeq (e.g., JSON transport)
PairSeq p = Ed448PrivateKeySpec.marshal(spec);
// Deserialize from PairSeq
Ed448PrivateKeySpec restored = Ed448PrivateKeySpec.unmarshal(p);
Thread-safety
Instances are immutable and safe to share across threads.- Since:
- 1.0
-
Constructor Summary
ConstructorsConstructorDescriptionEd448PrivateKeySpec(byte[] encodedPkcs8) Constructs a new Ed448 private key spec from the given PKCS#8-encoded bytes. -
Method Summary
Modifier and TypeMethodDescriptionbyte[]encoded()Returns a defensive copy of the PKCS#8-encoded private key bytes.static PairSeqmarshal(Ed448PrivateKeySpec spec) Serializes this key spec into aPairSeqrecord.static Ed448PrivateKeySpecDeserializes aPairSeqinto a newEd448PrivateKeySpec.
-
Constructor Details
-
Ed448PrivateKeySpec
public Ed448PrivateKeySpec(byte[] encodedPkcs8) Constructs a new Ed448 private key spec from the given PKCS#8-encoded bytes.- Parameters:
encodedPkcs8- PKCS#8-encoded Ed448 private key (non-null)- Throws:
IllegalArgumentException- ifencodedPkcs8isnull
-
-
Method Details
-
encoded
public byte[] encoded()Returns a defensive copy of the PKCS#8-encoded private key bytes.- Returns:
- cloned PKCS#8-encoded key bytes
-
marshal
Serializes this key spec into aPairSeqrecord.The encoding is base64 without padding. The
typefield is set to"Ed448-PRIV", and the PKCS#8 bytes are stored under the key"pkcs8.b64".- Parameters:
spec- the key spec to serialize- Returns:
- a
PairSeqcontaining the type and base64 data
-
unmarshal
Deserializes aPairSeqinto a newEd448PrivateKeySpec.Expects a field
"pkcs8.b64"containing the base64-encoded PKCS#8 private key bytes. Other fields are ignored.- Parameters:
p- the serialized pair sequence- Returns:
- a reconstructed
Ed448PrivateKeySpec - Throws:
IllegalArgumentException- ifpkcs8.b64is missing
-