Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use static string to test signMessage easier #233

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
# macOS finder
.DS_Store
.idea/
3 changes: 3 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -190,10 +190,8 @@ class MainViewModel(application: Application) : AndroidViewModel(application) {
if (!authorized) {
return@localAssociateAndExecute null
}
val messages = Array(numMessages) {
Random.nextBytes(1232)
}
doSignMessages(client, messages, arrayOf(_uiState.value.publicKey!!))
val message = "To avoid digital dognappers, sign below to authenticate with CryptoCorgis.".toByteArray(Charsets.UTF_8)
doSignMessages(client, arrayOf(message), arrayOf(_uiState.value.publicKey!!))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change will send only 1 message, irrespective of the value of the numMessages parameter. What if instead we did:

            val messages = Array(numMessages) { i ->
                "To avoid digital dognappers, sign below to authenticate with CryptoCorgis. [$i]".toByteArray(Charsets.UTF_8)
            }
            doSignMessages(client, messages, arrayOf(_uiState.value.publicKey!!))

This will append the message index to the string, ensuring that each message is unique (and thus that each signature will be unique as well)

}

showMessage(if (signedMessages != null) R.string.msg_request_succeeded else R.string.msg_request_failed)
Expand Down Expand Up @@ -444,7 +442,7 @@ class MainViewModel(application: Application) : AndroidViewModel(application) {
var signedMessages: Array<ByteArray>? = null
try {
val result = client.signMessages(messages, addresses).get()
Log.d(TAG, "Signed message(s): $result")
Log.d(TAG, "Signed message base58: ${Base58EncodeUseCase(result.signedPayloads[0])}")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd love to print out all the payloads here. not just the 0'th one.
Perhaps leave the original Log statement (to dump the whole object, in case we add fields to it in the future), followed by iterating through each payload and printint out the base58 signature?

signedMessages = result.signedPayloads
} catch (e: ExecutionException) {
when (val cause = e.cause) {
Expand Down