From b711fb7acaf38e44a964745c8db9f028f20b92e7 Mon Sep 17 00:00:00 2001 From: Juan Leni Date: Thu, 28 May 2020 11:53:10 +0200 Subject: [PATCH] fixing ed25591 derivation and updating test --- app/Makefile | 2 +- app/src/crypto.c | 6 +----- tests_zemu/tests/test.js | 11 +++++------ 3 files changed, 7 insertions(+), 12 deletions(-) diff --git a/app/Makefile b/app/Makefile index c1301ed0..d24cce9d 100755 --- a/app/Makefile +++ b/app/Makefile @@ -28,7 +28,7 @@ include $(BOLOS_SDK)/Makefile.defines APPNAME = "Zcash" APPVERSION_M=2 APPVERSION_N=0 -APPVERSION_P=1 +APPVERSION_P=2 APPPATH = "44'/133'" APP_LOAD_PARAMS = --appFlags 0x200 --delete $(COMMON_LOAD_PARAMS) --path ${APPPATH} --path "44'/1'" diff --git a/app/src/crypto.c b/app/src/crypto.c index 97e0081b..7af49a51 100644 --- a/app/src/crypto.c +++ b/app/src/crypto.c @@ -226,11 +226,7 @@ void crypto_fillSaplingSeed(uint8_t *sk) { 0x80000000, }; - // FIXME: Zemu/Speculos still does not emulate the derivation correctly - // FIXME: so the seed that is generated is still fixed - // This is fine for Milestone 1 - - os_perso_derive_node_bip32_seed_key(HDW_ED25519_SLIP10, CX_CURVE_Ed25519, + os_perso_derive_node_bip32_seed_key(HDW_NORMAL, CX_CURVE_Ed25519, path, HDPATH_LEN_DEFAULT, sk, NULL, diff --git a/tests_zemu/tests/test.js b/tests_zemu/tests/test.js index b3093a60..8f8f16bc 100644 --- a/tests_zemu/tests/test.js +++ b/tests_zemu/tests/test.js @@ -97,9 +97,8 @@ describe('Basic checks', function () { console.log(addr) expect(addr.return_code).toEqual(0x9000); - // FIXME: Ed25519 hd derivation in the emulator so the seed generated by the emulated SDK API is fixed for now - const expected_addr_raw = "cf99b502893ec7f2a2d275857abfea9848ca284e20530c410bfc133322a84d8326129c9dd39829bf65cd41"; - const expected_addr = "zs1e7vm2q5f8mrl9gkjwkzh40l2npyv52zwypfscsgtlsfnxg4gfkpjvy5unhfes2dlvhx52ywndr"; + const expected_addr_raw = "30fac80e962eb83353ff39d8f4fc255bc3464d0d842a257f849682f4903c11f16ab174aaabe27ff7f60269"; + const expected_addr = "zs1xravsr5k96urx5ll88v0flp9t0p5vngdss4z2luyj6p0fypuz8ck4vt54247yllh7cpxjjcxsv"; const addr_raw = addr.address_raw.toString('hex'); expect(addr_raw).toEqual(expected_addr_raw); @@ -116,7 +115,7 @@ describe('Basic checks', function () { await sim.start(sim_options); const app = new ZCashApp(sim.getTransport()); - const addrRequest = app.showAddressAndPubKey("m/44'/133'/5'/0'/0'"); + const addrRequest = app.showAddressAndPubKey("m/44'/133'/5'/0'/1"); await Zemu.sleep(1000); await sim.clickBoth(); @@ -124,8 +123,8 @@ describe('Basic checks', function () { console.log(addr) expect(addr.return_code).toEqual(0x9000); - const expected_addr_raw = "cf99b502893ec7f2a2d275857abfea9848ca284e20530c410bfc133322a84d8326129c9dd39829bf65cd41"; - const expected_addr = "zs1e7vm2q5f8mrl9gkjwkzh40l2npyv52zwypfscsgtlsfnxg4gfkpjvy5unhfes2dlvhx52ywndr"; + const expected_addr_raw = "30fac80e962eb83353ff39d8f4fc255bc3464d0d842a257f849682f4903c11f16ab174aaabe27ff7f60269"; + const expected_addr = "zs1xravsr5k96urx5ll88v0flp9t0p5vngdss4z2luyj6p0fypuz8ck4vt54247yllh7cpxjjcxsv"; const addr_raw = addr.address_raw.toString('hex'); expect(addr_raw).toEqual(expected_addr_raw);