pkg/vkp
lib/pkg/vkp.vklib/pkg/vkp.vk
Pure-Veko signed single-file 'VKP1' package bundle codec and verifier.
Supports deterministic SHA-256 Merkle trees over sorted module entries and
Ed25519 (RFC 8032), ML-DSA-65 (FIPS 204 post-quantum), or hybrid dual signatures.
Zero capabilities required for in-memory pack/unpack/verify.
VkpEntry = struct { path str, source bytes, sha256 bytes }
One module source file stored inside a 'VKP1' bundle.
VkpSig = struct { alg enum, pubkey bytes, signature bytes }
One cryptographic signature attached to a 'VKP1' bundle.
VkpBundle = struct { version i64, manifest map, entries block[VkpEntry], merkle_root bytes, payload_digest bytes, signatures block[VkpSig] }
Verified, unpacked representation of a 'VKP1' signed package bundle.
merkle-root = fn [entries block[VkpEntry]] bytes
Computes the deterministic 32-byte SHA-256 Merkle root over entries (assumed sorted by path).
format-trust-key = fn [alg enum, pubkey bytes] str
Formats a trust-key string ('ed25519:<hex>' or 'mldsa65:<hex>') for veko.vk trust-keys.
pack = fn [manifest map, files map, ed25519_seed bytes, mldsa_kp any] bytes
Packs manifest and files (map of logical path -> str/bytes) into a 'VKP1' bundle signed with Ed25519 and/or ML-DSA-65.
Pass bytes/with-cap 0 for ed25519_seed or .none for mldsa_kp to omit that signature algorithm.
use [vkp = pkg/vkp, x25 = crypto/x25519]
seed = bytes/from-str '0123456789abcdef0123456789abcdef'
pk = x25/ed25519-pubkey seed
raw = vkp/pack-ed25519 { name = 'demo', version = '1.0.0' } { 'mod.vk' = 'pub answer = fn [] i64 [ 42 ]' } seed
b = vkp/verify raw [(vkp/format-trust-key .ed25519 pk)]
if (vkp/extract-module b 'mod.vk') != 'pub answer = fn [] i64 [ 42 ]' [ err 'vkp roundtrip' ] else [ .ok ]
pack-ed25519 = fn [manifest map, files map, ed25519_seed bytes] bytes
Convenience wrapper that packs and signs a 'VKP1' bundle with a 32-byte Ed25519 seed.
pack-mldsa65 = fn [manifest map, files map, mldsa_kp dsa/KeyPair] bytes
Convenience wrapper that packs and signs a 'VKP1' bundle with a FIPS 204 ML-DSA-65 keypair.
unpack = fn [raw bytes] VkpBundle
Unpacks a 'VKP1' bundle and verifies its structural integrity, path safety, per-entry SHA-256 hashes, and Merkle root.
verify = fn [raw bytes, trusted_keys block[str]] VkpBundle
Unpacks and cryptographically verifies a 'VKP1' bundle against trusted_keys (['ed25519:<hex>', 'mldsa65:<hex>']).
Requires every embedded signature to be valid AND at least one signature to match a key in trusted_keys.
verify-self = fn [raw bytes] VkpBundle
Verifies that all embedded signatures in raw are cryptographically valid against their embedded public keys (no trust-anchor check).
extract-module = fn [bundle VkpBundle, rel_path str] str
Extracts the UTF-8 .vk source string for rel_path from a verified VkpBundle.