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

feat(certificate): first draft implementation #166

Merged
merged 13 commits into from
Oct 30, 2023
Merged

Conversation

bacco1977
Copy link
Contributor

Implementation and tests done
Test is failing calling the blake function
The hash message is 66 bytes instead of 32
The test has been renamed as certificate.torename.ts
@fabiorigam to review

@fabiorigam fabiorigam marked this pull request as ready for review October 26, 2023 14:51
@fabiorigam fabiorigam linked an issue Oct 26, 2023 that may be closed by this pull request
2 tasks
Copy link
Member

@pierobassa pierobassa left a comment

Choose a reason for hiding this comment

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

Looks good to me 🎖️! Left some considerations

packages/core/src/certificate/certificate.ts Outdated Show resolved Hide resolved
packages/core/src/certificate/certificate.ts Outdated Show resolved Hide resolved
Comment on lines 22 to 26
expect(certificate.encode({ ...cert, signature: sig })).toEqual(
certificate.encode({
...cert,
signature: sig
})
Copy link
Member

Choose a reason for hiding this comment

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

Why are we checking if encode of the same input returns the same output? @fabiorigam

Also please add tests on casing of the signature like in thor-devkit

Copy link
Contributor Author

@bacco1977 bacco1977 Oct 28, 2023

Choose a reason for hiding this comment

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

Silly mistake.
However for the casing of the signature, it appears the encode function is case sensitive for the signer field. Is that an error in the implementation? @pierobassa
This is the test:
expect(certificate.encode(cert)).toStrictEqual(
certificate.encode({ ...cert2, signer: cert2.signer.toUpperCase() })
);
I think we need to add again the "lowercase conversion" into the encode function. @fabiorigam would you agree?

Copy link
Contributor Author

@bacco1977 bacco1977 Oct 30, 2023

Choose a reason for hiding this comment

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

Agreed with @fabiorigam not to implement the casing tests to be aligned with ethers convention:
264c909

packages/core/src/certificate/certificate.ts Outdated Show resolved Hide resolved
export interface Certificate {
purpose: string;
payload: {
type: string;
Copy link
Member

Choose a reason for hiding this comment

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

Just curious what values this can take ... if its an enumerated type for example?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

you mean the payload? @claytonneal

* @param cert - The certificate object with a digital signature.
* @throws {Error} If the signature is missing, invalid, or doesn't match the signer's public key.
*/
function verify(cert: Certificate): void {
Copy link
Member

@claytonneal claytonneal Oct 26, 2023

Choose a reason for hiding this comment

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

should this also verify that fields are not null/empty, e.g. if domain is empty string for example?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it verifies that signature is not empty. Do we know what other fields ware mandatory and why?
Old implementation checked only for signature. It doesn't mean it is correct but do we know what we need to ccheck there?

Copy link
Contributor

@rodolfopietro97 rodolfopietro97 left a comment

Choose a reason for hiding this comment

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

Left some comments

@github-actions
Copy link

github-actions bot commented Oct 30, 2023

Test Coverage

Summary

Lines Statements Branches Functions
Coverage: 99%
99.53% (856/860) 98.33% (236/240) 100% (157/157)
Title Tests Skipped Failures Errors Time
core 218 0 💤 0 ❌ 0 🔥 1m 3s ⏱️
network 11 0 💤 0 ❌ 0 🔥 3.39s ⏱️
errors 25 0 💤 0 ❌ 0 🔥 14.69s ⏱️

@rodolfopietro97 rodolfopietro97 merged commit 8420562 into main Oct 30, 2023
@rodolfopietro97 rodolfopietro97 deleted the certificate branch October 30, 2023 13:43
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.

Certificate :: Offline
5 participants