Class VoucherSerializationUtils
java.lang.Object
xyz.tcheeric.cashu.voucher.domain.util.VoucherSerializationUtils
Utility class for canonical CBOR serialization of voucher data.
Provides deterministic serialization required for voucher signature generation and verification. Uses CBOR (Concise Binary Object Representation) to ensure stable byte representation across platforms and implementations.
Thread-safe and stateless.
- See Also:
-
Method Summary
-
Method Details
-
toCbor
Serializes a map to CBOR bytes in canonical form.The input map must have deterministic ordering (e.g., LinkedHashMap) to ensure consistent byte output for signature generation.
- Parameters:
data- the map to serialize (must not be null)- Returns:
- CBOR-encoded bytes
- Throws:
IllegalArgumentException- if serialization fails
-
fromCbor
Deserializes CBOR bytes to a map.- Parameters:
cborBytes- the CBOR-encoded bytes (must not be null)- Returns:
- the deserialized map
- Throws:
IllegalArgumentException- if deserialization fails
-