/// Helper function to evaluate a Pk Node which takes the
/// top of the stack as input signature and validates it.
/// Sat: If the signature witness is correct, 1 is pushed
/// Unsat: For empty witness a 0 is pushed
/// Err: All of other witness result in errors.
/// `pk` CHECKSIG
Helper function to evaluate a Pk Node which takes the
top of the stack as input signature and validates it.
Sat: If the signature witness is correct, 1 is pushed
Unsat: For empty witness a 0 is pushed
Err: All of other witness result in errors.
`pk` CHECKSIG
Helper function to evaluate a Pk Node which takes the top of the stack as input signature and validates it . Sat : If the signature witness is correct 1 is pushed Unsat : For empty witness a 0 is pushed Err : All of other witness result in errors . ` pk ` CHECKSIG
pub fn evaluate_pk<'intp, F>(
        &mut self,
        verify_sig: F,
        pk: &'intp bitcoin::PublicKey,
    ) -> Option<Result<SatisfiedConstraint<'intp, 'txin>, Error>>
    where
        F: FnMut(&bitcoin::PublicKey, ElementsSig) -> bool,
    {
        if let Some(sigser) = self.pop() {
            match sigser {
                Element::Dissatisfied => {
                    self.push(Element::Dissatisfied);
                    None
                }
                Element::Push(ref sigser) => {
                    let sig = verify_sersig(verify_sig, pk, sigser);
                    match sig {
                        Ok(sig) => {
                            self.push(Element::Satisfied);
                            Some(Ok(SatisfiedConstraint::PublicKey { key: pk, sig }))
                        }
                        Err(e) => return Some(Err(e)),
                    }
                }
                Element::Satisfied => {
                    return Some(Err(Error::PkEvaluationError(pk.clone().to_public_key())))
                }
            }
        } else {
            Some(Err(Error::UnexpectedStackEnd))
        }
    }
pub fn evaluate_pk < ' intp , F > ( & mut self , verify_sig : F , pk : & ' intp bitcoin :: PublicKey , ) -> Option < Result < SatisfiedConstraint < ' intp , ' txin > , Error > > where F : FnMut ( & bitcoin :: PublicKey , ElementsSig ) -> bool , { if let Some ( sigser ) = self . pop ( ) { match sigser { Element :: Dissatisfied => { self . push ( Element :: Dissatisfied ) ; None } Element :: Push ( ref sigser ) => { let sig = verify_sersig ( verify_sig , pk , sigser ) ; match sig { Ok ( sig ) => { self . push ( Element :: Satisfied ) ; Some ( Ok ( SatisfiedConstraint :: PublicKey { key : pk , sig } ) ) } Err ( e ) => return Some ( Err ( e ) ) , } } Element :: Satisfied => { return Some ( Err ( Error :: PkEvaluationError ( pk . clone ( ) . to_public_key ( ) ) ) ) } } } else { Some ( Err ( Error :: UnexpectedStackEnd ) ) } }
Helper function to evaluate a Pk Node which takes the
top of the stack as input signature and validates it.
Helper function to evaluate a Pk Node which takes the top of the stack as input signature and validates it .
&mut self
verify_sig
F
pk
&'intp bitcoin::PublicKey