Merge pull request #413 from zcash/sha256-assignedcell-fix

sha256: Fix `AssignedCell` `From` impls for `AssignedBits` and `Bits`
This commit is contained in:
str4d 2021-12-03 04:24:50 +00:00 committed by GitHub
commit 0295dc724b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 10 deletions

View File

@ -75,21 +75,21 @@ impl<const LEN: usize> From<[bool; LEN]> for Bits<LEN> {
}
}
impl<const LEN: usize> From<Bits<LEN>> for [bool; LEN] {
fn from(bits: Bits<LEN>) -> Self {
impl<const LEN: usize> From<&Bits<LEN>> for [bool; LEN] {
fn from(bits: &Bits<LEN>) -> Self {
bits.0
}
}
impl<const LEN: usize> From<Bits<LEN>> for Assigned<pallas::Base> {
fn from(bits: Bits<LEN>) -> Assigned<pallas::Base> {
impl<const LEN: usize> From<&Bits<LEN>> for Assigned<pallas::Base> {
fn from(bits: &Bits<LEN>) -> Assigned<pallas::Base> {
assert!(LEN <= 64);
pallas::Base::from_u64(lebs2ip(&bits.0)).into()
}
}
impl From<Bits<16>> for u16 {
fn from(bits: Bits<16>) -> u16 {
impl From<&Bits<16>> for u16 {
fn from(bits: &Bits<16>) -> u16 {
lebs2ip(&bits.0) as u16
}
}
@ -100,8 +100,8 @@ impl From<u16> for Bits<16> {
}
}
impl From<Bits<32>> for u32 {
fn from(bits: Bits<32>) -> u32 {
impl From<&Bits<32>> for u32 {
fn from(bits: &Bits<32>) -> u32 {
lebs2ip(&bits.0) as u32
}
}

View File

@ -294,7 +294,7 @@ impl MessageScheduleConfig {
fn decompose_word(
&self,
region: &mut Region<'_, pallas::Base>,
word: Option<Bits<32>>,
word: Option<&Bits<32>>,
index: usize,
) -> Result<Subregion2Word, Error> {
let row = get_word_row(index);

View File

@ -200,7 +200,7 @@ impl MessageScheduleConfig {
fn decompose_subregion3_word(
&self,
region: &mut Region<'_, pallas::Base>,
word: Option<Bits<32>>,
word: Option<&Bits<32>>,
index: usize,
) -> Result<Subregion3Word, Error> {
let row = get_word_row(index);