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

remove the crc-32 library from dependency #1565

Merged

Conversation

Danil42Russia
Copy link
Contributor

@Danil42Russia Danil42Russia commented Jan 24, 2025

Issue

Closes #1437.

The table was generated in advance, via:

function main() {
  const POLYNOMIAL = -306674912;
  for (let i = 0; i < 256; i++) {
    let r = i;
    for (let bit = 8; bit > 0; --bit) {
      r = ((r & 1) ? ((r >>> 1) ^ POLYNOMIAL) : (r >>> 1));
    }

    console.log(("0x" + (r >>> 0).toString(16)).padStart(8, "0"))
  }
}

If you need to write tests, I'll add them

Checklist

  • I have updated CHANGELOG.md
  • I have run all the tests locally and no test failure was reported
  • I have run the linter, formatter and spellchecker
  • I did not do unrelated and/or undiscussed refactorings

@Danil42Russia Danil42Russia requested a review from a team as a code owner January 24, 2025 18:36
src/utils/crc32.ts Outdated Show resolved Hide resolved
Copy link
Contributor

@verytactical verytactical left a comment

Choose a reason for hiding this comment

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

The original issue started specifically with

Write tests with a contract that uses crc32 function that pass strings with unicode characters.

Until there are tests for unicode characters, or rather any crc32 tests at all, we can't even know that hash is computed the way it did before, and can't do any of these changes.

@verytactical
Copy link
Contributor

Imagine worst-case scenario: we have something like message(crc32()) in tact contract, gets evaluated at compile-time as constant expression, all the contract tests pass because bindings use precisely the same value, then incorrect contract is deployed.

src/utils/crc32.ts Outdated Show resolved Hide resolved
Copy link
Member

@anton-trunov anton-trunov left a comment

Choose a reason for hiding this comment

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

We are looking for ways to make our code verifiable, so no tables like that should be hardcoded

@Danil42Russia
Copy link
Contributor Author

so no tables like that should be hardcoded

Can you then create a issue to remove the table in crc16?

@anton-trunov
Copy link
Member

#1635

src/utils/crc32.ts Outdated Show resolved Hide resolved
@anton-trunov anton-trunov merged commit be96b46 into tact-lang:main Jan 31, 2025
24 checks passed
@anton-trunov anton-trunov added this to the v1.6.0 milestone Jan 31, 2025
@anton-trunov anton-trunov self-assigned this Jan 31, 2025
@Danil42Russia Danil42Russia deleted the danil42russia/remove_crc32_dependence branch January 31, 2025 18: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.

Remove crc-32 dependency
3 participants