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

Cryspen HACL Packages #200

Open
danwallach opened this issue Nov 7, 2022 · 4 comments
Open

Cryspen HACL Packages #200

danwallach opened this issue Nov 7, 2022 · 4 comments
Assignees
Labels
non-jvm Specific to non-jvm platform development

Comments

@danwallach
Copy link
Contributor

Possibly interesting:
https://github.com/cryspen/hacl-packages
https://blog.cryspen.com/blog/hacl-0_6/

So far as I can tell, the only thing that's actually new, from our perspective, is that they've gone to the trouble of getting HACL compiling and packaged up on every platform we care about. They don't seem to yet have their builds hosted so you can have a binary-only dependency, but they've figured out how to build with all the right flags on every platform. That's still a win, in terms of removing stuff from our repository.

Also kinda interesting: they've got OCaml bindings (which come from the original work at Microsoft), Rust (a directory full of code, but it's labeled "work in progress, don't use in production"), and JavaScript (claimed in the README, but no code present).

@danwallach
Copy link
Contributor Author

danwallach commented Nov 10, 2022

Possible cmake incantation to fetch the source code and do a build:

FetchContent_Declare(hacl
        DOWNLOAD_EXTRACT_TIMESTAMP TRUE
        URL https://github.com/cryspen/hacl-packages/archive/refs/tags/c-v0.6.0.zip
    )
FetchContent_MakeAvailable(hacl)

@danwallach
Copy link
Contributor Author

danwallach commented Nov 29, 2022

Using the above code doesn't work. You ultimately get this:

CMake Error at CMakeLists.txt:54 (include):
  include could not find requested file:

    build/config.cmake


CMake Error at CMakeLists.txt:76 (include):
  include could not find requested file:

    build/config.cmake

So, if you go to the Cryspen page, it talks about using a tool called mach, which is their own build front-end tool (written in Python). That file does manage to get installed, but if you run it with build, here's the output:

% _deps/hacl-src/mach build
 [mach] Dependency checks ...
 [mach] Probing for cmake: Found
 [mach] Probing for ninja: Found

 [mach] Running config to write config.cmake and config.h ...
 [mach] Using config/config.json to configure ...
Traceback (most recent call last):
  File "/Users/dwallach/IdeaProjects/electionguard-kotlin-multiplatform/hacllib/build/_deps/hacl-src/mach", line 476, in <module>
    main()
  File "/Users/dwallach/IdeaProjects/electionguard-kotlin-multiplatform/hacllib/build/_deps/hacl-src/mach", line 472, in main
    args.func(args)
  File "/Users/dwallach/IdeaProjects/electionguard-kotlin-multiplatform/hacllib/build/_deps/hacl-src/mach", line 368, in build
    config = Config(json_config(), source_dir, include_dir, compiler=compiler)
  File "/Users/dwallach/IdeaProjects/electionguard-kotlin-multiplatform/hacllib/build/_deps/hacl-src/tools/configure.py", line 109, in __init__
    with open(config_file, "r") as f:
FileNotFoundError: [Errno 2] No such file or directory: 'config/config.json'
>> _deps/hacl-src/mach: 1

Okay, so do we have a config/config.json file somewhere? Yes. It's in there (_deps/hacl-src/config/config.json).

Hmmm.

@danwallach
Copy link
Contributor Author

Okay, but if I just cloned their repo, completely separate from ElectionGuard, and ran ./mach build, then everything just magically worked. This suggests that they're not quite making things work correctly for interfacing with FetchContent.

@franziskuskiefer
Copy link

For reference, here's an example for how to use HACL packages in CMake on a branch that fixes the config issue https://github.com/cryspen/hacl-packages/tree/franziskus/cmake-standalone-build/examples/cmake

@JohnLCaron JohnLCaron added the non-jvm Specific to non-jvm platform development label Jan 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
non-jvm Specific to non-jvm platform development
Projects
None yet
Development

No branches or pull requests

3 participants