zcash_note_encryption: s/TryFrom/From on ExtractedCommitmentBytes bound
This was left over from an earlier refactor where we could call a domain
API to extract cmstar from a note commitment (which could fail for
Orchard). This part of extraction was subsequently refactored into the
domain logic (and is rejected earlier for Orchard). The resulting bound
is wrong because it's always possible to serialize a scalar.
Extracted from: ee2b96c82d
This commit is contained in:
parent
22d0991a46
commit
d94482d5ac
|
@ -5,7 +5,6 @@
|
|||
|
||||
use crypto_api_chachapoly::{ChaCha20Ietf, ChachaPolyIetf};
|
||||
use rand_core::RngCore;
|
||||
use std::convert::TryFrom;
|
||||
use subtle::{Choice, ConstantTimeEq};
|
||||
|
||||
pub const COMPACT_NOTE_SIZE: usize = 1 + // version
|
||||
|
@ -75,7 +74,7 @@ pub trait Domain {
|
|||
type OutgoingViewingKey;
|
||||
type ValueCommitment;
|
||||
type ExtractedCommitment;
|
||||
type ExtractedCommitmentBytes: Eq + TryFrom<Self::ExtractedCommitment>;
|
||||
type ExtractedCommitmentBytes: Eq + for<'a> From<&'a Self::ExtractedCommitment>;
|
||||
type Memo;
|
||||
|
||||
fn derive_esk(note: &Self::Note) -> Option<Self::EphemeralSecretKey>;
|
||||
|
@ -384,9 +383,7 @@ fn check_note_validity<D: Domain>(
|
|||
epk: &D::EphemeralPublicKey,
|
||||
cmstar_bytes: &D::ExtractedCommitmentBytes,
|
||||
) -> NoteValidity {
|
||||
if D::ExtractedCommitmentBytes::try_from(D::cmstar(¬e))
|
||||
.map_or(false, |cs| &cs == cmstar_bytes)
|
||||
{
|
||||
if &D::ExtractedCommitmentBytes::from(&D::cmstar(¬e)) == cmstar_bytes {
|
||||
let epk_bytes = D::epk_bytes(epk);
|
||||
D::check_epk_bytes(¬e, |derived_esk| {
|
||||
if D::epk_bytes(&D::ka_derive_public(¬e, &derived_esk))
|
||||
|
|
Loading…
Reference in New Issue