From 2ca3bd7d97ac2674a09fed63ace16b4f181531b1 Mon Sep 17 00:00:00 2001 From: Chris Sosnin <48099298+slumber@users.noreply.github.com> Date: Thu, 31 Aug 2023 16:10:39 +0300 Subject: [PATCH] convert nonnative constant to little endian (#127) --- CHANGELOG.md | 1 + src/fields/nonnative/field_var.rs | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c0a1fa0..b9d5cf6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ ## Pending - [\#117](https://github.com/arkworks-rs/r1cs-std/pull/117) Fix result of `precomputed_base_scalar_mul_le` to not discard previous value. - [\#124](https://github.com/arkworks-rs/r1cs-std/pull/124) Fix `scalar_mul_le` constraints unsatisfiability when short Weierstrass point is zero. +- [\#127](https://github.com/arkworks-rs/r1cs-std/pull/127) Convert `NonNativeFieldVar` constants to little-endian bytes instead of big-endian (`ToBytesGadget`). ### Breaking changes diff --git a/src/fields/nonnative/field_var.rs b/src/fields/nonnative/field_var.rs index fb2e492..2879e63 100644 --- a/src/fields/nonnative/field_var.rs +++ b/src/fields/nonnative/field_var.rs @@ -313,7 +313,7 @@ impl ToBytesGadget fn to_bytes(&self) -> R1CSResult>> { match self { Self::Constant(c) => Ok(UInt8::constant_vec( - c.into_bigint().to_bytes_be().as_slice(), + c.into_bigint().to_bytes_le().as_slice(), )), Self::Var(v) => v.to_bytes(), @@ -324,7 +324,7 @@ impl ToBytesGadget fn to_non_unique_bytes(&self) -> R1CSResult>> { match self { Self::Constant(c) => Ok(UInt8::constant_vec( - c.into_bigint().to_bytes_be().as_slice(), + c.into_bigint().to_bytes_le().as_slice(), )), Self::Var(v) => v.to_non_unique_bytes(), }