mirror of
https://github.com/arnaucube/ark-r1cs-std.git
synced 2026-01-09 23:41:33 +01:00
add to_bits_be
This commit is contained in:
committed by
Pratyush Mishra
parent
2a8ee871d8
commit
d087166c51
@@ -25,13 +25,27 @@ pub trait ToBitsGadget<F: Field> {
|
|||||||
/// This is the correct default for 99% of use cases.
|
/// This is the correct default for 99% of use cases.
|
||||||
fn to_bits_le(&self) -> Result<Vec<Boolean<F>>, SynthesisError>;
|
fn to_bits_le(&self) -> Result<Vec<Boolean<F>>, SynthesisError>;
|
||||||
|
|
||||||
/// Outputs a possibly non-unique bit-wise representation of `self`.
|
/// Outputs a possibly non-unique little-endian bit-wise representation of `self`.
|
||||||
///
|
///
|
||||||
/// If you're not absolutely certain that your usecase can get away with a
|
/// If you're not absolutely certain that your usecase can get away with a
|
||||||
/// non-canonical representation, please use `self.to_bits()` instead.
|
/// non-canonical representation, please use `self.to_bits()` instead.
|
||||||
fn to_non_unique_bits_le(&self) -> Result<Vec<Boolean<F>>, SynthesisError> {
|
fn to_non_unique_bits_le(&self) -> Result<Vec<Boolean<F>>, SynthesisError> {
|
||||||
self.to_bits_le()
|
self.to_bits_le()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Outputs the canonical big-endian bit-wise representation of `self`.
|
||||||
|
fn to_bits_be(&self) -> Result<Vec<Boolean<F>>, SynthesisError> {
|
||||||
|
let mut res = self.to_bits_le()?;
|
||||||
|
res.reverse();
|
||||||
|
Ok(res)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Outputs a possibly non-unique big-endian bit-wise representation of `self`.
|
||||||
|
fn to_non_unique_bits_be(&self) -> Result<Vec<Boolean<F>>, SynthesisError> {
|
||||||
|
let mut res = self.to_non_unique_bits_le()?;
|
||||||
|
res.reverse();
|
||||||
|
Ok(res)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<F: Field> ToBitsGadget<F> for Boolean<F> {
|
impl<F: Field> ToBitsGadget<F> for Boolean<F> {
|
||||||
|
|||||||
Reference in New Issue
Block a user