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

Expose SHA512 to vats #3512

Open
warner opened this issue Jul 23, 2021 · 2 comments
Open

Expose SHA512 to vats #3512

warner opened this issue Jul 23, 2021 · 2 comments
Assignees
Labels
enhancement New feature or request liveslots requires vat-upgrade to deploy changes moddable-P2 Moddable collaboration: future priority SwingSet package: SwingSet xsnap the XS execution tool

Comments

@warner
Copy link
Member

warner commented Jul 23, 2021

What is the Problem Being Solved?

The ongoing Endo "hashed archive" work means that vats (Zoe in particular) will soon need the ability to compute SHA512 over bytes. @kriskowal 's new "hashBundle" package will use this to accept a source-code archive and verify/return its hash. Zoe will then use this package to accept bundles and return an InstallationHandle with a "get hash" method.

Description of the Design

SHA512 is just an algorithm, and our vats are Turing-complete, so strictly speaking we don't need to do anything special. But for performance (and correctness) reasons we probably want to use native code to do the hashing.

We'll start with a platform-level SHA512 function: import ?? from 'crypto' on Node, something written in C on XS. Then the vat worker supervisor will need to expose it to the vat. We'll either make it a global, or attach it to vatPowers, depending on our confidence and patience.

Security Considerations

A C implementation of SHA512 will consume CPU time in proportion to the data you feed it, but won't cause the compute meter to change very much, so we must consider whether vats can use this for a metering attack.

The implementation must, of course, be memory safe and not expose any undue authority. To the vat. It should be just like an open-coded JS SHA512 library, but faster.

Test Plan

Normal unit tests.

@warner warner added enhancement New feature or request SwingSet package: SwingSet labels Jul 23, 2021
@kriskowal kriskowal self-assigned this Jul 23, 2021
@dckc dckc added the xsnap the XS execution tool label Aug 2, 2021
@dckc
Copy link
Member

dckc commented Aug 19, 2021

The Moddable SDK includes a crypt module that includes sha512, so if/when we get build support for their module FFI system (#3510) we could slot that in.

@kriskowal
Copy link
Member

That’s exciting and would save us the trouble of bouncing a message off the controlling process.

@dckc dckc added the moddable-P2 Moddable collaboration: future priority label Aug 26, 2021
@warner warner added the liveslots requires vat-upgrade to deploy changes label Jan 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request liveslots requires vat-upgrade to deploy changes moddable-P2 Moddable collaboration: future priority SwingSet package: SwingSet xsnap the XS execution tool
Projects
None yet
Development

No branches or pull requests

4 participants