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

Refactor signed object constructors #250

Open
bifurcation opened this issue Mar 23, 2022 · 0 comments
Open

Refactor signed object constructors #250

bifurcation opened this issue Mar 23, 2022 · 0 comments

Comments

@bifurcation
Copy link
Contributor

Signed objects, especially GroupInfo and KeyPackage, are used in basically two ways:

  1. Instantiate => sign => serialize
  2. Deserialize => verify => instantiate

Given that, it seems like we be able should have two constructors for these objects:

  1. A "signing constructor" of the form Thing(fields..., sig_priv)
  2. A "verifying constructor" of the form Thing(const bytes&, verify_data...) (where verify_data would include things like a tree from which the public key would be taken for GroupInfo)

The type might still need to be default-constructible to facilitate deserialization. Or it might be possible to define tls::get<T>(tls::ostream&), and then do:

Thing::Thing(tls::istream& str)
  : field1(tls::get<FieldType1>(str))
  , field2(tls::get<FieldType2>(str))
  , ...
{
  // verify signature
}

That would be a bit more boilerplate than TLS_SERIALIZABLE, but might be worth it for a clearer API.

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

1 participant