Closed lucanicoladebiasi closed 2 weeks ago
Lines | Statements | Branches | Functions |
---|---|---|---|
100% (3404/3404) | 100% (794/794) | 100% (705/705) |
Title | Tests | Skipped | Failures | Errors | Time |
---|---|---|---|---|---|
core | 495 | 0 :zzz: | 0 :x: | 0 :fire: | 1m 7s :stopwatch: |
network | 658 | 0 :zzz: | 0 :x: | 0 :fire: | 4m 11s :stopwatch: |
errors | 48 | 0 :zzz: | 0 :x: | 0 :fire: | 11.704s :stopwatch: |
Accurate revision with @rodolfopietro97 shows the introduction of thor-devkit dependency in test code messes lint behaviour. Lint configuration must be changed, a specific ticket will be assigned for the task. Rodolfo and I decided to proceed to promote this PR to review to include the fixes.
Description
The code at
packages/core/src/certificate/certificate.ts
introducessign
method to encapsulate the logic encoding aCertificate
instance to its byte array representation;verify
method is compatible with the certificates built by with thor-devkit if the the certificate doesn't include text occurring in https://en.wikipedia.org/wiki/Unicode_equivalence ambiguities.The tests at
packages/core/tests/certificate/certificate.unit.test.ts
bignumber.js
library.NOTE: The
sign
method is introduced to avoid ambiguities in the transformation of a certificate from object to its byte representation through JSON and UTF8 encoding and decoding. If no UTF normalisation is enforced, 'high' Unicode planes (ideograms, emoticons) are not consistently represented with the same bytes because the normalisation is demanded to the runtime.Fixes # 943
sign
enforces UTF8 Normalization Form Canonical Composition to compute the signature.verify
is insensitive about the signer address case (but the equivalent thor-devkit code is not).sign
andverify
functions ignores additional properties introduced if the certificate instance extends theCertificate
interface: the signature is computed only on the basis of the properties defined in theCertificate
interface.Type of change
Please delete options that are not relevant.
How Has This Been Tested?
Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration
yarn test:solo
Test Configuration:
Checklist: