mirror of
https://github.com/arnaucube/ark-r1cs-std.git
synced 2026-01-23 12:13:48 +01:00
Fix integer conversions and log2
This commit is contained in:
@@ -591,7 +591,7 @@ impl<F: Field> ToBytesGadget<F> for Boolean<F> {
|
||||
fn to_bytes(&self) -> Result<Vec<UInt8<F>>, SynthesisError> {
|
||||
let mut bits = vec![self.clone()];
|
||||
bits.extend(vec![Boolean::constant(false); 7]);
|
||||
let value = self.value().map(|val| val as u8).ok();
|
||||
let value = self.value().map(u8::from).ok();
|
||||
let byte = UInt8 { bits, value };
|
||||
Ok(vec![byte])
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ macro_rules! make_uint {
|
||||
pub mod $mod_name {
|
||||
use algebra::{Field, FpParameters, PrimeField};
|
||||
use core::borrow::Borrow;
|
||||
use core::convert::TryFrom;
|
||||
|
||||
use r1cs_core::{
|
||||
lc, ConstraintSystemRef, LinearCombination, Namespace, SynthesisError, Variable,
|
||||
@@ -119,7 +120,9 @@ macro_rules! make_uint {
|
||||
|
||||
$name {
|
||||
bits: new_bits,
|
||||
value: self.value.map(|v| v.rotate_right(by as u32)),
|
||||
value: self
|
||||
.value
|
||||
.map(|v| v.rotate_right(u32::try_from(by).unwrap())),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user