Sign hashes or any data with wallet's private key.
Signs data with a wallet private key. The card receives a transaction hash and signs it. The resulting signature is relayed to the blockchain along with the transaction. It proves that the user is authorized to dispose of assets stored on the address associated with the walet’s public key.
For the simplicity we created two methods if you want to sign one or several hashes. Method for one hash will return response with one signature, for many – many.
Request parameters
hash[es] <Sring> or array of <String>
One or several hashes of the data to be signed by the card.
walletPublicKey<Data>
The wallet's public key. Since a Tangem card can contain more than one wallet, you need to specify the wallet's public key that you want to use to sign the data.
cardId <String>
CID, Unique Tangem card ID number.
hdPath <DerivationPath> [optional]
Derivation path of the wallet. COS v. 4.28 and higher.
initialMessage<Message> [optional]
This message will be shown in the NFC session dialog.
Default: "Tap the card to your phone exactly as it shown above".
let hash =Data(repeating:0x1, count:32)// Test datalet walletPublicKey = card.wallets[0].publicKey //Sign with the first walletlet cardId = card.cardIdtangemSdk.sign(hash: hash, walletPublicKey: walletPublicKey, cardId: cardId) { result inswitch result {case .success(let response):let signature = response.signatureprint(signature)case .failure(let error):print(error) }}
val hash = Random.nextBytes(ByteArray(32)) // Random dataval walletPublicKey = card.wallets.first().publicKey //Sign with the first walletval cardId = card.cardIdtangemSdk.sign( hash: hash, walletPublicKey = walletPublicKey, cardId = cardId) { result ->when (result) {is CompletionResult.Success -> {runOnUiThread { Log.d(TAG, result.signature) } }is CompletionResult.Failure -> {runOnUiThread { Log.d(TAG, result.error) } } } }