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

Change to crypto_primitives host function signature and semantics. #470

Closed
larryk85 opened this issue Jun 20, 2022 · 0 comments
Closed

Change to crypto_primitives host function signature and semantics. #470

larryk85 opened this issue Jun 20, 2022 · 0 comments
Assignees
Labels
3.1 Candidates 3.1 RC2 CONSENSUS Changes the core protocol
Milestone

Comments

@larryk85
Copy link
Contributor

larryk85 commented Jun 20, 2022

For the host functions:

alt_bn128_add, alt_bn128_mul, alt_bn128_pair, mod_exp, blake2_f, and k1_recover the return values have changed.

Before 0 represented success and 1 represented failure. Now, 0 still represents success but -1 represents failure.

This is done to allow for tri-state return values and specifically for alt_bn128_pair.

The new signature for alt_bn128_pair should be int32_t alt_bn128_pair(const char* bytes, uint32_t length); with the return value capturing whether it was a failure or true/false.

On failure it will return -1, 1 on false and 0 if true and successful.

In addition there are a couple of uses of bool in the new function signatures for blake2_f and sha3. These need to be changed to a fixed size type (preferably int32_t).

Note that since this changes the behavior of the CRYPTO_PRIMITIVES protocol feature without introducing a new protocol feature, the CRYPTO_PRIMITIVES protocol feature of 3.1.0-rc1 should not be used. To reduce confusion among peers who may still use 3.1.0-rc1 in a network with later releases, the feature description of the CRYPTO_PRIMITIVES protocol feature should be changed so that it ends up having a new protocol feature digest.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.1 Candidates 3.1 RC2 CONSENSUS Changes the core protocol
Projects
None yet
Development

No branches or pull requests

2 participants