Skip to content

Conversation

@rg911
Copy link
Contributor

@rg911 rg911 commented Sep 18, 2019

Signature Schema Refactoring

  • Signature schema (NIS1 vs Catapult) can be identified by NetworkType (based on confirmation from Core on [Sig-API]. Signatures of methods which previously used SignSchema have been refactored to use NetworkType instead.

    - NIS1: Public(Test) => Keccak (No key reversal any more)
    - Catapult: MIjin(Test) => SHA3
    
  • KeyPair generation under NIS1 does NOT reverse the private key bytes anymore. Keys & Address generated / derived under NIS1 schema in the SDK will not be compatible with current public net any more.

  • Fixed all unit tests (due to key reversal removed)

@coveralls
Copy link

coveralls commented Sep 18, 2019

Pull Request Test Coverage Report for Build 664

  • 133 of 134 (99.25%) changed or added relevant lines in 30 files are covered.
  • 3 unchanged lines in 2 files lost coverage.
  • Overall coverage increased (+0.2%) to 69.096%

Changes Missing Coverage Covered Lines Changed/Added Lines %
src/model/account/Account.ts 20 21 95.24%
Files with Coverage Reduction New Missed Lines %
src/infrastructure/receipt/CreateReceiptFromDTO.ts 1 68.0%
src/infrastructure/MosaicHttp.ts 2 52.5%
Totals Coverage Status
Change from base Build 651: 0.2%
Covered Lines: 6264
Relevant Lines: 8363

💛 - Coveralls

Copy link
Contributor

@fboucquez fboucquez left a comment

Choose a reason for hiding this comment

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

Hi Steve, I've added a few comments. Nothing blocker. What do you think about them?

secretKey = convert.hexToUint8Reverse(convert.uint8ToHex(secretKey));
}
return Utility.catapult_crypto.deriveSharedKey(salt, secretKey, publicKey, Utility.catapult_hash.func, signSchema);
return Utility.catapult_crypto.deriveSharedKey(salt, keyPair.privateKey, publicKey, Utility.catapult_hash.func, networkType);
Copy link
Contributor

Choose a reason for hiding this comment

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

I would keep the reverse hooks, maybe create a utility method that reverse if necessary (called every time there was a hexToUint8Reverse). Just in case you want to add the reverse stuff in the future.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure about this. Let's confirm with core first. If the decision is non-reversal I don't think we should keep it.

The 'hexToUint8Reverse' definitely stays, as will probably need it at some point. E.g. the UInt64 is using Little Endian.

'NCBC4VAQBVSB4J5J2PTFM7OUY5CYDL33VW7RKW7K',
'NBLW3CQPBGPCFAXG4XM5GDEVLPESCPDPFO7NUCOM',
'NA5RDU36TKBTW4KVSSPD7PT5YTUMD7OIJFMMIEEQ',
'MDIPRQMB3HT7A6ZKV7HOHJQM7JHX6H3FN5YHHZMD',
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe you can load the test cases directly from the vector files. I've added that to Java sdk.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point, but the size of the test vector json files is a concern. To keep all unit tests run offline, need to copy the files to the project.

* Determines the validity of a decoded address.
* @param {Uint8Array} decoded The decoded address.
* @param {SignSchema} signSchema The Sign Schema. (KECCAK_REVERSED_KEY / SHA3)
* @param {number} networkIdentifier The network identifier.
Copy link
Contributor

Choose a reason for hiding this comment

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

what is network identifier ? Is it a networkType ? or maybe do we need an added model NetworkIdentifier ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think's it's a typo. should read NetworkType

Copy link
Contributor

@fboucquez fboucquez left a comment

Choose a reason for hiding this comment

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

All good. The only thing would be to add more vector tests related to Keccak (not reversed) once the new vectors have been defined. In Java, I'm still supporting reversed Keccak just for the tests although network type resolves the non-reverse Keccak. Just for a confidence boost, if the reverse Keccak (nes1) vector tests passes, new simpler Keccak implementation would pass too.

@rg911 rg911 merged commit 9e3f83f into symbol:master Sep 20, 2019
@rg911 rg911 deleted the task/g253_signSchema_refactoring branch October 8, 2019 20:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants