Class SignedVoucher
java.lang.Object
xyz.tcheeric.cashu.voucher.domain.SignedVoucher
A voucher secret with an issuer's cryptographic signature.
SignedVoucher represents a complete voucher that has been cryptographically signed by the issuing merchant. It combines the voucher secret with the issuer's ED25519 signature and public key for verification.
Verification
The signature can be verified using verify() which delegates to
VoucherSignatureService. A voucher is considered fully valid if:
- The signature is cryptographically valid (
verify()returns true) - The voucher has not expired (
isExpired()returns false)
Model B Constraint
Signed vouchers are only redeemable with the issuing merchant identified by
secret.issuerId. They cannot be redeemed at the mint.
Immutability
This class is immutable once created. All fields are final.
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionSignedVoucher(@NonNull VoucherSecret secret, @lombok.NonNull byte[] issuerSignature, @NonNull String issuerPublicKey) Creates a signed voucher. -
Method Summary
Modifier and TypeMethodDescriptionbooleanbyte[]Returns a defensive copy of the signature bytes.inthashCode()booleanChecks if this voucher has expired.booleanisValid()Checks if this voucher is fully valid (signature valid AND not expired).toString()Returns a string representation for debugging.Returns a detailed string representation including full secret metadata.booleanverify()Verifies the cryptographic signature of this voucher.
-
Constructor Details
-
SignedVoucher
public SignedVoucher(@NonNull @NonNull VoucherSecret secret, @NonNull @lombok.NonNull byte[] issuerSignature, @NonNull @NonNull String issuerPublicKey) Creates a signed voucher.- Parameters:
secret- the voucher secret (must not be null)issuerSignature- the issuer's signature (must not be null, 64 bytes for ED25519)issuerPublicKey- the issuer's public key hex string (must not be null)- Throws:
IllegalArgumentException- if any parameter is invalid
-
-
Method Details
-
verify
public boolean verify()Verifies the cryptographic signature of this voucher.Delegates to
VoucherSignatureService.verify(VoucherSecret, byte[], String)to perform ED25519 signature verification.- Returns:
- true if the signature is valid, false otherwise
-
isExpired
public boolean isExpired()Checks if this voucher has expired.Delegates to
VoucherSecret.isExpired().- Returns:
- true if expired, false if valid or no expiry set
-
isValid
public boolean isValid()Checks if this voucher is fully valid (signature valid AND not expired).A voucher is considered valid if:
- The signature verifies correctly
- The voucher has not expired
- Returns:
- true if signature is valid and voucher not expired, false otherwise
-
getIssuerSignature
public byte[] getIssuerSignature()Returns a defensive copy of the signature bytes.- Returns:
- copy of the signature bytes
-
toString
Returns a string representation for debugging. -
toStringWithMetadata
Returns a detailed string representation including full secret metadata.- Returns:
- detailed human-readable string
-
equals
-
hashCode
public int hashCode()
-