From c1f4a54b344b9d96509f1f36b6ba1d67230a1313 Mon Sep 17 00:00:00 2001 From: Junxiao Shi Date: Sat, 12 Oct 2024 02:59:56 +0000 Subject: [PATCH] trust-schema: Light VerSec compiler in Python --- pkg/pyrepo/README.md | 4 ++-- pkg/trust-schema/README.md | 21 +++++++++++++++++++++ pkg/trust-schema/lvs/compile.py | 8 ++++++++ 3 files changed, 31 insertions(+), 2 deletions(-) create mode 100644 pkg/trust-schema/lvs/compile.py diff --git a/pkg/pyrepo/README.md b/pkg/pyrepo/README.md index 263e5e30..0ba65a1b 100644 --- a/pkg/pyrepo/README.md +++ b/pkg/pyrepo/README.md @@ -8,8 +8,8 @@ To install and start the specified version, run: ```bash # create Python virtual environment -python3 -m venv ~/pyrepo-venv -source ~/pyrepo-venv/bin/activate +python3 -m venv ~/pyrepo.venv +source ~/pyrepo.venv/bin/activate # install ndn-python-repo pip install git+https://github.com/UCLA-IRL/ndn-python-repo@2dcd229a4cb81927a52e8a8f1d963c55ee939ffa diff --git a/pkg/trust-schema/README.md b/pkg/trust-schema/README.md index 55b90702..c169528a 100644 --- a/pkg/trust-schema/README.md +++ b/pkg/trust-schema/README.md @@ -151,6 +151,27 @@ await keyChain.insertCert(rootCert); const schema = new TrustSchema(policy, [rootCert]); ``` +## LVS Binary Format + +This package intends to support importing [python-ndn Light VerSec (LVS)](https://python-ndn.readthedocs.io/en/latest/src/lvs/lvs.html) binary format. +This feature is still in design stage. + +To compile LVS textual format to binary format, you need to use python-ndn: + +```bash +# create Python virtual environment +python3.11 -m venv ~/lvs.venv +source ~/lvs.venv/bin/activate + +# install python-ndn +pip install 'python-ndn[dev] @ git+https://github.com/named-data/python-ndn@177844e6142bd4616929bbbfa10a857569fbdf5b' + +# run the compiler +python ./lvs/compile.py <~/lvs-model.txt >~/lvs-model.tlv +``` + +The compiled binary TLV will be importable into NDNts in the future. + ## Trust Schema Signer `TrustSchemaSigner` type can automatically select a signer among available certificates in the KeyChain. diff --git a/pkg/trust-schema/lvs/compile.py b/pkg/trust-schema/lvs/compile.py new file mode 100644 index 00000000..7eed3dac --- /dev/null +++ b/pkg/trust-schema/lvs/compile.py @@ -0,0 +1,8 @@ +#!/usr/bin/env python +import sys + +import ndn.app_support.light_versec + +lvs_text = sys.stdin.read() +lvs_model = ndn.app_support.light_versec.compile_lvs(lvs_text) +sys.stdout.buffer.write(lvs_model.encode())