sxt-proof-of-sql icon indicating copy to clipboard operation
sxt-proof-of-sql copied to clipboard

Make Scalar conversions explicit

Open maujim opened this issue 1 year ago • 2 comments

Please go through the following checklist

  • [x] The PR title and commit messages adhere to guidelines here: https://github.com/spaceandtimelabs/sxt-proof-of-sql/blob/main/CONTRIBUTING.md. In particular ! is used if and only if at least one breaking change has been introduced.
  • [ ] I have run the ci check script with source scripts/run_ci_checks.sh.

Rationale for this change

  • this is step 1 of 3 for #228, each step will ideally be a standalone PR
  • /claim #228

What changes are included in this PR?

Copied from description of #228

  • Remove Into<[u64; 4]>, From<[u64; 4]>, and RefInto<[u64; 4]> bounds.
  • Replace these with the trait methods fn from_limbs(val: [u64; 4]) -> Self and fn to_limbs(&self) -> [u64; 4]

Are these changes tested?

Not yet, thats why its in draft

maujim avatar Nov 04 '24 14:11 maujim

Ok so I have it mostly working except for this one compilation issue. At the latest commit, I'm getting multiple errors of the following format in owned_column_operation.rs:

error[E0277]: the trait bound `num_bigint::BigInt: base::scalar::scalar::Scalar` is not satisfied
   --> crates/proof-of-sql/src/base/database/owned_column_operation.rs:595:21
    |
593 |                 Ok(Self::Boolean(ge_decimal_columns(
    |                                  ------------------ required by a bound introduced by this call
594 |                     lhs_values,
595 |                     rhs_values,
    |                     ^^^^^^^^^^ the trait `base::scalar::scalar::Scalar` is not implemented for `num_bigint::BigInt`
    |
    = help: the following other types implement trait `base::scalar::scalar::Scalar`:
              MontScalar<ark_bls12_381::FrConfig>
              MontScalar<ark_curve25519::FrConfig>
note: required by a bound in `ge_decimal_columns`
   --> crates/proof-of-sql/src/base/database/column_operation.rs:686:8
    |
679 | pub(super) fn ge_decimal_columns<S, T>(
    |               ------------------ required by a bound in this function
...
686 |     S: Scalar,
    |        ^^^^^^ required by this bound in `ge_decimal_columns`

I'm not sure how to proceed from here. We could try adding a impl Scalar for BigInt block. I gave it a quick spin and the only thing I could not figure out was how to implement Scalar.MAX_SIGNED using BigInt. @JayWhite2357 please let me know if you any suggestions here.

maujim avatar Nov 04 '24 18:11 maujim