Closed marsella closed 3 years ago
Correct! We use i64
to represent account balances in the contract. @marsella @gijsvl Does the bls12-381 lib still provide a way to convert signed/unsigned integers into scalar fields?
It has a from_raw
method that converts (little-endian) bytes into a Scalar. I'm not sure if that would handle bytes corresponding to a signed integer, though.
The documentation of the scalar type says
// The internal representation of this type is four 64-bit unsigned
// integers in little-endian order. `Scalar` values are always in
// Montgomery form; i.e., Scalar(a) = aR mod q, with R = 2^256.</span>
and that function just drops the bytes directly into the Scalar type, so I'm guessing it does not handle signed values. I think for negative values, we'll have to do the same subtraction step that Gijs implemented in v1.
@indomitableSwan This clarifies things for me. Did you have other questions?
No, the above makes sense to me.
In a Tezos contract, how is a payment amount / account balance represented? (Typewise - is it an
i64
?)The zkAbacus API needs to define a transformation between a currency value (e.g. using the same type as in the contract) and scalar field from the pairing group.