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