A collection of cryptographic primitives for CC:Tweaked.
Find a file
2024-10-28 00:36:51 -06:00
.vscode Initial commit 2022-03-01 20:08:55 -03:00
ccryptolib Copy sha512 to main lib for general use 2024-10-28 00:23:43 -06:00
example Add some silly examples 2024-10-28 00:36:51 -06:00
spec Stabilize x25519c.lua 2023-10-29 19:37:38 -03:00
install.lua Test install script 2024-10-27 16:31:05 -06:00
LICENSE Create LICENSE 2023-06-08 01:26:25 -03:00
profile.lua Add a profiling program 2023-06-09 13:28:10 -03:00
README.md Update README 2024-10-27 17:55:35 -06:00

CCryptoLib

An integrated collection of cryptographic primitives written in Lua using the ComputerCraft system API.

Installation

A simple install script is provided, just run the following command: wget run https://git.chrischro.me/ChrisChrome/ccryptolib/raw/branch/main/install.lua

Initialization

An init.lua is provided to allow easier access to all modules, use crypto = require("ccryptolib") in your script to use the module!

Initializing the Random Number Generator

All functions that take secret input may query the library's random generator, ccryptolib.random. CC doesn't have high-quality entropy sources, so instead of hoping for the best like other libraries do, CCryptoLib shifts that burden into you!

Initializing using a Trusted Web Source

If you trust the tmpim Krist node, you can fetch a socket token and use it for initialization:

local crypto = require("ccryptolib")

-- Fetch a WebSocket token.
local postHandle = assert(http.post("https://krist.dev/ws/start", ""))
local data = textutils.unserializeJSON(postHandle.readAll())
postHandle.close()

-- Initialize the generator using the given URL.
crypto.random.init(data.url)

-- Be polite and actually open the socket too.
http.websocket(data.url).close()

Initializing using VM Instruction Counting

As of v1.2.0, you can also initialize the generator using VM instruction timing noise. See the random.initWithTiming method for security risks of taking this approach.

local crypto = require("ccryptolib")
crypto.random.initWithTiming()