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

feat: expose secp hashing to lua environment #314

Open
wants to merge 3 commits into
base: trunk
Choose a base branch
from

Conversation

nicol-ii
Copy link
Contributor

feat: expose secp hashing to lua environment

Exposes a hash function to the Lua smart contract execution environment.
Additionally adds a handful of library version bumps and other cleanup.

maurermi and others added 3 commits February 25, 2025 15:26
Signed-off-by: Michael Maurer <[email protected]>
@maurermi
Copy link
Collaborator

This is great! @nicol-ii if you can fix up the linter errors then we should be able to push this forward some

Copy link
Collaborator

@HalosGhost HalosGhost left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A simple and clear exposure of internal hashing to the Lua runner. There are just a couple instances of small tidying that occur to me. Well done!

Comment on lines +46 to +50

hash = make_hash("Hello World!")
print(hash)

if sequence < from_seq then
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Presumably, this is meant to test that the newly-exposed function works; can this be verified using a real test instead of adding IO to the bytecode generation?

On that note, when testing the exposure of a hash-function (or any data-transformation) specifically, it's probably a good idea to verify that it works against known values (i.e., I'd suggest asserting that the hash from "Hello World!" is what you expect).

Comment on lines +318 to +322
auto unsigned_str = std::vector<unsigned char>(sz);
std::memcpy(unsigned_str.data(), str, sz);
sha.Write(unsigned_str.data(), sz);
cbdc::hash_t computed_hash{};
sha.Finalize(computed_hash.data());
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cbdc::hash_data() is effectively this snippet refactored into a method; I might suggest using it here directly.

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

Successfully merging this pull request may close these issues.

3 participants