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

test: balance sanitization #1

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

sebastiantf
Copy link
Collaborator

@sebastiantf sebastiantf commented Feb 20, 2024

Description

  • Part of exploring @flyingnobita's lead on balance sanitization
  • Added a few tests that tries providing negative values to csv_parser, mst, range_check, big_uint_to_fp conversions

Observations

1. Cannot convert negative number into BigUint: test_negative_big_uint_conversion

  • BigUint conversion using to_biguint returns None. So unwrap() panics
  • Hence cannot convert negative number to big uint
  • BigUint is being converted to field element using merkle_sum_tree::utils::big_uint_to_fp

2. Field elements are non-negative values. So it doesn't seem possible to get a negative value into mst or range_check: test

  • halo2_proofs::halo2curves::bn256::Fr does not implement From trait for any signed integer types
  • Sidenote: Summa seems to use their own fork of halo2 which seems to use an old version of halo2curves v0.1.0 whereas PSE's halo2curves is at v0.6.1

3. csv_parser and merkle_sum_tree errors when using negative values: test_parse_csv_to_entries, test_mst_negative_value_in_csv

  • This is a direct effect of Observation 1 from the line

@0xnirlin
Copy link
Collaborator

Regarding this, one thing I was thinking, about is it even possible for an individual user of an exchange to have a negative value. I don't think it is possible.

@flyingnobita
Copy link
Collaborator

Yeah it "shouldn't" be possible. I believe that's why we need to put these constraints in the code to prevent a malicious custodian from undermining the system in anyway possible.

@igorline
Copy link
Collaborator

Same, haven't found yet any way to submit invalid value into the circuit as BigUint used won't allow this

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.

4 participants