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

[consensus/threshold-simplex] Store Deserialized Partial Signature to Avoid Duplicate Deserialization #457

Open
patrick-ogrady opened this issue Feb 6, 2025 · 1 comment
Labels
enhancement New feature or request

Comments

@patrick-ogrady
Copy link
Contributor

In the current consensus code, we drop deserialized partial signatures and re-deserialize them when generating a notarization, nullification, or finalization:

  • // Verify signature
    let Some(signature) = Eval::deserialize(&nullify.view_signature) else {
    debug!(
    public_key_index,
    "partial signature is not formatted correctly"
    );
    return;
    };
    if signature.index != public_key_index {
    debug!(
    public_key_index,
    partial_signature = signature.index,
    "invalid signature index for nullify"
    );
    return;
    }
    let nullify_message = nullify_message(nullify.view);
    if ops::partial_verify_message(
    identity,
    Some(&self.nullify_namespace),
    &nullify_message,
    &signature,
    )
    .is_err()
    {
    return;
    }
    // Verify seed
    let Some(seed) = Eval::deserialize(&nullify.seed_signature) else {
    return;
    };
    if seed.index != public_key_index {
    return;
    }
    let seed_message = seed_message(nullify.view);
    if ops::partial_verify_message(identity, Some(&self.seed_namespace), &seed_message, &seed)
    .is_err()
    {
    return;
    }
    // Handle nullify
    self.handle_nullify(public_key_index, nullify).await;
  • for notarize in notarizes.values() {
    let eval = Eval::deserialize(&notarize.message.proposal_signature).unwrap();
    notarization.push(eval);
    let eval = Eval::deserialize(&notarize.message.seed_signature).unwrap();
    seed.push(eval);

We should find a way to store arbitrary fixed-size arrays with a parsed protobuf object or find a way to parse the types directly with prost (#454).

We currently have Parsed but that is typically only used with Digests (and support one associated item):

/// Parsed is a wrapper around a message that has a parsable digest.
#[derive(Clone)]
struct Parsed<Message, D: Digest> {
pub message: Message,
pub digest: D,
}

@patrick-ogrady
Copy link
Contributor Author

Related #489

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: Backlog
Development

No branches or pull requests

1 participant