471 using FqNative = Curve::fq;
472 using FrNative = Curve::fr;
473 using G1Native = Curve::g1;
475 using Builder = Curve::Builder;
476 using FrStdlib = Curve::bigfr_ct;
477 using FqStdlib = Curve::fq_ct;
478 using G1Stdlib = Curve::g1_bigfr_ct;
482 const std::array<uint8_t, 32> pub_x_bytes = { 0x2f, 0x8b, 0xde, 0x4d, 0x1a, 0x07, 0x20, 0x93, 0x55, 0xb4, 0xa7,
483 0x25, 0x0a, 0x5c, 0x51, 0x28, 0xe8, 0x8b, 0x84, 0xbd, 0xdc, 0x61,
484 0x9a, 0xb7, 0xcb, 0xa8, 0xd5, 0x69, 0xb2, 0x40, 0xef, 0xe4 };
485 const std::array<uint8_t, 32> pub_y_bytes = { 0xd8, 0xac, 0x22, 0x26, 0x36, 0xe5, 0xe3, 0xd6, 0xd4, 0xdb, 0xa9,
486 0xdd, 0xa6, 0xc9, 0xc4, 0x26, 0xf7, 0x88, 0x27, 0x1b, 0xab, 0x0d,
487 0x68, 0x40, 0xdc, 0xa8, 0x7d, 0x3a, 0xa6, 0xac, 0x62, 0xd6 };
488 const std::array<uint8_t, 32> r_bytes = { 0xa8, 0x41, 0x94, 0xc3, 0x71, 0xc6, 0x7b, 0xa2, 0x59, 0x2f, 0x59,
489 0xc6, 0x20, 0xad, 0x30, 0x4c, 0xb7, 0x6d, 0x7a, 0x88, 0x25, 0x6b,
490 0xb5, 0x0d, 0xc4, 0x1c, 0x66, 0x57, 0x44, 0xbf, 0x78, 0x61 };
491 const std::array<uint8_t, 32> s_bytes = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
492 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
493 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x64 };
494 const std::array<uint8_t, 32> z_bytes = { 0xb6, 0xb8, 0x18, 0x2e, 0xc7, 0x1f, 0x95, 0xd4, 0x42, 0x13, 0x3f,
495 0x21, 0x5c, 0x9e, 0x0e, 0x7b, 0x55, 0x98, 0x0e, 0xf2, 0x02, 0x07,
496 0xf7, 0xaa, 0x2a, 0xbb, 0x7a, 0x7e, 0xe9, 0x1b, 0xab, 0x1f };
498 FqNative pub_x = FqNative::serialize_from_buffer(pub_x_bytes.data());
499 FqNative pub_y = FqNative::serialize_from_buffer(pub_y_bytes.data());
500 typename G1Native::affine_element public_key_native(pub_x, pub_y);
501 ASSERT_TRUE(public_key_native.on_curve()) <<
"Public key must be on curve";
504 const std::string message_string(z_bytes.begin(), z_bytes.end());
509 bool native_verification =
510 ecdsa_verify_signature<Sha256Hasher, FqNative, FrNative, G1Native>(message_string, public_key_native, sig);
512 bool stdlib_verification;
516 const G1Stdlib public_key_ct = G1Stdlib::from_witness(&
builder, public_key_native);
518 const std::vector<uint8_t> r_vec(r_bytes.begin(), r_bytes.end());
519 const std::vector<uint8_t> s_vec(s_bytes.begin(), s_bytes.end());
523 const std::vector<uint8_t> z_vec(z_bytes.begin(), z_bytes.end());
527 stdlib::ecdsa_verify_signature<Builder, Curve, FqStdlib, FrStdlib, G1Stdlib>(
528 hashed_message_ct, public_key_ct, sig_ct);
530 stdlib_verification = signature_result.
get_value();
535 ASSERT_FALSE(circuit_valid);
536 EXPECT_EQ(
builder.err(),
"ECDSA validation: the result of the batch multiplication is the point at infinity.");
540 EXPECT_FALSE(native_verification);
541 EXPECT_FALSE(stdlib_verification);
542 EXPECT_EQ(native_verification, stdlib_verification);
549 using FqNative = Curve::fq;
550 using FrNative = Curve::fr;
551 using G1Native = Curve::g1;
553 using Builder = Curve::Builder;
554 using FrStdlib = Curve::bigfr_ct;
555 using FqStdlib = Curve::fq_ct;
556 using G1Stdlib = Curve::g1_bigfr_ct;
558 const std::array<uint8_t, 32> pub_x_bytes = { 0x79, 0x9f, 0x2a, 0xba, 0xfa, 0x27, 0x16, 0x4b, 0x09, 0x50, 0xf2,
559 0xc8, 0x82, 0xf0, 0xd1, 0x67, 0xe1, 0xd2, 0x16, 0x74, 0x87, 0xd5,
560 0x2e, 0xa7, 0x23, 0x0b, 0x5d, 0x96, 0xc2, 0xa8, 0x74, 0x00 };
561 const std::array<uint8_t, 32> pub_y_bytes = { 0xda, 0xa5, 0x79, 0xf4, 0xf1, 0x61, 0xe9, 0xdc, 0xa1, 0xa1, 0x34,
562 0x35, 0x92, 0x16, 0xb9, 0x35, 0xea, 0xd0, 0x97, 0x2d, 0x76, 0x3f,
563 0xe3, 0x33, 0xc7, 0x12, 0xee, 0x8d, 0x18, 0x4b, 0xd8, 0x11 };
564 const std::array<uint8_t, 32> r_bytes = { 0xb1, 0x99, 0xa1, 0x62, 0x72, 0x66, 0x61, 0xba, 0x23, 0x3c, 0xd6,
565 0xc6, 0x6e, 0x99, 0x0b, 0x01, 0x2e, 0x1e, 0x76, 0x04, 0xb1, 0x1f,
566 0x76, 0x19, 0x3b, 0x2a, 0xf5, 0xca, 0x36, 0xc1, 0x01, 0x76 };
567 const std::array<uint8_t, 32> s_bytes = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
568 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
569 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05 };
570 const std::array<uint8_t, 32> z_bytes = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
571 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
572 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05 };
574 const FqNative pub_x = FqNative::serialize_from_buffer(pub_x_bytes.data());
575 const FqNative pub_y = FqNative::serialize_from_buffer(pub_y_bytes.data());
576 const typename G1Native::affine_element public_key_native(pub_x, pub_y);
577 ASSERT_TRUE(public_key_native.on_curve()) <<
"Public key must be on curve";
580 const std::string message_string(z_bytes.begin(), z_bytes.end());
585 bool native_verification =
586 ecdsa_verify_signature<Sha256Hasher, FqNative, FrNative, G1Native>(message_string, public_key_native, sig);
590 const G1Stdlib public_key_ct = G1Stdlib::from_witness(&
builder, public_key_native);
592 const std::vector<uint8_t> r_vec(r_bytes.begin(), r_bytes.end());
593 const std::vector<uint8_t> s_vec(s_bytes.begin(), s_bytes.end());
597 const std::vector<uint8_t> z_vec(z_bytes.begin(), z_bytes.end());
601 stdlib::ecdsa_verify_signature<Builder, Curve, FqStdlib, FrStdlib, G1Stdlib>(
602 hashed_message_ct, public_key_ct, sig_ct);
604 bool stdlib_verification = signature_result.
get_value();
607 ASSERT_TRUE(circuit_valid);
609 EXPECT_EQ(native_verification, stdlib_verification);
616 using FqNative = Curve::fq;
617 using G1Native = Curve::g1;
619 using Builder = Curve::Builder;
620 using FrStdlib = Curve::bigfr_ct;
621 using FqStdlib = Curve::fq_ct;
622 using G1Stdlib = Curve::g1_bigfr_ct;
624 const std::array<uint8_t, 32> pub_x_bytes = { 0xbd, 0xae, 0xdd, 0xff, 0x80, 0x69, 0x8b, 0xd0, 0xb5, 0xdb, 0x79,
625 0x10, 0xe1, 0xc6, 0x56, 0x9d, 0xc3, 0x4e, 0x77, 0x3b, 0xda, 0x69,
626 0x5e, 0x61, 0x5c, 0x87, 0xf5, 0x4e, 0x6a, 0x70, 0x7e, 0xd6 };
627 const std::array<uint8_t, 32> pub_y_bytes = { 0xc1, 0xb3, 0x69, 0x9c, 0x7e, 0xea, 0x97, 0xbe, 0x5e, 0x52, 0x3d,
628 0x47, 0x5c, 0x5f, 0x72, 0x00, 0x97, 0x2c, 0x61, 0x23, 0xf2, 0xcd,
629 0x3d, 0x59, 0x33, 0x54, 0xe7, 0x4d, 0x35, 0xd1, 0x85, 0x11 };
630 const std::array<uint8_t, 32> r_bytes = { 0x4d, 0xc6, 0x6f, 0x06, 0x26, 0x12, 0x5d, 0x49, 0xb5, 0xa7, 0x7d,
631 0x36, 0xc3, 0xf9, 0x7e, 0x9b, 0xb8, 0x29, 0x48, 0xf2, 0xbd, 0xdc,
632 0xf8, 0x43, 0xe5, 0xee, 0x13, 0x3c, 0xc8, 0x96, 0xf1, 0xd8 };
633 const std::array<uint8_t, 32> s_bytes = { 0x52, 0x59, 0x33, 0x34, 0x92, 0xf6, 0x68, 0x42, 0x1a, 0xe0, 0x63,
634 0x3f, 0x2d, 0x16, 0x92, 0x4b, 0x9f, 0x3b, 0xe9, 0x36, 0xee, 0xd3,
635 0xf1, 0x96, 0x28, 0x6e, 0x0a, 0x57, 0x5d, 0xe2, 0x9f, 0xb7 };
636 const std::array<uint8_t, 32> z_bytes = { 0x93, 0xd5, 0x0c, 0x3d, 0xd6, 0xd6, 0xc3, 0xf7, 0xf7, 0x55, 0x0e,
637 0x69, 0x76, 0x40, 0x2b, 0x89, 0xaa, 0xf2, 0xd6, 0x8a, 0x7a, 0x94,
638 0x80, 0x44, 0x69, 0xaa, 0x69, 0x03, 0x15, 0xb8, 0x64, 0x31 };
640 const FqNative pub_x = FqNative::serialize_from_buffer(pub_x_bytes.data());
641 const FqNative pub_y = FqNative::serialize_from_buffer(pub_y_bytes.data());
642 const typename G1Native::affine_element public_key_native(pub_x, pub_y);
643 ASSERT_TRUE(public_key_native.on_curve()) <<
"Public key must be on curve";
646 const G1Stdlib public_key_ct = G1Stdlib::from_witness(&
builder, public_key_native);
648 const std::vector<uint8_t> r_vec(r_bytes.begin(), r_bytes.end());
649 const std::vector<uint8_t> s_vec(s_bytes.begin(), s_bytes.end());
653 const std::vector<uint8_t> z_vec(z_bytes.begin(), z_bytes.end());
657 stdlib::ecdsa_verify_signature<Builder, Curve, FqStdlib, FrStdlib, G1Stdlib>(
658 hashed_message_ct, public_key_ct, sig_ct);
661 EXPECT_TRUE(signature_result.
get_value());
664 ASSERT_TRUE(circuit_valid);