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

PQ code package update script #323

Closed
wants to merge 14 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "libcrux-ml-kem/pqcp/repo"]
path = libcrux-ml-kem/pqcp/repo
url = [email protected]:pq-code-package/mlkem-rust-libcrux.git
7 changes: 7 additions & 0 deletions libcrux-ml-kem/pqcp/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# SPDX-License-Identifier: Apache-2.0
# (TODO customize .gitignore for project)

.vscode
.idea
/target
Cargo.lock
6 changes: 6 additions & 0 deletions libcrux-ml-kem/pqcp/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# PQCP

## Submodule

## Updating

6 changes: 6 additions & 0 deletions libcrux-ml-kem/pqcp/allowlist.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
build.rs
examples
src
tests
benches
pqcp/.gitignore
44 changes: 44 additions & 0 deletions libcrux-ml-kem/pqcp/cargo.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import tomlkit
import os
import sys

libcrux_root = sys.argv[1]
workspace_toml_path = os.path.join(libcrux_root, 'Cargo.toml')
crate_toml_path = os.path.join(libcrux_root, 'libcrux-ml-kem/Cargo.toml')
package_toml_path = os.path.join(libcrux_root, 'libcrux-ml-kem/pqcp/repo/Cargo.toml')

with open(workspace_toml_path, 'r') as workspace_toml_f:
with open(crate_toml_path, 'r') as crate_toml_f:
workspace_toml = tomlkit.parse(workspace_toml_f.read())
crate_toml = tomlkit.parse(crate_toml_f.read())

package_toml = tomlkit.document()

package = tomlkit.table()
package["name"] = crate_toml["package"]["name"]
package["description"] = crate_toml["package"]["description"]
package["readme"] = crate_toml["package"]["readme"]
package["version"] = workspace_toml["workspace"]["package"]["version"]
package["authors"] = workspace_toml["workspace"]["package"]["authors"]
package["license"] = workspace_toml["workspace"]["package"]["license"]
package["edition"] = workspace_toml["workspace"]["package"]["edition"]
package["repository"] = workspace_toml["workspace"]["package"]["repository"]
package_toml["package"] = package


package_toml["workspace"] = tomlkit.table()
package_toml["workspace"]["members"] = ["."]


deps = tomlkit.table()
for dep in crate_toml["dependencies"]:
deps[dep] = {"version": crate_toml["dependencies"][dep]["version"]}
package_toml["dependencies"] = deps
package_toml["features"] = crate_toml["features"]
package_toml["dev-dependencies"] = crate_toml["dev-dependencies"]

package_toml["profile"] = tomlkit.table()
package_toml["profile"]["release"] = workspace_toml["profile"]["release"]

with open(package_toml_path, 'w') as package_toml_f:
package_toml_f.write(tomlkit.dumps(package_toml))
1 change: 1 addition & 0 deletions libcrux-ml-kem/pqcp/repo
Submodule repo added at f83fd4
47 changes: 47 additions & 0 deletions libcrux-ml-kem/pqcp/update-pqcp.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#!/usr/bin/env bash
#
# This script copies files to be included in the `mlkem-rust-libcrux`
# crate for the PQ code package. Files and directories to be copied
# are listed, one per line, in a file at `ALLOWLIST` and copied to the
# PQCP submodule. The copied files include a custom .gitignore file
# for mlkem-rust-libcrux. On successful completion of `cargo test`, a
# signed-off commit is created in the target repository.

set -e
set -o pipefail

if [ -z "$(which pip)" ]
then
echo "Error: Python (>= 3.7) required to run this script."
fi

if [ -z "$(pip list | grep tomlkit)" ]
then
echo "Error: Pythong package tomlkit required to run this script."
echo "To install it using pip, run"
echo ""
echo " pip install tomlkit"
echo ""
exit 1
fi

libcrux_root="$(git rev-parse --show-toplevel)"
libcrux_ml_kem_crate="$libcrux_root/libcrux-ml-kem"
allowlist="$libcrux_ml_kem_crate/pqcp/allowlist.txt"
pqcp_repo="$libcrux_ml_kem_crate/pqcp/repo"

cd "$libcrux_ml_kem_crate"
while read -r item; do
cp -r "$item" "$pqcp_repo"
done < "$allowlist"

python "$libcrux_ml_kem_crate/pqcp/cargo.py" "$libcrux_root"
Copy link
Member

Choose a reason for hiding this comment

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

python doesn't exist on many systems. You probably want python3.


cd "$pqcp_repo"
cargo test
cargo clean

message="$(printf "mlkem-rust-libcrux PQ code packages update\n\n$(date): libcrux revision $(git -C $libcrux_root rev-parse HEAD)")"
git switch -c "libcrux-ml-kem-$(git -C $libcrux_root rev-parse HEAD)"
Copy link
Member

Choose a reason for hiding this comment

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

This moved the libcrux repo over to this revision. Something doesn't seem quite right here.

git add .
git commit -sm "$message"
Loading