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 wraps a VoucherSecret that stores the signature and
public key as NUT-10 compliant tags.
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.getIssuerId(). They cannot be redeemed at the mint.
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionSignedVoucher(@NonNull xyz.tcheeric.cashu.common.VoucherSecret secret) Creates a signed voucher from a VoucherSecret that already has signature and public key set.SignedVoucher(@NonNull xyz.tcheeric.cashu.common.VoucherSecret secret, @lombok.NonNull byte[] issuerSignature, @NonNull String issuerPublicKey) Creates a signed voucher from components (for deserialization compatibility). -
Method Summary
Modifier and TypeMethodDescriptionstatic SignedVouchercreate(@NonNull UUID voucherId, @NonNull String issuerId, @NonNull String unit, long faceValue, Long expiresAt, String memo, @NonNull BackingStrategy backingStrategy, double issuanceRatio, int faceDecimals, @NonNull String issuerSignature, @NonNull String issuerPublicKey) Creates a signed voucher with all voucher details.booleanintdoubleReturns the issuer public key.byte[]Returns the issuer signature as bytes.getMemo()getUnit()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 xyz.tcheeric.cashu.common.VoucherSecret secret) Creates a signed voucher from a VoucherSecret that already has signature and public key set.- Parameters:
secret- the voucher secret with signature and public key tags set- Throws:
IllegalArgumentException- if the secret doesn't have signature or public key
-
SignedVoucher
public SignedVoucher(@NonNull @NonNull xyz.tcheeric.cashu.common.VoucherSecret secret, @NonNull @lombok.NonNull byte[] issuerSignature, @NonNull @NonNull String issuerPublicKey) Creates a signed voucher from components (for deserialization compatibility).- Parameters:
secret- the voucher secretissuerSignature- the issuer's signature (64 bytes for Schnorr)issuerPublicKey- the issuer's public key hex string- Throws:
IllegalArgumentException- if any parameter is invalid
-
-
Method Details
-
create
public static SignedVoucher create(@NonNull @NonNull UUID voucherId, @NonNull @NonNull String issuerId, @NonNull @NonNull String unit, long faceValue, Long expiresAt, String memo, @NonNull @NonNull BackingStrategy backingStrategy, double issuanceRatio, int faceDecimals, @NonNull @NonNull String issuerSignature, @NonNull @NonNull String issuerPublicKey) Creates a signed voucher with all voucher details.- Parameters:
voucherId- unique voucher identifierissuerId- merchant identifierunit- currency unitfaceValue- face value in smallest unitexpiresAt- optional expiry timestampmemo- optional descriptionbackingStrategy- backing strategyissuanceRatio- issuance ratiofaceDecimals- decimal placesissuerSignature- hex-encoded signatureissuerPublicKey- hex-encoded public key- Returns:
- new SignedVoucher instance
-
verify
public boolean verify()Verifies the cryptographic signature of this voucher.- Returns:
- true if the signature is valid, false otherwise
-
isExpired
public boolean isExpired()Checks if this voucher has expired.- 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).- Returns:
- true if signature is valid and voucher not expired, false otherwise
-
getIssuerSignature
public byte[] getIssuerSignature()Returns the issuer signature as bytes.- Returns:
- signature bytes (64 bytes), or null if not set
-
getIssuerPublicKey
Returns the issuer public key.- Returns:
- hex-encoded public key
-
getVoucherId
-
getIssuerId
-
getUnit
-
getFaceValue
-
getExpiresAt
-
getMemo
-
getBackingStrategy
-
getIssuanceRatio
public double getIssuanceRatio() -
getFaceDecimals
public int getFaceDecimals() -
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()
-