sway/sway-features
Igor Rončević 8d4178f12d
Some checks are pending
CI / cargo-fmt-check (push) Waiting to run
Codspeed Benchmarks / benchmarks (push) Waiting to run
CI / build-sway-examples (push) Waiting to run
CI / get-fuel-core-version (push) Waiting to run
CI / build-sway-lib-std (push) Waiting to run
CI / check-forc-manifest-version (push) Waiting to run
CI / verifications-complete (push) Blocked by required conditions
CI / check-dependency-version-formats (push) Waiting to run
CI / build-reference-examples (push) Waiting to run
CI / forc-fmt-check-sway-lib-std (push) Waiting to run
CI / forc-fmt-check-sway-examples (push) Waiting to run
CI / forc-fmt-check-panic (push) Waiting to run
CI / check-sdk-harness-test-suite-compatibility (push) Waiting to run
CI / build-mdbook (push) Waiting to run
CI / cargo-test-sway-lsp (push) Waiting to run
CI / build-forc-doc-sway-lib-std (push) Waiting to run
CI / build-forc-test-project (push) Waiting to run
CI / cargo-build-workspace (push) Waiting to run
CI / cargo-clippy (push) Waiting to run
CI / cargo-toml-fmt-check (push) Waiting to run
CI / cargo-test-forc (push) Waiting to run
CI / cargo-run-e2e-test (push) Blocked by required conditions
CI / cargo-run-e2e-test-release (push) Blocked by required conditions
CI / cargo-run-e2e-test-evm (push) Waiting to run
CI / cargo-test-lib-std (push) Waiting to run
CI / forc-run-benchmarks (push) Waiting to run
CI / forc-unit-tests (push) Waiting to run
CI / forc-pkg-fuels-deps-check (push) Waiting to run
CI / cargo-test-forc-debug (push) Blocked by required conditions
CI / cargo-test-forc-client (push) Blocked by required conditions
CI / cargo-test-forc-node (push) Blocked by required conditions
CI / cargo-test-workspace (push) Waiting to run
CI / cargo-unused-deps-check (push) Waiting to run
CI / notify-slack-on-failure (push) Blocked by required conditions
CI / pre-publish-check (push) Waiting to run
CI / publish (push) Blocked by required conditions
CI / publish-sway-lib-std (push) Blocked by required conditions
CI / Build and upload forc binaries to release (push) Blocked by required conditions
github pages / deploy (push) Waiting to run
Implement new hashing (#7259)
## Description

This PR implements new hashing, as explained in the tracking issue
#7256. New hashing is an opt-in experimental feature with the feature
flag `new_hashing`.

The new hashing hashes lengths as prefix to the content hash for the
following built-in and `std` types:
- string slices (`str`)
- arrays (`[T; N]`)
- `std::vec::Vec<T>`
- `std::bytes::Bytes`

Some of the `std` types that use the above types internally for storing
their content still hash only the content, without the length prefix of
the container. The reason for this is that 1) the choice of the
container is just an implementation detail and 2) the semantics of the
type requires only the content (mostly of the fixed, type-specific
length) to be hashed.

A typical example would be `std::b512::B512` where, same to `b256` we
want to hash only the content.

Notice that this does not cause the security issue described in #7256.

Here is the complete list of those types:
- `std::crypto::secp256k1::Secp256k1`
- `std::crypto::secp256r1::Secp256r1`
- `std::crypto::message::Message`
- `std::crypto::public_key::PublicKey`
- `std::b512::B512`
 
Some of the implementations differ based on the combination of
`const_generics` and `new_hashing` features. Therefore, on CI, we have a
step testing both experimental features together.

Additionally, the PR:
- adds missing `Hash` implementations for string arrays (`str[N]`).
- adds testing of `const_generics` experimental feature to CI.

## Checklist

- [x] I have linked to any relevant issues.
- [x] I have commented my code, particularly in hard-to-understand
areas.
- [ ] I have updated the documentation where relevant (API docs, the
reference, and the Sway book).
- [ ] If my change requires substantial documentation changes, I have
[requested support from the DevRel
team](https://github.com/FuelLabs/devrel-requests/issues/new/choose)
- [x] I have added tests that prove my fix is effective or that my
feature works.
- [x] I have added (or requested a maintainer to add) the necessary
`Breaking*` or `New Feature` labels where relevant.
- [x] I have done my best to ensure that my PR adheres to [the Fuel Labs
Code Review
Standards](https://github.com/FuelLabs/rfcs/blob/master/text/code-standards/external-contributors.md).
- [x] I have requested a review from the relevant team or maintainers.
2025-07-11 14:39:29 +12:00
..
src Implement new hashing (#7259) 2025-07-11 14:39:29 +12:00
Cargo.toml Fix source dependencies preventing release (#7012) 2025-03-11 18:54:51 +04:00