Part V · Complete Tooling, CLI & Standard Library Reference
Appendix B.2
Standard Library Reference: Codecs, DEFLATE/Zstandard, PNG, Archives, VKP1 & Lockfiles
Complete AST-verified API reference for 19 serialization, wire framing, DEFLATE/Zstd, PNG, archive, and package lockfile modules
Binary and text codecs, compress/deflate, RFC 8878 compress/zstd, lossless image/png, archive/{tar,zip}, Ed25519/ML-DSA-65 pkg/vkp bundles, and homoiconic pkg/lock verification.
Module (use [...]) | Source File | Capabilities | Types | Functions |
|---|---|---|---|---|
archive/tar | lib/archive/tar.vk | Zero host capabilities | 1 | 4 |
archive/zip | lib/archive/zip.vk | Zero host capabilities | 1 | 2 |
codec/cbor | lib/codec/cbor.vk | Zero host capabilities | 0 | 2 |
codec/csv | lib/codec/csv.vk | Zero host capabilities | 0 | 3 |
codec/der | lib/codec/der.vk | Zero host capabilities | 0 | 32 |
codec/hex | lib/codec/hex.vk | Zero host capabilities | 0 | 7 |
codec/http1 | lib/codec/http1.vk | Zero host capabilities | 0 | 7 |
codec/http2 | lib/codec/http2.vk | Zero host capabilities | 3 | 23 |
codec/ini | lib/codec/ini.vk | Zero host capabilities | 0 | 3 |
codec/pem | lib/codec/pem.vk | Zero host capabilities | 0 | 6 |
codec/toml | lib/codec/toml.vk | Zero host capabilities | 0 | 2 |
codec/url | lib/codec/url.vk | Zero host capabilities | 1 | 6 |
codec/vbin | lib/codec/vbin.vk | Zero host capabilities | 0 | 2 |
codec/wire | lib/codec/wire.vk | Zero host capabilities | 1 | 2 |
compress/deflate | lib/compress/deflate.vk | Zero host capabilities | 0 | 6 |
compress/zstd | lib/compress/zstd.vk | Zero host capabilities | 0 | 3 |
image/png | lib/image/png.vk | Zero host capabilities | 1 | 4 |
pkg/lock | lib/pkg/lock.vk | ..env, ..fs | 2 | 16 |
pkg/vkp | lib/pkg/vkp.vk | Zero host capabilities | 3 | 9 |
Module archive/tar
Exported Structs & Interfaces
TarEntry:TarEntry = struct { path str, data bytes, mode i64 = ..., mtime i64 = ... }— Single file entry stored in a.tar/.tar.gzarchive.
Exported Functions
| Symbol | Signature | Description |
|---|---|---|
pack | pack = fn [entries block[TarEntry]] bytes | Packs entries into a POSIX USTAR .tar archive. |
unpack | unpack = fn [raw bytes] block[TarEntry] | Unpacks a POSIX USTAR .tar archive, verifying header checksums and path confinement. |
pack-gz | pack-gz = fn [entries block[TarEntry]] bytes | Packs entries into a gzip-compressed .tar.gz archive. |
unpack-gz | unpack-gz = fn [gz bytes] block[TarEntry] | Decompresses and unpacks a .tar.gz archive. |
Verified Doctest (archive/tar/pack)
VEKO
use [tar = archive/tar]
raw = tar/pack [
tar/TarEntry { path = 'hello.txt', data = bytes/from-str 'hello tar' }
tar/TarEntry { path = 'sub/a.vk', data = bytes/from-str '1 + 2' }
]
out = tar/unpack raw
if (len out) != 2 or out[0].path != 'hello.txt' or (bytes/to-str out[1].data) != '1 + 2' [
err 'tar roundtrip'
] else [ .ok ]Module archive/zip
Exported Structs & Interfaces
ZipEntry:ZipEntry = struct { path str, data bytes, compress bool = ... }— Single file entry stored in a.ziparchive.
Exported Functions
| Symbol | Signature | Description |
|---|---|---|
pack | pack = fn [entries block[ZipEntry]] bytes | Packs entries into a standard PKZIP .zip archive (auto-falling back to STORE if DEFLATE is larger). |
unpack | unpack = fn [raw bytes] block[ZipEntry] | Unpacks a .zip archive via its Central Directory, decompressing DEFLATE entries and verifying CRC-32 checksums. |
Verified Doctest (archive/zip/pack)
VEKO
use [zip = archive/zip]
raw = zip/pack [
zip/ZipEntry { path = 'readme.txt', data = bytes/from-str 'hello veko zip hello veko zip hello veko zip' }
zip/ZipEntry { path = 'raw.bin', data = bytes/from-str 'abc', compress = false }
]
out = zip/unpack raw
if (len out) != 2 or (bytes/to-str out[0].data) != 'hello veko zip hello veko zip hello veko zip' or (bytes/to-str out[1].data) != 'abc' [
err 'zip roundtrip'
] else [ .ok ]Module codec/cbor
Exported Functions
| Symbol | Signature | Description |
|---|---|---|
encode | encode = fn [v any] bytes | Encodes a Veko value into deterministic RFC 8949 CBOR bytes. |
decode | decode = fn [data bytes] any | Decodes RFC 8949 CBOR bytes into a Veko value (CBOR null maps to .null). |
Verified Doctest (codec/cbor/encode)
VEKO
use [cbor = codec/cbor]
raw = cbor/encode { count = -100, ok = true, empty = .null, tag = 'veko' }
dec = cbor/decode raw
if (map/get dec 'count') != -100 or (map/get dec 'empty') != .null or (map/get dec 'tag') != 'veko' [
err 'cbor roundtrip'
] else [ .ok ]Module codec/csv
Exported Functions
| Symbol | Signature | Description |
|---|---|---|
parse | parse = fn [input str] block[block[str]] | Parses RFC 4180 CSV text into rows of string fields (block[block[str]]). Supports quoted fields, embedded commas/newlines, and "" escaped quotes. |
parse-records | parse-records = fn [input str] block[map[str]] | Parses CSV text whose first row contains column headers into block[map[str]]. |
encode | encode = fn [rows block[block[str]]] str | Encodes rows (block[block[str]]) into RFC 4180 CSV text separated by \n. |
Verified Doctest (codec/csv/parse)
VEKO
use [csv = codec/csv]
rows = csv/parse 'name,note\nalpha,"hello, ""world"""\nbeta,plain'
if (len rows) != 3 or rows[1][1] != 'hello, "world"' [ err 'csv/parse' ] else [ .ok ]Module codec/der
Exported Functions
| Symbol | Signature | Description |
|---|---|---|
from-list | from-list = fn [arr block] bytes | Builds a bytes buffer from an integer element block [0x01 0x02 ...]. |
u16-be | u16-be = fn [b bytes, off i64] i64 | Reads a 16-bit big-endian integer from b at off. |
u24-be | u24-be = fn [b bytes, off i64] i64 | Exported codec/der/u24-be operation. |
u32-be | u32-be = fn [b bytes, off i64] i64 | Exported codec/der/u32-be operation. |
put-u16-be | put-u16-be = fn [mut out bytes, v i64] | Exported codec/der/put-u16-be operation. |
put-u24-be | put-u24-be = fn [mut out bytes, v i64] | Exported codec/der/put-u24-be operation. |
put-u32-be | put-u32-be = fn [mut out bytes, v i64] | Exported codec/der/put-u32-be operation. |
put-u16-vec | put-u16-vec = fn [mut out bytes, data bytes] | Exported codec/der/put-u16-vec operation. |
put-u24-vec | put-u24-vec = fn [mut out bytes, data bytes] | Exported codec/der/put-u24-vec operation. |
read-u8 | read-u8 = fn [b bytes, pos i64] any | Exported codec/der/read-u8 operation. |
read-u16 | read-u16 = fn [b bytes, pos i64] any | Exported codec/der/read-u16 operation. |
read-u24 | read-u24 = fn [b bytes, pos i64] any | Exported codec/der/read-u24 operation. |
read-bytes | read-bytes = fn [b bytes, pos i64, n i64] any | Exported codec/der/read-bytes operation. |
read-u16-vec | read-u16-vec = fn [b bytes, pos i64] any | Exported codec/der/read-u16-vec operation. |
read-u24-vec | read-u24-vec = fn [b bytes, pos i64] any | Exported codec/der/read-u24-vec operation. |
decode-tlv | decode-tlv = fn [b bytes, pos i64] any | Decodes one DER TLV element starting at byte offset pos. Returns { tag, cls, constructed, hdr_len, content, raw, next } or err(...). |
decode-all | decode-all = fn [b bytes] any | Decodes all consecutive DER TLVs inside b (typically the content of a SEQUENCE/SET). |
decode-tlv-view | decode-tlv-view = fn [b bytes, pos i64] any | Decodes one DER TLV element without slicing raw. |
decode-all-view | decode-all-view = fn [b bytes] any | Exported codec/der/decode-all-view operation. |
decode-seq-items-view | decode-seq-items-view = fn [node map] any | Exported codec/der/decode-seq-items-view operation. |
decode-seq-items | decode-seq-items = fn [node map] any | Decodes an ASN.1 SEQUENCE TLV node into its child TLV block. |
decode-oid | decode-oid = fn [content bytes] any | Decodes a DER OBJECT IDENTIFIER content byte slice into dotted decimal text (e.g. '1.2.840.113549.1.1.11'). |
decode-int-bytes | decode-int-bytes = fn [content bytes] any | Decodes a positive DER INTEGER into minimal big-endian unsigned magnitude bytes. |
decode-int-i64 | decode-int-i64 = fn [content bytes] any | Decodes a non-negative DER INTEGER up to 63 bits into i64. |
decode-bitstr | decode-bitstr = fn [content bytes] any | Decodes a DER BIT STRING content into { unused_bits, data }. |
tag-to-enum | tag-to-enum = fn [tag i64] any | Returns a homoiconic symbol/tag name for common ASN.1 DER tags for parse-block. |
tlv-to-block | tlv-to-block = fn [node map] any | Converts a decoded DER TLV tree into a homoiconic Veko block [tag_enum payload] so downstream code can match DER structures directly using parse-block. |
encode-len | encode-len = fn [mut out bytes, n i64] | Exported codec/der/encode-len operation. |
encode-tlv | encode-tlv = fn [tag i64, content bytes] bytes | Exported codec/der/encode-tlv operation. |
encode-seq | encode-seq = fn [items block] bytes | Exported codec/der/encode-seq operation. |
encode-int | encode-int = fn [raw_be bytes] bytes | Exported codec/der/encode-int operation. |
encode-bitstr | encode-bitstr = fn [data bytes] bytes | Exported codec/der/encode-bitstr operation. |
Verified Doctest (codec/der/u16-be)
VEKO
use [der = codec/der]
mut b = bytes/with-cap 8
der/put-u16-be mut b 0x0303
der/put-u32-be mut b 0x12345678
if (der/u16-be b 0) != 0x0303 or (der/u32-be b 2) != 0x12345678 [ err 'der be' ] else [ .ok ]Module codec/hex
Exported Functions
| Symbol | Signature | Description |
|---|---|---|
encode | encode = fn [data bytes] str | Encodes data into a lowercase hexadecimal string. |
encode-upper | encode-upper = fn [data bytes] str | Encodes data into an uppercase hexadecimal string. |
decode | decode = fn [s str] bytes | Decodes a hexadecimal string (even length, uppercase or lowercase) into bytes. |
b64-encode | b64-encode = fn [data bytes] str | Encodes data into standard RFC 4648 Base64 with '=' padding. |
b64url-encode | b64url-encode = fn [data bytes] str | Encodes data into RFC 4648 URL-safe Base64 without padding (used by JWT/JWS/OAuth2). |
b64-decode | b64-decode = fn [s str] bytes | Decodes standard or URL-safe Base64 (with or without '=' padding) into bytes. |
b64url-decode | b64url-decode = fn [s str] bytes | Alias for b64-decode accepting unpadded URL-safe Base64 strings. |
Verified Doctest (codec/hex/encode)
VEKO
use [hex = codec/hex]
enc = hex/encode (bytes/from-str 'Veko')
dec = hex/decode enc
if enc != '56656b6f' or (bytes/to-str dec) != 'Veko' [ err 'hex roundtrip' ] else [ .ok ]Module codec/http1
Exported Functions
| Symbol | Signature | Description |
|---|---|---|
encode-request | encode-request = fn [method str, target str, headers map, body bytes] any | Encodes an HTTP/1.1 request wire frame (METHOD TARGET HTTP/1.1\r\n...). |
encode-response | encode-response = fn [status i64, reason str, headers map, body bytes] any | Encodes an HTTP/1.1 response wire frame. |
decode-response | decode-response = fn [raw bytes] any | Decodes an HTTP/1.1 response message into { version, status, reason, headers, body, consumed }. |
decode-response-head | decode-response-head = fn [raw bytes] any | Decodes an HTTP/1.1 HEAD response (status + headers with zero body bytes on the wire, preserving Content-Length). |
decode-request | decode-request = fn [raw bytes] any | Decodes an HTTP/1.1 request message into { method, target, version, headers, body, consumed }. |
request-to-block | request-to-block = fn [req map] block | Converts a decoded request into [ .req method target version headers body ] for parse-block. |
response-to-block | response-to-block = fn [resp map] block | Converts a decoded response into [ .resp version status reason headers body ] for parse-block. |
Verified Doctest (codec/http1/encode-request)
VEKO
use [h1 = codec/http1]
req = h1/encode-request 'GET' '/health' { Host = 'api.local' } (bytes/with-cap 0)
dec = h1/decode-request req
if dec.method != 'GET' or dec.target != '/health' [ err 'http1 roundtrip' ] else [ .ok ]Module codec/http2
Exported Structs & Interfaces
Frame:Frame = struct { ftype i64, flags i64, stream_id i64, payload bytes }— Decoded HTTP/2 binary frame (9-byte header + payload).Header:Header = struct { name str, value str }— Single HTTP/2 header name/value pair.HpackDecoder:HpackDecoder = struct { entries block = ..., cur_size i64 = ..., max_size i64 = ... }— Stateful RFC 7541 HPACK connection decoder maintaining the per-connection FIFO dynamic table.
Exported Functions
| Symbol | Signature | Description |
|---|---|---|
connection-preface | connection-preface = fn [] str | HTTP/2 connection preface (PRI * HTTP/2.0\r\n\r\nSM\r\n\r\n). |
frame-data | frame-data = fn [] i64 | HTTP/2 frame type constants (RFC 9113 Section 6). |
frame-headers | frame-headers = fn [] i64 | Exported codec/http2/frame-headers operation. |
frame-priority | frame-priority = fn [] i64 | Exported codec/http2/frame-priority operation. |
frame-rst-stream | frame-rst-stream = fn [] i64 | Exported codec/http2/frame-rst-stream operation. |
frame-settings | frame-settings = fn [] i64 | Exported codec/http2/frame-settings operation. |
frame-push-promise | frame-push-promise = fn [] i64 | Exported codec/http2/frame-push-promise operation. |
frame-ping | frame-ping = fn [] i64 | Exported codec/http2/frame-ping operation. |
frame-goaway | frame-goaway = fn [] i64 | Exported codec/http2/frame-goaway operation. |
frame-window-update | frame-window-update = fn [] i64 | Exported codec/http2/frame-window-update operation. |
frame-continuation | frame-continuation = fn [] i64 | Exported codec/http2/frame-continuation operation. |
flag-end-stream | flag-end-stream = fn [] i64 | Common HTTP/2 frame flags. |
flag-ack | flag-ack = fn [] i64 | Exported codec/http2/flag-ack operation. |
flag-end-headers | flag-end-headers = fn [] i64 | Exported codec/http2/flag-end-headers operation. |
encode-frame | encode-frame = fn [f Frame] bytes | Encodes an HTTP/2 Frame (24-bit length + type + flags + 31-bit stream ID + payload). |
decode-frame | decode-frame = fn [wire bytes] Frame | Decodes a single HTTP/2 Frame from wire. |
encode-settings | encode-settings = fn [settings map[i64]] bytes | Encodes HTTP/2 SETTINGS pairs (map[i64] mapping setting ID -> 32-bit value) into a SETTINGS frame payload. |
decode-settings | decode-settings = fn [payload bytes] map[i64] | Decodes an HTTP/2 SETTINGS payload into a map[i64] (ID -> value). |
huffman-decode | huffman-decode = fn [enc bytes] str | Decodes an RFC 7541 / RFC 9204 Huffman-compressed byte slice into UTF-8 str. |
hpack-encode | hpack-encode = fn [headers block[Header]] bytes | Encodes headers (block[Header]) into an RFC 7541 HPACK header block using the static table and literal-without-indexing representations. |
new-hpack-decoder | new-hpack-decoder = fn [max_size i64] HpackDecoder | Creates a new stateful HpackDecoder with max_size dynamic table capacity (4096 default per RFC 9113). |
hpack-decode-ctx | hpack-decode-ctx = fn [mut dec HpackDecoder, block_bytes bytes] block[Header] | Decodes an RFC 7541 HPACK header block updating stateful dec (static + dynamic table + Huffman). |
hpack-decode | hpack-decode = fn [block_bytes bytes] block[Header] | Decodes an RFC 7541 HPACK header block (static indexed + literal + Huffman) into block[Header]. |
Verified Doctest (codec/http2/encode-frame)
VEKO
use [h2 = codec/http2]
f = h2/Frame { ftype = h2/frame-data, flags = h2/flag-end-stream, stream_id = 1, payload = (bytes/from-str 'ok') }
wire = h2/encode-frame f
dec = h2/decode-frame wire
if dec.ftype != 0 or dec.stream_id != 1 or (bytes/to-str dec.payload) != 'ok' [ err 'h2 frame' ] else [ .ok ]Module codec/ini
Exported Functions
| Symbol | Signature | Description |
|---|---|---|
parse | parse = fn [input str] map[map[str]] | Parses INI text into a two-level map { section_name = { key = value } }. Top-level keys outside any [section] are placed under the '' (root) section. Lines starting with # or ; are treated as comments. |
get | get = fn [cfg map[map[str]], section str, key str] str | Looks up key inside section of parsed INI cfg, returning err if missing (combine with /or). |
encode | encode = fn [cfg map[map[str]]] str | Serializes a two-level INI section map back into .ini text. |
Verified Doctest (codec/ini/parse)
VEKO
use [ini = codec/ini]
cfg = ini/parse '[server]\nhost = 127.0.0.1\nport = 8443\n# comment\n[tls]\nmin = 1.3'
if (ini/get cfg 'server' 'port') != '8443' or (ini/get cfg 'tls' 'min') != '1.3' [
err 'ini/parse'
] else [ .ok ]Module codec/pem
Exported Functions
| Symbol | Signature | Description |
|---|---|---|
b64-decode | b64-decode = fn [text str] any | Decodes a standard or URL-safe Base64 string into raw bytes (ignoring ASCII whitespace). |
b64-encode | b64-encode = fn [data bytes] str | Encodes data into standard RFC 4648 Base64 text. |
pem-decode-all | pem-decode-all = fn [text str] any | Parses all PEM blocks in text, returning a block of { label, der } maps. |
pem-decode | pem-decode = fn [text str, expected_label str] any | Extracts the first PEM block matching expected_label (or any block if expected_label == ''). |
pem-encode | pem-encode = fn [label str, der bytes] str | Encodes der bytes into a standard 64-column wrapped PEM string. |
pem-to-block | pem-to-block = fn [text str] any | Converts decoded PEM blocks to [ .pem label der ... ] for declarative parse-block matching. |
Verified Doctest (codec/pem/b64-decode)
VEKO
use [pem = codec/pem]
enc = pem/b64-encode (bytes/from-str 'Veko 1.0')
dec = pem/b64-decode enc
if enc != 'VmVrbyAxLjA=' or (bytes/to-str dec) != 'Veko 1.0' [ err 'pem b64' ] else [ .ok ]Module codec/toml
Exported Functions
| Symbol | Signature | Description |
|---|---|---|
decode | decode = fn [src str] map | Decodes a TOML v1.0 string into nested Veko maps, blocks, strings, integers, floats, and booleans. |
encode | encode = fn [doc map] str | Encodes a Veko map (including nested sub-tables) into a clean TOML v1.0 string. |
Verified Doctest (codec/toml/decode)
VEKO
use [toml = codec/toml]
doc = toml/decode 'title = "Veko"\n[server]\nhost = "127.0.0.1"\nport = 8_080\ntls = true\ntags = ["pqc", "oro"]\n'
if doc.title != 'Veko' or doc.server.port != 8080 or doc.server.tls != true or (len doc.server.tags) != 2 [
err 'toml decode'
] else [ .ok ]Module codec/url
Exported Structs & Interfaces
Url:Url = struct { scheme str = ..., userinfo str = ..., host str = ..., port i64 = ..., path str = ..., query str = ..., fragment str = ... }— Structured representation of a parsed RFC 3986 URL.
Exported Functions
| Symbol | Signature | Description |
|---|---|---|
encode-component | encode-component = fn [s str] str | Percent-encodes a URL component per RFC 3986 (spaces become %20). |
decode-component | decode-component = fn [s str] str | Decodes a percent-encoded URL component (also converting + when plus_as_space is false -> leaves + literal). |
parse | parse = fn [raw_url str] Url | Parses an RFC 3986 URL string into a Url struct. |
format | format = fn [u Url] str | Formats a Url struct back into a canonical URL string. |
parse-query | parse-query = fn [q str] map[str] | Parses a URL query string ('a=1&b=hello%20world') into a map[str]. |
encode-query | encode-query = fn [params map[str]] str | Encodes a map[str] into a percent-encoded query string. |
Verified Doctest (codec/url/encode-component)
VEKO
use [url = codec/url]
e = url/encode-component 'hello world/v1'
if e != 'hello%20world%2Fv1' or (url/decode-component e) != 'hello world/v1' [ err 'url enc' ] else [ .ok ]Module codec/vbin
Exported Functions
| Symbol | Signature | Description |
|---|---|---|
encode | encode = fn [v any] bytes | Encodes any supported Veko value into canonical deterministic VBIN bytes. |
decode | decode = fn [data bytes] any | Decodes VBIN bytes back into a Veko value (wire null maps to .null). |
Verified Doctest (codec/vbin/encode)
VEKO
use [vbin = codec/vbin]
orig = { a = 1, b = -42, c = [true .null 'ok'], d = (bytes/from-str 'xy') }
enc = vbin/encode orig
dec = vbin/decode enc
if (map/get dec 'b') != -42 or (map/get dec 'c')[1] != .null [ err 'vbin roundtrip' ] else [ .ok ]Module codec/wire
Exported Structs & Interfaces
Field:Field = struct { name str, kind enum, size i64 = ... }— Describes a single field in a binary wire packet schema.
Exported Functions
| Symbol | Signature | Description |
|---|---|---|
pack | pack = fn [schema block[Field], record map] bytes | Packs a map of field values according to schema (block[Field]) into bytes. |
unpack | unpack = fn [schema block[Field], data bytes] map | Unpacks data according to schema (block[Field]) into a map of decoded values. |
Verified Doctest (codec/wire/pack)
VEKO
use [w = codec/wire]
schema = [
w/Field { name = 'version', kind = .u16_be }
w/Field { name = 'flags', kind = .u8 }
w/Field { name = 'seq', kind = .varint }
w/Field { name = 'topic', kind = .str_u16_be }
]
pkt = w/pack schema { version = 0x0303, flags = 5, seq = 300, topic = 'metrics' }
dec = w/unpack schema pkt
if (map/get dec 'version') != 0x0303 or (map/get dec 'seq') != 300 or (map/get dec 'topic') != 'metrics' [
err 'wire roundtrip'
] else [ .ok ]Module compress/deflate
Exported Functions
| Symbol | Signature | Description |
|---|---|---|
inflate | inflate = fn [compressed bytes] bytes | Decompresses raw RFC 1951 DEFLATE bytes (supports stored, fixed Huffman, and dynamic Huffman blocks). |
deflate | deflate = fn [data bytes] bytes | Compresses data into raw RFC 1951 DEFLATE bytes using LZ77 + Fixed Huffman (automatically selecting a Stored block if the input is incompressible). |
zlib-compress | zlib-compress = fn [data bytes] bytes | Compresses data into RFC 1950 zlib format (0x78 0x9c + DEFLATE + Adler-32). |
zlib-decompress | zlib-decompress = fn [zbytes bytes] bytes | Decompresses RFC 1950 zlib bytes and verifies the Adler-32 checksum. |
gzip-compress | gzip-compress = fn [data bytes] bytes | Compresses data into RFC 1952 gzip format (10-byte header + DEFLATE + CRC-32 + ISIZE). |
gzip-decompress | gzip-decompress = fn [gz bytes] bytes | Decompresses RFC 1952 gzip bytes and verifies both CRC-32 and ISIZE trailers. |
Verified Doctest (compress/deflate/inflate)
VEKO
use [def = compress/deflate]
msg = bytes/from-str 'veko deflate deflate deflate compression test 12345 12345 12345'
comp = def/deflate msg
back = def/inflate comp
if back != msg or (len comp) >= (len msg) [ err 'deflate roundtrip' ] else [ .ok ]Module compress/zstd
Exported Functions
| Symbol | Signature | Description |
|---|---|---|
zstd-frame? | zstd-frame? = fn [data bytes] bool | Returns true if data starts with the 4-byte RFC 8878 Zstandard frame magic 28 B5 2F FD. |
compress | compress = fn [data bytes] bytes | Compresses data into a wire-compliant RFC 8878 Zstandard frame. |
decompress | decompress = fn [zbytes bytes] bytes | Decompresses one or more concatenated RFC 8878 Zstandard frames (ignoring skippable frames). |
Verified Doctest (compress/zstd/compress)
VEKO
use [zstd = compress/zstd]
mut msg = bytes/with-cap 256
_ = bytes/push-all mut msg (bytes/from-str 'Veko Zstd Frame Header: ')
mut i = 0
while i < 64 [
_ = bytes/push mut msg 65
i = i + 1
]
_ = bytes/push-all mut msg (bytes/from-str ' -- tail payload!')
z = zstd/compress msg
if (not (zstd/zstd-frame? z)) or (zstd/decompress z) != msg [ err 'zstd roundtrip' ] else [ .ok ]Module image/png
Exported Structs & Interfaces
PngImage:PngImage = struct { width i64, height i64, pixels bytes }— Decoded RGBA32 PNG image surface (width * height * 4bytes, top-down).
Exported Functions
| Symbol | Signature | Description |
|---|---|---|
encode-rgba | encode-rgba = fn [rgba bytes, w i64, h i64] bytes | Encodes a top-down RGBA32 byte buffer (w * h * 4 bytes) into an RFC 2083 PNG byte stream. Uses adaptive per-row filtering (None, Sub, Up) for compact UI screenshot compression. |
encode | encode = fn [c cv/Canvas] bytes | Encodes a ui/canvas Canvas directly into PNG bytes. |
decode-rgba | decode-rgba = fn [png_bytes bytes] PngImage | Decodes an RFC 2083 8-bit PNG byte stream (Grayscale, RGB, Grayscale+Alpha, or RGBA; non-interlaced; all 5 scanline filters 0..4) into a top-down RGBA32 PngImage. |
decode | decode = fn [png_bytes bytes] cv/Canvas | Decodes a PNG byte stream directly into a ui/canvas Canvas. |
Verified Doctest (image/png/encode-rgba)
VEKO
use [png = image/png, cv = ui/canvas]
mut c = cv/new-canvas 16 12
cv/clear mut c (cv/rgb 248 250 252)
cv/fill-rect mut c 2 2 8 6 (cv/rgb 2 132 199)
raw_png = png/encode c
dec = png/decode raw_png
p0 = cv/get-pixel dec 0 0
p1 = cv/get-pixel dec 4 4
if dec.width != 16 or dec.height != 12 or p0.r != 248 or p1.b != 199 [ err 'png roundtrip' ] else [ .ok ]Module pkg/lock
Exported Structs & Interfaces
LockEntry:LockEntry = struct { name str, version str, source str, sha256 str, merkle_root str, signer str = ... }— One cryptographically pinned package dependency inveko.lock.Lockfile:Lockfile = struct { version i64 = ..., packages block[LockEntry] }— Parsed representation of aveko.lockmanifest.
Exported Functions
| Symbol | Signature | Description |
|---|---|---|
DEFAULT-REGISTRY | DEFAULT-REGISTRY = fn [] str | Official Veko HTTPS package registry root (veko-lang.org), overrideable via VEKO_REGISTRY. |
registry-base | registry-base = fn [] str | Returns the active HTTPS registry base URL (VEKO_REGISTRY when set, otherwise https://veko-lang.org/pkg). |
modules-home | modules-home = fn [] str | Resolves the shared user-level .veko_modules directory (VEKO_MODULES -> $HOME/.veko_modules / %USERPROFILE%\.veko_modules -> .veko/modules). |
expand-spec-with-registry | expand-spec-with-registry = fn [spec str, reg_base str] str | Expands a dependency specifier into its canonical source URL or local path: - 'http-extra@1.2.0' -> 'https://veko-lang.org/pkg/http-extra/1.2.0.vkp' (or VEKO_REGISTRY) - 'https://host/pkg.vkp' -> unchanged decentralized URL - '../shared' or 'vendor/pkg.vkp' -> unchanged local path |
resolve-dep-spec | resolve-dep-spec = fn [spec str] str | Expands spec using the active registry-base. |
infer-dep-name | infer-dep-name = fn [spec str] str | Extracts the default dependency alias from a specifier ('sqlite-orm@1.0.2' -> 'sqlite-orm', 'https://.../foo-1.0.vkp' -> 'foo'). |
fetch-vkp-url | fetch-vkp-url = fn [url str] bytes | Downloads raw binary .vkp bytes over HTTP/HTTPS across all 3 execution tracks (lib/net/client.vk). |
encode | encode = fn [lf Lockfile] str | Formats a Lockfile into canonical, idempotent homoiconic veko.lock text. |
decode | decode = fn [src str] Lockfile | Zero-eval deterministic parser for homoiconic veko.lock files. |
lock-vkp-bytes | lock-vkp-bytes = fn [dep_name str, source_ref str, raw bytes, trust_keys block[str]] LockEntry | Builds a LockEntry from a signed .vkp bundle raw (verifying trust_keys when non-empty, or self-signature otherwise). |
verify-locked-bytes | verify-locked-bytes = fn [entry LockEntry, raw bytes, extra_trust block[str]] vkp/VkpBundle | Verifies raw .vkp bytes against every cryptographic field pinned in entry (sha256, merkle_root, and signer + extra_trust). |
global-cache-path | global-cache-path = fn [entry LockEntry] str | Returns the global content-addressed cache path <~/.veko_modules>/cache/<sha256>.vkp for entry. |
installed-pkg-path | installed-pkg-path = fn [entry LockEntry] str | Returns the human-readable installed snapshot path <~/.veko_modules>/pkgs/<name>@<version>.vkp for entry. |
cache-path | cache-path = fn [proj_dir str, entry LockEntry] str | Returns the workspace-local content-addressed cache path <proj_dir>/.veko/pkg_cache/<sha256>.vkp for entry. |
locate-cached-vkp | locate-cached-vkp = fn [proj_dir str, entry LockEntry] str | Resolves cached .vkp path preferring ~/.veko_modules/cache/<sha256>.vkp if present, then <proj_dir>/.veko/pkg_cache/<sha256>.vkp. |
find-entry | find-entry = fn [lf Lockfile, dep_name str] LockEntry | Looks up dep_name inside lf (err if absent). |
Verified Doctest (pkg/lock/expand-spec-with-registry)
VEKO
use [lk = pkg/lock]
u1 = lk/expand-spec-with-registry 'sqlite-orm@1.0.2' 'https://veko-lang.org/pkg'
u2 = lk/expand-spec-with-registry 'https://cdn.example.org/p.vkp' 'https://veko-lang.org/pkg'
if u1 != 'https://veko-lang.org/pkg/sqlite-orm/1.0.2.vkp' or u2 != 'https://cdn.example.org/p.vkp' [ err 'spec expand failed' ] else [ .ok ]Module pkg/vkp
Exported Structs & Interfaces
VkpEntry:VkpEntry = struct { path str, source bytes, sha256 bytes }— One module source file stored inside a'VKP1'bundle.VkpSig:VkpSig = struct { alg enum, pubkey bytes, signature bytes }— One cryptographic signature attached to a'VKP1'bundle.VkpBundle: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.
Exported Functions
| Symbol | Signature | Description |
|---|---|---|
merkle-root | 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 | 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 | 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. |
pack-ed25519 | 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 | 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 | 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 | 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 | 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 | extract-module = fn [bundle VkpBundle, rel_path str] str | Extracts the UTF-8 .vk source string for rel_path from a verified VkpBundle. |
Verified Doctest (pkg/vkp/pack)
VEKO
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 ]