Interface TraceCryptoProvider
TraceCryptoImpl.
Scopes. The Ed25519 signature covers the JCS (RFC 8785) form of the record
without its top-level signature member. The content_digest covers the
JCS form of the complete record, signature included.
Receipt hash. "sha256:" + hex(SHA-256(JCS(m))) where m has exactly
these members: receipt_profile (TraceHashes.RECEIPT_PROFILE),
evidence_domain_id, receipt_sequence (JSON integer), received_at
(RFC 3339 UTC string with three fraction digits, see TraceTime), producer_id,
record_id, content_digest and prev_receipt_hash.
Thread safety. Implementations are @ApplicationScoped singletons. Every
method is safe for concurrent use.
Failures are reported as TraceCryptoException; messages carry no key material,
signature bytes or record content.
- Author:
- Yuriy Movchan
-
Method Summary
Modifier and TypeMethodDescriptioncanonicalize(com.fasterxml.jackson.databind.JsonNode node) describe()booleanBuilds a verification key from a public Ed25519 JWK (kty,crv,x).receiptHash(String domainId, long receiptSequence, long receivedAtMs, String producerId, String recordId, String contentDigest, String prevReceiptHash) voidtype()verifyAndDigest(TraceSignedRecord record, byte[] signature, TraceVerificationKey key) Verifiessignature(Ed25519) over the JCS form of the record without its top-levelsignaturemember and computes the content digest.
-
Method Details
-
type
TraceCryptoProviderType type()- Returns:
- the type this provider implements
-
requireAvailable
void requireAvailable()- Throws:
TraceCryptoException- with reasoncrypto_unavailablewhen the provider cannot perform Ed25519 verification
-
isAvailable
boolean isAvailable()- Returns:
truewhenrequireAvailable()would not throw
-
describe
String describe()- Returns:
- one line for the startup log; never contains secrets
-
canonicalize
- Returns:
- the RFC 8785 canonical text of
node - Throws:
TraceCryptoException- with reasoncanonicalization_failed
-
parseKey
Builds a verification key from a public Ed25519 JWK (kty,crv,x).- Throws:
TraceCryptoException- with ajwk_*reason,invalid_keyorcrypto_unavailable
-
verifyAndDigest
Verifiessignature(Ed25519) over the JCS form of the record without its top-levelsignaturemember and computes the content digest.- Returns:
content_digest:"sha256:" + hex(SHA-256(JCS(complete record)))- Throws:
TraceCryptoException- with reasonsignature_mismatch,canonicalization_failedorcrypto_unavailable
-
receiptHash
String receiptHash(String domainId, long receiptSequence, long receivedAtMs, String producerId, String recordId, String contentDigest, String prevReceiptHash) - Returns:
- the receipt hash for one receipt-chain position (see the class description for the member set)
- Throws:
TraceCryptoException- with reasoninvalid_receipt_inputwhen an input cannot be a receipt position
-