Skip to content

Commit

Permalink
Merge pull request #98 from cosmos/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
ftheirs authored Sep 19, 2023
2 parents 70676ed + 0105338 commit 0e7a871
Show file tree
Hide file tree
Showing 10 changed files with 57 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/Makefile.version
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ APPVERSION_M=2
# This is the `spec_version` field of `Runtime`
APPVERSION_N=35
# This is the patch version of this release
APPVERSION_P=12
APPVERSION_P=13
1 change: 1 addition & 0 deletions app/src/chain_config.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ typedef struct {
static const chain_config_t chainConfig[] = {
// {118, cosmos, BECH32_COSMOS},
{60, "inj", BECH32_ETH},
{60, "evmos", BECH32_ETH}
};

static const uint32_t chainConfigLen = sizeof(chainConfig) / sizeof(chainConfig[0]);
Expand Down
Binary file modified tests_zemu/snapshots/s-mainmenu/00004.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests_zemu/snapshots/s-mainmenu/00010.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests_zemu/snapshots/sp-mainmenu/00004.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests_zemu/snapshots/sp-mainmenu/00010.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests_zemu/snapshots/st-mainmenu/00001.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests_zemu/snapshots/x-mainmenu/00004.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests_zemu/snapshots/x-mainmenu/00010.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
55 changes: 55 additions & 0 deletions tests_zemu/tests/textual.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -226,4 +226,59 @@ describe('Textual', function () {
await sim.close()
}
})

test.concurrent.each(DEVICE_MODELS)('sign basic textual evmos ', async function (m) {
const sim = new Zemu(m.path)
try {
await sim.start({ ...defaultOptions, model: m.name })
const app = new CosmosApp(sim.getTransport())

// Enable expert to allow sign with eth path
await sim.toggleExpertMode()

const path = [44, 60, 0, 0, 0]
const tx = Buffer.from(tx_sign_textual, 'hex')
const hrp = 'evmos'

// get address / publickey
const respPk = await app.getAddressAndPubKey(path, hrp)
expect(respPk.return_code).toEqual(0x9000)
expect(respPk.error_message).toEqual('No errors')
console.log(respPk)

// do not wait here..
const signatureRequest = app.sign(path, tx, hrp, TEXTUAL_TX)

// Wait until we are not in the main menu
await sim.waitUntilScreenIsNot(sim.getMainMenuSnapshot())
const last_index = await sim.navigateUntilText(
'.',
`${m.prefix.toLowerCase()}-textual-sign_basic_evmos`,
sim.startOptions.approveKeyword,
false,
false,
)

const resp = await signatureRequest
console.log(resp)

expect(resp.return_code).toEqual(0x9000)
expect(resp.error_message).toEqual('No errors')
expect(resp).toHaveProperty('signature')

// Now verify the signature
const sha3 = require('js-sha3')
const msgHash = Buffer.from(sha3.keccak256(tx), 'hex')

const signatureDER = resp.signature
const signature = secp256k1.signatureImport(Uint8Array.from(signatureDER))

const pk = Uint8Array.from(respPk.compressed_pk)

const signatureOk = secp256k1.ecdsaVerify(signature, msgHash, pk)
expect(signatureOk).toEqual(true)
} finally {
await sim.close()
}
})
})

0 comments on commit 0e7a871

Please sign in to comment.