502 using FqNative = Curve::BaseFieldNative;
503 using FrNative = Curve::ScalarFieldNative;
504 using G1Native = Curve::GroupNative;
506 using Builder = Curve::Builder;
513 const std::array<uint8_t, 32> pub_x_bytes = { 0x2f, 0x8b, 0xde, 0x4d, 0x1a, 0x07, 0x20, 0x93, 0x55, 0xb4, 0xa7,
514 0x25, 0x0a, 0x5c, 0x51, 0x28, 0xe8, 0x8b, 0x84, 0xbd, 0xdc, 0x61,
515 0x9a, 0xb7, 0xcb, 0xa8, 0xd5, 0x69, 0xb2, 0x40, 0xef, 0xe4 };
516 const std::array<uint8_t, 32> pub_y_bytes = { 0xd8, 0xac, 0x22, 0x26, 0x36, 0xe5, 0xe3, 0xd6, 0xd4, 0xdb, 0xa9,
517 0xdd, 0xa6, 0xc9, 0xc4, 0x26, 0xf7, 0x88, 0x27, 0x1b, 0xab, 0x0d,
518 0x68, 0x40, 0xdc, 0xa8, 0x7d, 0x3a, 0xa6, 0xac, 0x62, 0xd6 };
519 const std::array<uint8_t, 32> r_bytes = { 0xa8, 0x41, 0x94, 0xc3, 0x71, 0xc6, 0x7b, 0xa2, 0x59, 0x2f, 0x59,
520 0xc6, 0x20, 0xad, 0x30, 0x4c, 0xb7, 0x6d, 0x7a, 0x88, 0x25, 0x6b,
521 0xb5, 0x0d, 0xc4, 0x1c, 0x66, 0x57, 0x44, 0xbf, 0x78, 0x61 };
522 const std::array<uint8_t, 32> s_bytes = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
523 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
524 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x64 };
525 const std::array<uint8_t, 32> z_bytes = { 0xb6, 0xb8, 0x18, 0x2e, 0xc7, 0x1f, 0x95, 0xd4, 0x42, 0x13, 0x3f,
526 0x21, 0x5c, 0x9e, 0x0e, 0x7b, 0x55, 0x98, 0x0e, 0xf2, 0x02, 0x07,
527 0xf7, 0xaa, 0x2a, 0xbb, 0x7a, 0x7e, 0xe9, 0x1b, 0xab, 0x1f };
529 FqNative pub_x = FqNative::serialize_from_buffer(pub_x_bytes.data());
530 FqNative pub_y = FqNative::serialize_from_buffer(pub_y_bytes.data());
531 typename G1Native::affine_element public_key_native(pub_x, pub_y);
532 ASSERT_TRUE(public_key_native.on_curve()) <<
"Public key must be on curve";
535 const std::string message_string(z_bytes.begin(), z_bytes.end());
540 bool native_verification =
541 ecdsa_verify_signature<Sha256Hasher, FqNative, FrNative, G1Native>(message_string, public_key_native, sig);
543 bool stdlib_verification;
547 const G1Stdlib public_key_ct = G1Stdlib::from_witness(&
builder, public_key_native);
549 const std::vector<uint8_t> r_vec(r_bytes.begin(), r_bytes.end());
550 const std::vector<uint8_t> s_vec(s_bytes.begin(), s_bytes.end());
554 const std::vector<uint8_t> z_vec(z_bytes.begin(), z_bytes.end());
558 stdlib::ecdsa_verify_signature<Builder, Curve, FqStdlib, FrStdlib, G1Stdlib>(
559 hashed_message_ct, public_key_ct, sig_ct);
561 stdlib_verification = signature_result.
get_value();
566 ASSERT_TRUE(circuit_valid);
570 EXPECT_FALSE(native_verification);
571 EXPECT_FALSE(stdlib_verification);
572 EXPECT_EQ(native_verification, stdlib_verification);
579 using FqNative = Curve::BaseFieldNative;
580 using FrNative = Curve::ScalarFieldNative;
581 using G1Native = Curve::GroupNative;
583 using Builder = Curve::Builder;
588 const std::array<uint8_t, 32> pub_x_bytes = { 0x79, 0x9f, 0x2a, 0xba, 0xfa, 0x27, 0x16, 0x4b, 0x09, 0x50, 0xf2,
589 0xc8, 0x82, 0xf0, 0xd1, 0x67, 0xe1, 0xd2, 0x16, 0x74, 0x87, 0xd5,
590 0x2e, 0xa7, 0x23, 0x0b, 0x5d, 0x96, 0xc2, 0xa8, 0x74, 0x00 };
591 const std::array<uint8_t, 32> pub_y_bytes = { 0xda, 0xa5, 0x79, 0xf4, 0xf1, 0x61, 0xe9, 0xdc, 0xa1, 0xa1, 0x34,
592 0x35, 0x92, 0x16, 0xb9, 0x35, 0xea, 0xd0, 0x97, 0x2d, 0x76, 0x3f,
593 0xe3, 0x33, 0xc7, 0x12, 0xee, 0x8d, 0x18, 0x4b, 0xd8, 0x11 };
594 const std::array<uint8_t, 32> r_bytes = { 0xb1, 0x99, 0xa1, 0x62, 0x72, 0x66, 0x61, 0xba, 0x23, 0x3c, 0xd6,
595 0xc6, 0x6e, 0x99, 0x0b, 0x01, 0x2e, 0x1e, 0x76, 0x04, 0xb1, 0x1f,
596 0x76, 0x19, 0x3b, 0x2a, 0xf5, 0xca, 0x36, 0xc1, 0x01, 0x76 };
597 const std::array<uint8_t, 32> s_bytes = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
598 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
599 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05 };
600 const std::array<uint8_t, 32> z_bytes = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
601 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
602 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05 };
604 const FqNative pub_x = FqNative::serialize_from_buffer(pub_x_bytes.data());
605 const FqNative pub_y = FqNative::serialize_from_buffer(pub_y_bytes.data());
606 const typename G1Native::affine_element public_key_native(pub_x, pub_y);
607 ASSERT_TRUE(public_key_native.on_curve()) <<
"Public key must be on curve";
610 const std::string message_string(z_bytes.begin(), z_bytes.end());
615 bool native_verification =
616 ecdsa_verify_signature<Sha256Hasher, FqNative, FrNative, G1Native>(message_string, public_key_native, sig);
620 const G1Stdlib public_key_ct = G1Stdlib::from_witness(&
builder, public_key_native);
622 const std::vector<uint8_t> r_vec(r_bytes.begin(), r_bytes.end());
623 const std::vector<uint8_t> s_vec(s_bytes.begin(), s_bytes.end());
627 const std::vector<uint8_t> z_vec(z_bytes.begin(), z_bytes.end());
631 stdlib::ecdsa_verify_signature<Builder, Curve, FqStdlib, FrStdlib, G1Stdlib>(
632 hashed_message_ct, public_key_ct, sig_ct);
634 bool stdlib_verification = signature_result.
get_value();
637 ASSERT_TRUE(circuit_valid);
639 EXPECT_EQ(native_verification, stdlib_verification);
646 using FqNative = Curve::BaseFieldNative;
647 using G1Native = Curve::GroupNative;
649 using Builder = Curve::Builder;
654 const std::array<uint8_t, 32> pub_x_bytes = { 0xbd, 0xae, 0xdd, 0xff, 0x80, 0x69, 0x8b, 0xd0, 0xb5, 0xdb, 0x79,
655 0x10, 0xe1, 0xc6, 0x56, 0x9d, 0xc3, 0x4e, 0x77, 0x3b, 0xda, 0x69,
656 0x5e, 0x61, 0x5c, 0x87, 0xf5, 0x4e, 0x6a, 0x70, 0x7e, 0xd6 };
657 const std::array<uint8_t, 32> pub_y_bytes = { 0xc1, 0xb3, 0x69, 0x9c, 0x7e, 0xea, 0x97, 0xbe, 0x5e, 0x52, 0x3d,
658 0x47, 0x5c, 0x5f, 0x72, 0x00, 0x97, 0x2c, 0x61, 0x23, 0xf2, 0xcd,
659 0x3d, 0x59, 0x33, 0x54, 0xe7, 0x4d, 0x35, 0xd1, 0x85, 0x11 };
660 const std::array<uint8_t, 32> r_bytes = { 0x4d, 0xc6, 0x6f, 0x06, 0x26, 0x12, 0x5d, 0x49, 0xb5, 0xa7, 0x7d,
661 0x36, 0xc3, 0xf9, 0x7e, 0x9b, 0xb8, 0x29, 0x48, 0xf2, 0xbd, 0xdc,
662 0xf8, 0x43, 0xe5, 0xee, 0x13, 0x3c, 0xc8, 0x96, 0xf1, 0xd8 };
663 const std::array<uint8_t, 32> s_bytes = { 0x52, 0x59, 0x33, 0x34, 0x92, 0xf6, 0x68, 0x42, 0x1a, 0xe0, 0x63,
664 0x3f, 0x2d, 0x16, 0x92, 0x4b, 0x9f, 0x3b, 0xe9, 0x36, 0xee, 0xd3,
665 0xf1, 0x96, 0x28, 0x6e, 0x0a, 0x57, 0x5d, 0xe2, 0x9f, 0xb7 };
666 const std::array<uint8_t, 32> z_bytes = { 0x93, 0xd5, 0x0c, 0x3d, 0xd6, 0xd6, 0xc3, 0xf7, 0xf7, 0x55, 0x0e,
667 0x69, 0x76, 0x40, 0x2b, 0x89, 0xaa, 0xf2, 0xd6, 0x8a, 0x7a, 0x94,
668 0x80, 0x44, 0x69, 0xaa, 0x69, 0x03, 0x15, 0xb8, 0x64, 0x31 };
670 const FqNative pub_x = FqNative::serialize_from_buffer(pub_x_bytes.data());
671 const FqNative pub_y = FqNative::serialize_from_buffer(pub_y_bytes.data());
672 const typename G1Native::affine_element public_key_native(pub_x, pub_y);
673 ASSERT_TRUE(public_key_native.on_curve()) <<
"Public key must be on curve";
676 const G1Stdlib public_key_ct = G1Stdlib::from_witness(&
builder, public_key_native);
678 const std::vector<uint8_t> r_vec(r_bytes.begin(), r_bytes.end());
679 const std::vector<uint8_t> s_vec(s_bytes.begin(), s_bytes.end());
683 const std::vector<uint8_t> z_vec(z_bytes.begin(), z_bytes.end());
687 stdlib::ecdsa_verify_signature<Builder, Curve, FqStdlib, FrStdlib, G1Stdlib>(
688 hashed_message_ct, public_key_ct, sig_ct);
691 EXPECT_TRUE(signature_result.
get_value());
694 ASSERT_TRUE(circuit_valid);