bloxbean / cardano-client-lib

Cardano client library in Java
https://cardano-client.dev
MIT License
120 stars 51 forks source link

FEATURE: CIP30 data sign doesn't support generating hashed content #447

Open matiwinnetou opened 1 month ago

matiwinnetou commented 1 month ago

Hardware wallets, e.g. ledger typically will only return message as a blake224 hash. If this is the case they typically add: hashed: TRUE in the unprotected header section.

Please add support for ability to sign hashed content to the java class.

https://github.com/bloxbean/cardano-client-lib/blob/24959cbe7928788d2426a7dd32bbf45ed08c190b/cip/cip30/src/main/java/com/bloxbean/cardano/client/cip/cip30/CIP30DataSigner.java#L22

Typically I would expect a new overloaded method where I can sing the payload and the signature will be using blake2b224.

matiwinnetou commented 1 month ago

Example:

payload (text):
{"action":"LOGIN","actionText":"Login","data":{"event":"CARDANO_SUMMIT_AWARDS_2024","network":"MAIN","role":"VOTER","walletId":"stake1uypayp2nyzy66tmcz6yjuth59pym0df83rjpk0758fhqrncq8vcdz","walletType":"CARDANO"},"slot":"136068943"}

signature: 84582aa201276761646472657373581de103d205532089ad2f7816892e2ef42849b7b52788e41b3fd43a6e01cfa166686173686564f5581c1c1afc33a1ed48205eadcbbda2fc8e61442af2e04673616f21b7d0385840954858f672e9ca51975655452d79a8f106011e9535a2ebfb909f7bbcce5d10d246ae62df2da3a7790edd8f93723cbdfdffc5341d08135b1a40e7a998e8b2ed06

key: a4010103272006215820c13745be35c2dfc3fa9523140030dda5b5346634e405662b1aae5c61389c55b3

payload (hex): 7b22616374696f6e223a224c4f47494e222c22616374696f6e54657874223a224c6f67696e222c2264617461223a7b226576656e74223a2243415244414e4f5f53554d4d49545f4157415244535f32303234222c226e6574776f726b223a224d41494e222c22726f6c65223a22564f544552222c2277616c6c65744964223a227374616b6531757970617970326e797a793636746d637a36796a757468353970796d3064663833726a706b30373538666871726e6371387663647a222c2277616c6c657454797065223a2243415244414e4f227d2c22736c6f74223a22313336303638393432227d
matiwinnetou commented 1 month ago
image
satran004 commented 1 month ago

Thanks @matiwinnetou . We will look into it.

matiwinnetou commented 1 month ago

https://github.com/bloxbean/cardano-client-lib/pull/453/files