Project
compiler
Context
The current way to hash a value in SimplicityHL uses the raw context API:
let ctx1 = jet::sha_256_ctx_8_init();
let ctx2 = jet::sha_256_ctx_8_add_2(ctx1, 0x5120);
let ctx3 = jet::sha_256_ctx_8_add_32(ctx2, tweaked_key);
let hash = jet::sha_256_ctx_8_finalize(ctx3);
Every hash of a compound value spans several lines of ctx-threading. This is noisy in application code.
Available primitives
sha_256_ctx_8_add_N exists for N ∈ {2, 4, 8, 16, 32, 64, 128, 256, 512}
plus sha_256_ctx_8_add_buffer_511. Any wrapper has to dispatch across
this set based on the static size of its input.
Wanted
An ergonomic wrapper, ideally something like:
let hash = sha_256(tweaked_key);
let hash = sha_256((0x5120, tweaked_key));
so that "init, add, finalize" collapses into one call.
Open question
Input shape: fixed-size type, tuple of fixed-size types, both? What is rejected and how does a user handle it?
Deliverable
Design proposal answering the questions above, reviewed on this issue, then implementation.
Project
compiler
Context
The current way to hash a value in SimplicityHL uses the raw context API:
Every hash of a compound value spans several lines of ctx-threading. This is noisy in application code.
Available primitives
sha_256_ctx_8_add_Nexists for N ∈ {2, 4, 8, 16, 32, 64, 128, 256, 512}plus
sha_256_ctx_8_add_buffer_511. Any wrapper has to dispatch acrossthis set based on the static size of its input.
Wanted
An ergonomic wrapper, ideally something like:
so that "init, add, finalize" collapses into one call.
Open question
Input shape: fixed-size type, tuple of fixed-size types, both? What is rejected and how does a user handle it?
Deliverable
Design proposal answering the questions above, reviewed on this issue, then implementation.