Skip to main content

Installation

npm install @brik64/core
# pnpm add @brik64/core
# yarn add @brik64/core
Works in Node.js (18+) and modern browsers. Full TypeScript type definitions included.

Quick Start

import { mc, eva } from '@brik64/core';

// Arithmetic — wrapping, never throws
const sum = mc.arithmetic.add8(200, 100);     // 255 (saturating)
const diff = mc.arithmetic.sub8(10, 20);      // 0 (saturating)
const [q, r] = mc.arithmetic.div8(17, 5);     // [3, 2]

// Logic
const result = mc.logic.and8(0xFF, 0x0F);     // 15
const shifted = mc.logic.shl8(1, 4);          // 16

// Crypto
const hash = await mc.crypto.sha256(
  new TextEncoder().encode('hello')
);

All 128 Monomers

The SDK exposes all 128 monomers organized by family:
mc.arithmetic   // MC_00–MC_07:  ADD8, SUB8, MUL8, DIV8, MOD8, NEG8, ABS8, POW8
mc.logic        // MC_08–MC_15:  AND8, OR8, XOR8, NOT8, SHL8, SHR8, ROL8, ROR8
mc.memory       // MC_16–MC_23:  STORE, LOAD, PUSH, POP, DUP, SWAP, ZERO, COPY
mc.control      // MC_24–MC_31:  JUMP, JZ, JNZ, CALL, RET, LOOP, BREAK, HALT
mc.io           // MC_32–MC_39:  READ, WRITE, OPEN, CLOSE, SEEK, FLUSH, STAT, SYNC
mc.string       // MC_40–MC_47:  LEN, CAT, SLICE, FIND, REPLACE, UPPER, LOWER, TRIM
mc.crypto       // MC_48–MC_55:  SHA256, SHA512, HMAC, AES_ENC, AES_DEC, RAND, HASH, VERIFY
mc.system       // MC_56–MC_63:  CLOCK, SLEEP, EXIT, ENV, SPAWN, WAIT, SIGNAL, PIPE

// Extended monomers: MC_64–MC_127
mc.extended.arithmetic  // MC_64–MC_71
mc.extended.logic       // MC_72–MC_79
// ... etc

EVA Composition

Compose monomers using EVA algebra operators:
import { mc, eva } from '@brik64/core';

// Sequential composition (⊗)
const pipeline = eva.seq(
  (x: number) => mc.arithmetic.add8(x, 10),
  (x: number) => mc.arithmetic.mul8(x, 2),
);
pipeline(5);  // (5 + 10) * 2 = 30

// Parallel composition (∥)
const both = eva.par(
  (x: number) => mc.arithmetic.add8(x, 1),
  (x: number) => mc.arithmetic.mul8(x, 2),
);
both(5);  // [6, 10]

// Conditional composition (⊕)
const branch = eva.cond(
  (x: number) => x > 10,
  (x: number) => mc.arithmetic.add8(x, 1),
  (x: number) => mc.arithmetic.sub8(x, 1),
);
branch(15);  // 16
branch(5);   // 4

TypeScript Types

import type { Monomer, EvaOperator, MonomerFamily } from '@brik64/core';
All monomer functions are fully typed with input/output signatures matching the PCD specification.

Python SDK

Use monomers in Python.

Rust SDK

Use monomers in Rust.