MCPcopy Create free account
hub / github.com/BitVM/BitVM / verify_test_vector

Function verify_test_vector

bitvm/src/signatures/public.rs:794–861  ·  view source on GitHub ↗

Run the test vector and verify the expected outputs.

(test_vector: TestVector)

Source from the content-addressed store, hash-verified

792
793 /// Run the test vector and verify the expected outputs.
794 fn verify_test_vector<WOTS: Wots + CompactWots>(test_vector: TestVector) {
795 let message =
796 WOTS::Message::try_from(test_vector.message.clone()).expect("Invalid message bytes");
797 let computed_public_key = WOTS::generate_public_key(&test_vector.secret_key);
798 assert_eq!(
799 &test_vector.public_key,
800 computed_public_key.as_ref(),
801 "public key mismatch"
802 );
803 let computed_signature = WOTS::sign(&test_vector.secret_key, &message);
804 assert_eq!(
805 &test_vector.signature,
806 computed_signature.as_ref(),
807 "signature mismatch"
808 );
809 let computed_witness = WOTS::sign_to_raw_witness(&test_vector.secret_key, &message);
810 assert_eq!(
811 &test_vector.witness,
812 &computed_witness.to_vec(),
813 "witness mismatch"
814 );
815 assert_eq!(
816 WOTS::raw_witness_to_signature(&computed_witness).as_ref(),
817 computed_signature.as_ref(),
818 "bad conversion witness -> signature"
819 );
820 assert_eq!(
821 &WOTS::signature_to_raw_witness(&computed_signature),
822 &computed_witness,
823 "bad conversion signature -> witness"
824 );
825 let script = script! {
826 { computed_witness }
827 { WOTS::checksig_verify_and_clear_stack(&computed_public_key) }
828 OP_TRUE
829 };
830 assert!(execute_script(script).success);
831
832 let computed_compact_signature = WOTS::compact_sign(&test_vector.secret_key, &message);
833 assert_eq!(
834 &test_vector.compact_signature,
835 computed_compact_signature.as_ref(),
836 "compact signature mismatch"
837 );
838 let computed_compact_witness =
839 WOTS::compact_sign_to_raw_witness(&test_vector.secret_key, &message);
840 assert_eq!(
841 &test_vector.compact_witness,
842 &computed_compact_witness.to_vec(),
843 "compact witness mismatch"
844 );
845 assert_eq!(
846 WOTS::compact_raw_witness_to_signature(&computed_compact_witness).as_ref(),
847 computed_compact_signature.as_ref(),
848 "bad conversion compact witness -> compact signature"
849 );
850 assert_eq!(
851 &WOTS::compact_signature_to_raw_witness(&computed_compact_signature),

Callers

nothing calls this directly

Calls 2

generate_public_keyFunction · 0.85
cloneMethod · 0.80

Tested by

no test coverage detected