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

fix: use new implementation of sha256 for array_dynamic_blackbox_input test #4360

Closed
wants to merge 2 commits into from

Conversation

guipublic
Copy link
Contributor

Description

Problem*

Resolves #4356

Summary*

Use the new method for sha256, which give a different result than the previous sha256.
This is really strange, there is probably something more going on. I give more information in the issue.

Additional Context

Documentation*

Check one:

  • No documentation needed.
  • Documentation included in this PR.
  • [Exceptional Case] Documentation to be submitted in a separate PR.

PR Checklist*

  • I have tested the changes locally.
  • I have formatted the changes with Prettier and/or cargo fmt on default settings.

Copy link
Contributor

@vezenovm vezenovm left a comment

Choose a reason for hiding this comment

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

I noticed that when making main unconstrained while still using #[foreign(sha256)] I also got a root that matches the result here. So the mismatch looks to come from passing a dynamic array to the old std::hash::sha256 in a constrained environment. So #4351 has some deeper bug. I'm not sure whether this test is worth merging as when running this program I never got into the DynamicArray case during flatten.

I'm currently looking into whether this is truly due to the dynamic array being read not being what we expect or something else with the sha blackbox func.

EDIT: I have found the actual bug with flattening a dynamic array and will post a PR

github-merge-queue bot pushed a commit that referenced this pull request Feb 14, 2024
# Description

## Problem\*

Resolves #4356 

Supercedes #4360

## Summary\*

An ACIR dynamic array is a pointer to flat memory. We have been treating
this flat memory as a list of fields, however, this breaks if we do in
fact need accurate numeric type information such as when working black
box function inputs. For example for hash inputs we set up the byte
array based upon the bit size. This needs to be the correct bit size or
else we will get a lot of extra garbage when calling
`fetch_nearest_bytes` on a FieldElement.

This PR attaches a list of `Vec<NumericType>` to the `AcirDynamicArray`
structure. This gives us the expected output result for `sha` then.

We probably could restrict the `AcirDynamicArray` to be created only
through a constructor where we check that the `value_types` match the
supplied len in size. I left it for a follow-up as this is a quick fix
but I can do it as part of this PR.

## Additional Context



## Documentation\*

Check one:
- [ ] No documentation needed.
- [ ] Documentation included in this PR.
- [ ] **[Exceptional Case]** Documentation to be submitted in a separate
PR.

# PR Checklist\*

- [ ] I have tested the changes locally.
- [ ] I have formatted the changes with [Prettier](https://prettier.io/)
and/or `cargo fmt` on default settings.

---------

Co-authored-by: TomAFrench <tom@tomfren.ch>
@vezenovm
Copy link
Contributor

Closing in favor of #4364

@vezenovm vezenovm closed this Feb 14, 2024
@TomAFrench TomAFrench deleted the gd/issue_4356 branch November 20, 2024 12:03
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.

ACIR test array_dynamic_blackbox_input fails to verify in BB
2 participants