Class Ed25519PublicKeys

java.lang.Object
io.jans.lock.trace.crypto.bc.Ed25519PublicKeys

public final class Ed25519PublicKeys extends Object
Builds Ed25519 PublicKeys from RFC 8037 OKP JWKs ({"kty":"OKP","crv":"Ed25519","x":"<32 raw bytes, base64url>"}) through the JCA KeyFactory of the installed BouncyCastle provider (standard or FIPS), so no BC-internal class is referenced.

The raw 32-byte key is wrapped in the RFC 8410 SubjectPublicKeyInfo DER structure (30 2a 30 05 06 03 2b 65 70 03 21 00 || raw), the only public-key encoding every JCA provider is required to understand.

Not reused on purpose: io.jans.as.model.crypto.AbstractCryptoProvider and EDDSASigner treat x as a full SPKI blob (non-RFC-8037) and refuse FIPS mode.

Author:
Yuriy Movchan
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
    JCA algorithm name used for KeyFactory, Signature and KeyPairGenerator.
    static final String
    JWK curve name (RFC 8037 §3.1).
    static final String
    JWK key type of Edwards-curve keys (RFC 8037 §2).
    static final int
    Length of a raw Ed25519 public key (RFC 8032 §5.1.5).
  • Method Summary

    Modifier and Type
    Method
    Description
    static PublicKey
    fromJwk(com.fasterxml.jackson.databind.JsonNode jwk)
    Builds the public key from a JWK given as a Jackson object node (the shape received by the admin API).
    static PublicKey
    Builds the public key from a JWK given as a string map (the shape stored in jansTracePublicKeyJwk).
    static PublicKey
    fromRaw(byte[] raw)
    Builds the public key from its raw 32 bytes (RFC 8032 encoding, as carried in JWK x).
    static String
    RFC 7638 / RFC 8037 §A.3 JWK thumbprint of an Ed25519 key in the TRACE hash format : "sha256:" + lowercaseHex(SHA-256(UTF-8( '{"crv":"Ed25519","kty":"OKP","x":"<x>"}'))).

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Method Details

    • thumbprint

      public static String thumbprint(Map<String,String> jwk)
      RFC 7638 / RFC 8037 §A.3 JWK thumbprint of an Ed25519 key in the TRACE hash format : "sha256:" + lowercaseHex(SHA-256(UTF-8( '{"crv":"Ed25519","kty":"OKP","x":"<x>"}'))). The required members are written in lexicographic order with no whitespace; the JWK's x is used exactly as stored, and no other member can influence the result (the input is not built from the map).
      Throws:
      TraceCryptoException - with reason jwk_format when the JWK is null or has no x, or jwk_x_encoding when x is not an unpadded base64url encoding of 32 bytes
    • fromJwk

      public static PublicKey fromJwk(Map<String,String> jwk)
      Builds the public key from a JWK given as a string map (the shape stored in jansTracePublicKeyJwk). Members other than kty, crv, x and d are ignored.
      Throws:
      TraceCryptoException - with reason jwk_format, jwk_kty, jwk_crv, jwk_private_material, jwk_x_encoding, jwk_x_length, invalid_key or crypto_unavailable
    • fromJwk

      public static PublicKey fromJwk(com.fasterxml.jackson.databind.JsonNode jwk)
      Builds the public key from a JWK given as a Jackson object node (the shape received by the admin API). Members other than kty, crv, x and d are ignored.
      Throws:
      TraceCryptoException - see fromJwk(Map)
    • fromRaw

      public static PublicKey fromRaw(byte[] raw)
      Builds the public key from its raw 32 bytes (RFC 8032 encoding, as carried in JWK x).
      Throws:
      TraceCryptoException - with reason jwk_x_length, invalid_key or crypto_unavailable