1

I'm aware how one can sign a message with a single key using web3.eth.sign or helpeth. How can multiple keys sign the same message? (preferably with an example using web3)

1

There's no special trick to it. Multiple signatures are just that, multiple signatures, not one special mega-signature. You just iterate through the accounts that you want to sign with, and collect an array of signatures, which you then all provide to whatever needs them.

Example (untested):

var signatures = [];
for(var i=0; i<signingAccounts.length; i++) {
  signatures[i] = web3.eth.sign(signingAccounts[i], data);
}
  • are you sure? cause I've seen contracts which use the result of sign = ecrecover(h,v,r,s) and compare it against multiple address if (sign==A && sign==B) – d9ngle Aug 16 '17 at 17:14
  • I'll be darned, then. I've never heard or seen of these--do you have a link? (that said, an array of signatures is probably easier to work with.) – Matthew Schmidt Aug 17 '17 at 12:23
  • @d9ngle do you remember which contract does that? Would be interesting to read. Although I wonder if the comparison (logically can't be literally "sign == A && sign == B") is another form of comparing elements in the array, which would essentially be Matthew's implementation. – Linmao Song Feb 17 '18 at 16:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.