We will use the following terms:
pk is public key
sk is private key (secret key)
H is hash function
sig is message signature
m is plain-text message
function hashCrypt(key, plain, hasher, workFactor=1) { // hasher is any sync string-output hash function | |
var len=plain.length, keyLen = key.length, keyOrig = key, | |
// calculate derivation count based on deterministic factors from the inputs: | |
mx = hasher(key).split("").map((a, b)=> a.charCodeAt(0) + b).reduce((a, b)=> a + b, 0) * workFactor; | |
// derive firstly for some hardness using cpu and ram hungry calculations: | |
for(let i = 0; i < mx; i++) key = hasher(key.repeat( ((i+len) % ((workFactor || 1) * 4))+1 )); | |
// expand key to needed length by appending re-hashing (with counters): |
Digital cryptography! This is a subject I've been interested in since taking a class with Prof. Fred Schneider back in college. Articles pop up on Hacker News fairly often that pique my interest and this technique is the result of one of them.
Specifically, this is about Lamport signatures. There are many signature algorithms (ECDSA and RSA are the most commonly used) but Lamport signatures are unique because they are formed using a hash function. Many cryptographers believe that this makes them resistant to attacks made possible by quantum computers.
LOVE_BIN=/usr/bin/love | |
LOVE_DIR=./src/love | |
DIST_DIR=./src/dist | |
PATCH_DIR=./src/patch | |
BUILD_DIR=./build | |
BIN_DIR=./bin | |
LOVE_VERSION=0.9.1 | |
GAME_NAME=MySampleGame | |
PRETTY_NAME=My Sample Game |
Not all random values are created equal - for security-related code, you need a specific kind of random value.
A summary of this article, if you don't want to read the entire thing:
Math.random()
. There are extremely few cases where Math.random()
is the right answer. Don't use it, unless you've read this entire article, and determined that it's necessary for your case.crypto.getRandomBytes
directly. While it's a CSPRNG, it's easy to bias the result when 'transforming' it, such that the output becomes more predictable.uuid
, specifically the uuid.v4()
method. Avoid node-uuid
- it's not the same package, and doesn't produce reliably secure random values.random-number-csprng
.You should seriously consider reading the entire article, though - it's
Now that we live in the Big Data, Web 3.14159 era, lots of people want to build databases that are too big to fit on a single machine. But there's a problem in the form of the CAP theorem, which states that if your network ever partitions (a machine goes down, or part of the network loses its connection to the rest) then you can keep consistency (all machines return the same answer to
common category:
category of categories:
module Ownership ( ) : sig | |
type owner | |
type ('owner, 'value) owned = private 'value | |
val acquire : 'value -> (owner, 'value) owned | |
val release : (owner, 'value) owned -> 'value | |
end = struct | |
type owner = unit | |
type ('owner, 'value) owned = 'value |
import scala.language.implicitConversions | |
class Unknown (value : Any) { | |
def coercion[ Type ] : Type = | |
value.asInstanceOf[ Type ] | |
} | |
implicit def promotion[ Type ] (value : Type) : Unknown = | |
new Unknown (value) |
local export = { } | |
local weakkey = { __mode = 'k' } | |
local updated = setmetatable ({ }, weakkey) | |
local clones = setmetatable ({ }, weakkey) | |
local prototype = setmetatable ({ }, weakkey) | |
local proxy = setmetatable ({ }, weakkey) | |
local metatable = { } | |
-- we use the `prototype` relation for indexing -- | |
-- propagation while the `clones` relation -- |