diff --git a/lib/frost.rb b/lib/frost.rb index fea792d..6e79eb1 100644 --- a/lib/frost.rb +++ b/lib/frost.rb @@ -119,6 +119,7 @@ def sign(secret_share, group_pubkey, nonces, msg, commitment_list) def aggregate(commitment_list, msg, group_pubkey, sig_shares) raise ArgumentError, "msg must be String." unless msg.is_a?(String) raise ArgumentError, "group_pubkey must be ECDSA::Point." unless group_pubkey.is_a?(ECDSA::Point) + raise ArgumentError, "The numbers of commitment_list and sig_shares do not match." unless commitment_list.length == sig_shares.length binding_factors = compute_binding_factors(group_pubkey, commitment_list, msg) group_commitment = compute_group_commitment(commitment_list, binding_factors) diff --git a/spec/frost_spec.rb b/spec/frost_spec.rb index 06cbd52..f7567a6 100644 --- a/spec/frost_spec.rb +++ b/spec/frost_spec.rb @@ -3,6 +3,8 @@ RSpec.describe FROST do + let(:group) { ECDSA::Group::Secp256k1 } + shared_examples "Test Vector" do it do # key generation @@ -112,14 +114,12 @@ describe "Test Vector" do context "secp256k1" do - let(:group) { ECDSA::Group::Secp256k1 } let(:vectors) { load_fixture("secp256k1/vectors.json") } it_behaves_like "Test Vector", "secp256k1" it_behaves_like "frost process", "secp256k1" end context "secp256k1 big identifiers" do - let(:group) { ECDSA::Group::Secp256k1 } let(:vectors) { load_fixture("secp256k1/vectors-big-identifier.json") } it_behaves_like "Test Vector", "secp256k1 with big identifier" end @@ -138,4 +138,19 @@ end end + describe "#aggregate" do + context "with long commitment list" do + it do + secret = FROST::SigningKey.generate(group) + group_pubkey = secret.to_point + comm1 = FROST::Commitments.new(1, group_pubkey, group_pubkey) # fake commitments + comm2 = FROST::Commitments.new(2, group_pubkey, group_pubkey) # fake commitments + comm3 = FROST::Commitments.new(3, group_pubkey, group_pubkey) # fake commitments + msg = "" + sig_shares = [1, 2] + expect{ described_class.aggregate([comm1, comm2, comm3], msg, group_pubkey, sig_shares) }. + to raise_error("The numbers of commitment_list and sig_shares do not match.") + end + end + end end