2#include <gtest/gtest.h>
10template <
typename Hash>
struct MultisigTest :
public ::testing::Test {
17 static KeyPair generate_account()
21 account.public_key =
G::one * account.private_key;
29 for (
size_t i = 0; i < accounts.size(); ++i) {
30 auto& signer = accounts[i];
33 return signer_pubkeys;
38 const bool tamper_proof_of_possession =
false)
45 if (tamper_proof_of_possession) {
46 signer_pubkeys[0].proof_of_possession.response += 1;
48 const size_t num_signers = accounts.size();
50 for (
size_t i = 0; i < num_signers; ++i) {
52 round1_pub.push_back(_round1_pub);
53 round1_priv.push_back(_round1_priv);
56 for (
size_t i = 0; i < num_signers; ++i) {
57 auto& signer = accounts[i];
59 message, signer, round1_priv[i], signer_pubkeys, round1_pub)) {
60 round2.push_back(*round2_output);
67using HashTypes = ::testing::Types<KeccakHasher, Sha256Hasher>;
80 std::string message =
"The quick brown dog jumped over the lazy fox.";
82 const size_t num_signers = 5;
85 for (
auto& acct : accounts) {
86 acct = this->generate_account();
89 auto signature = this->create_multisig(message, accounts);
90 ASSERT_TRUE(signature.has_value());
93 ASSERT_TRUE(pub_key.has_value());
95 bool result = crypto::schnorr_verify_signature<Blake2sHasher, Fq, Fr, G>(message, *pub_key, *signature);
97 EXPECT_EQ(result,
true);
100TYPED_TEST(MultisigTest, multi_signature_fails_if_proof_of_possession_invalid)
106 std::string message =
"The quick brown dog jumped over the lazy fox.";
108 const size_t num_signers = 5;
111 for (
auto& acct : accounts) {
112 acct = this->generate_account();
115 auto signature = this->create_multisig(message, accounts,
true);
116 ASSERT_FALSE(signature.has_value());
125 std::string message =
"The quick brown dog jumped over the lazy fox.";
127 const size_t num_signers = 5;
130 for (
auto& acct : accounts) {
131 acct = this->generate_account();
134 accounts[2] = accounts[4];
135 auto signature = this->create_multisig(message, accounts);
136 ASSERT_FALSE(signature.has_value());
Implements the SpeedyMuSig protocol; a secure 2-round interactive multisignature scheme whose signatu...
static std::optional< schnorr_signature > combine_signatures(const std::string &message, const std::vector< MultiSigPublicKey > &signer_pubkeys, const std::vector< RoundOnePublicOutput > &round_1_nonces, const std::vector< RoundTwoPublicOutput > &round_2_signature_shares)
the final step in the SpeedyMuSig multisig scheme. Can be computed by an untrusted 3rd party....
static std::pair< RoundOnePublicOutput, RoundOnePrivateOutput > construct_signature_round_1()
First round of SpeedyMuSig. Signers generate random nonce keypairs R = {r, [R]}, S = {s,...
static std::optional< RoundTwoPublicOutput > construct_signature_round_2(const std::string &message, const key_pair &signer, const RoundOnePrivateOutput &signer_round_1_private_output, const std::vector< MultiSigPublicKey > &signer_pubkeys, const std::vector< RoundOnePublicOutput > &round_1_nonces)
Second round of SpeedyMuSig. Given the signer pubkeys and the output of round 1, round 2 has each sig...
static std::optional< affine_element > validate_and_combine_signer_pubkeys(const std::vector< MultiSigPublicKey > &signer_pubkeys)
Computes the sum of all signer pubkeys. Output is the public key of the public-facing schnorr multisi...
static constexpr element one
#define G(r, i, a, b, c, d)
typename multisig::MultiSigPublicKey multisig_public_key
bb::group< bb::fr, bb::fq, G1Params > g1
Entry point for Barretenberg command-line interface.
TYPED_TEST_SUITE(ShpleminiTest, TestSettings)
TYPED_TEST(ShpleminiTest, CorrectnessOfMultivariateClaimBatching)
std::pair< uint32_t, size_t > KeyPair
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
::testing::Types< KeccakHasher, Sha256Hasher, Blake2sHasher > HashTypes
MultiSigPublicKey wraps a signer's public key g1::affine_element along with a proof of posession: a s...
static field random_element(numeric::RNG *engine=nullptr) noexcept