New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Is there any instructions or examples for verifying the signature (for gg20)? #189
Comments
See #177 and in particular the comments after #177 (comment) |
thanks for the reply! will check that out! |
Unfortunately I didn't really get my question solved in that discussion 😢 But I tried another thing -
Is it a valid test? Or actually I am signing with different public key each time? Here's my implementation in Javascript for reference: https://gist.github.com/hcheng826/2c3a4b98490a81052d8a4a1f8d4aad7f output
|
Yes.
No. As long as you use the same private keys, you sign with the same public key.
How are you recovering the public keys? Check the recovery id, that's a common source of issues. |
@ataki Thanks for the reply! The recovery id I used is the id from the output of the signature. Is that the correct value to use? To my knowledge the recid could be either 0 or 1, I tried with both values but still got different public keys 🤔 |
Try to print the signature as a hex string let r = BigInt::from_bytes(sig.r.to_bytes().as_ref()).to_str_radix(16);
let s = BigInt::from_bytes(sig.s.to_bytes().as_ref()).to_str_radix(16);
let v = sig.recid;
let signature = format!("{:0>width$}{:0>width$}{:02x}", r, s, v, width = 64); For |
Thanks for your reply! But I still cannot work it out 😥 I had another try, though. When I am tracing the code I found this: https://github.com/ZenGo-X/multi-party-ecdsa/blob/master/src/protocols/multi_party_ecdsa/gg_2020/state_machine/keygen/rounds.rs#L324-L329 I guess that points out that This is how I process |
replace
const msg = "hello";
const result = pk.verify(Buffer.from(sha3.keccak256(msg), "hex"), sig);
to
const msg = "68656c6c6f";
const result = pk.verify(Buffer.from(msg, "hex"), sig); you need to get the actual message to be signed. data_to_sign changed let data_to_sign = "hello";
let message = BigInt::from_bytes(data_to_sign.as_bytes());
println!("message: {}", message.to_hex());
=> 68656c6c6f |
@peng-huang-ch Thank you so much! It works!!!! Append the conversion in js for others' reference const msg = "hello";
const msgHex = Buffer.from(msg).toString("hex");
const result = pk.verify(Buffer.from(msgHex, "hex"), sig); |
Thanks for the great repository! I have walked through the example for GG20 keygen and signing. I can successfully generate the signature but I don't actually know how to extract the public key and actually verify the generated signature.
Is there any instructions or examples that I can refer to? Thanks!
The text was updated successfully, but these errors were encountered: