Skip to content
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

SecretKeyShare/PublicKeyShare incompatiiblity with gennaro_bls secret key share and public key share #2

Open
tbraun96 opened this issue Jan 30, 2024 · 2 comments

Comments

@tbraun96
Copy link

Notice the test here: https://github.com/webb-tools/gadget/pull/60/files#diff-859b3cbc12cbcc4dd8fd5b3fb2c3f70b07d5d7e136b769be36443976607dcfcaR330-R345

When mapping from a gennaro BLS secret share to a blsful secret share, there is a failure in deserialization because there is no standardized way of doing this between the two crates. Blsful uses serde, whereas gennaro has no export option using the same serde methods for serialization. I imagine the same is true for the public key shares too.

If there can be a from_raw_be and from_from_compressed for secret shares and public shares, respectively, this should solve our issue.

@mikelodder7
Copy link
Contributor

The secret from gennaro is just a scalar element whereas a secret share in blsful requires the identifier also. The easiest way to do this is to prepend the identifier as a byte to the secret share bytes.

let mut secret_share_bytes = Vec::with_capacity(33);
secret_share_bytes.push(1u8); // or whatever the identifier is
secret_share_bytes.extend_from_slice(&secret.to_be_bytes());
let secret_share: SecretShare = secret_share_bytes.try_into()?;

@mikelodder7
Copy link
Contributor

Since secretShare implements the Share trait from Vsss-rs you can use https://docs.rs/vsss-rs/latest/vsss_rs/trait.Share.html#method.with_identifier_and_value also if that's easier or https://docs.rs/vsss-rs/latest/vsss_rs/trait.Share.html#method.from_field_element.

SecretKeyShare(<::SecretKeyShare as Share>::from_field_element(1u8, secret));

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants