Skip to content

Commit 2ca3bd7

Browse files
authored
convert nonnative constant to little endian (#127)
1 parent 7693d58 commit 2ca3bd7

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
## Pending
44
- [\#117](https://github.com/arkworks-rs/r1cs-std/pull/117) Fix result of `precomputed_base_scalar_mul_le` to not discard previous value.
55
- [\#124](https://github.com/arkworks-rs/r1cs-std/pull/124) Fix `scalar_mul_le` constraints unsatisfiability when short Weierstrass point is zero.
6+
- [\#127](https://github.com/arkworks-rs/r1cs-std/pull/127) Convert `NonNativeFieldVar` constants to little-endian bytes instead of big-endian (`ToBytesGadget`).
67

78
### Breaking changes
89

src/fields/nonnative/field_var.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ impl<TargetField: PrimeField, BaseField: PrimeField> ToBytesGadget<BaseField>
313313
fn to_bytes(&self) -> R1CSResult<Vec<UInt8<BaseField>>> {
314314
match self {
315315
Self::Constant(c) => Ok(UInt8::constant_vec(
316-
c.into_bigint().to_bytes_be().as_slice(),
316+
c.into_bigint().to_bytes_le().as_slice(),
317317
)),
318318

319319
Self::Var(v) => v.to_bytes(),
@@ -324,7 +324,7 @@ impl<TargetField: PrimeField, BaseField: PrimeField> ToBytesGadget<BaseField>
324324
fn to_non_unique_bytes(&self) -> R1CSResult<Vec<UInt8<BaseField>>> {
325325
match self {
326326
Self::Constant(c) => Ok(UInt8::constant_vec(
327-
c.into_bigint().to_bytes_be().as_slice(),
327+
c.into_bigint().to_bytes_le().as_slice(),
328328
)),
329329
Self::Var(v) => v.to_non_unique_bytes(),
330330
}

0 commit comments

Comments
 (0)