axelarnetwork / tofn

A threshold cryptography library in Rust
Apache License 2.0
112 stars 23 forks source link

Smoother handling of "malicious" feature #87

Closed ggutoski closed 3 years ago

ggutoski commented 3 years ago

Currently, we have to verify that each corrupt_* function has a feature = "malicious" config. One way to simplify this might be to have a macro, say corrupt! or malicious! that expands to something that just returns the input itself if the feature is not enabled, or calls the corrupt_* function if it is. This also allows us to feature gate the whole pub mod malicious block. Possible usages of this macro:

        let y_i_commit = corrupt!(y_i_commit, self.corrupt_commit(index, y_i_commit));
        corrupt!(y_i_commit, commit(index, y_i_commit));  // This expands to a let statement.

_Originally posted by @milapsheth in https://github.com/axelarnetwork/tofn/pull/86#discussion_r668919553_