Skip to content

Instantly share code, notes, and snippets.

View devi's full-sized avatar
⛰️
Off-Grid

Devi Mandiri devi

⛰️
Off-Grid
View GitHub Profile
@devi
devi / KummerScalarmult.js
Created June 2, 2014 13:59
Kummer scalar multiplication for Javascript
/**
* kummer scalar multiplication - ref5
*
* ported from SUPERCOP 20140529
*
* see for details: http://bench.cr.yp.to/supercop.html
*/
var KummerScalarmult = (function() {
/* bitwise dance helper*/
@devi
devi / crypto_hash_sha256.js
Last active August 29, 2015 14:02
sha256
/* crypto_hash - sha256 */
// Written in 2014 by Devi Mandiri. Public domain.
//
// Implementation derived from TweetNaCl version 20140427.
// See for details: http://tweetnacl.cr.yp.to/
//
function load(x, pos) {
return x[pos+3] | (x[pos+2]<<8) | (x[pos+1]<<16) | (x[pos]<<24);
}
@devi
devi / u64.js
Last active August 29, 2015 14:02
helper for dealing with uint64
// helper for dealing with uint64
var u64 = function (h, l) {
h = h|0; l = l|0;
this.hi = h >>> 0;
this.lo = l >>> 0;
}
function new64(num) {
var hi = 0, lo = num >>> 0;
if ((+(Math.abs(num))) >= 1) {
@devi
devi / chacha20.js
Last active July 6, 2016 22:06
chacha20.js
/* chacha20 - 256 bits */
// Written in 2014 by Devi Mandiri. Public domain.
//
// Implementation derived from chacha-ref.c version 20080118
// See for details: http://cr.yp.to/chacha/chacha-20080128.pdf
var Chacha20KeySize = 32;
var Chacha20NonceSize = 8;
@devi
devi / poly1305.js
Last active August 29, 2015 14:02
poly1305.js
/* poly1305 */
// Written in 2014 by Devi Mandiri. Public domain.
//
// Implementation derived from poly1305-donna-16.h
// See for details: https://github.com/floodyberry/poly1305-donna
var Poly1305BlockSize = 16;
var Poly1305Ctx = function() {
@devi
devi / sha512.js
Last active August 29, 2015 14:02
sha512.js
/* sha512 */
// Written in 2014 by Devi Mandiri. Public domain.
//
// Implementation derived from TweetNaCl version 20140427.
// See for details: http://tweetnacl.cr.yp.to/
//
var u64 = function (h, l) {
h = h|0; l = l|0;
this.hi = h >>> 0;
@devi
devi / blake2b.js
Created July 2, 2014 08:49
blake2b.js
(function(exports) {
'use strict';
// Blake2b
// Ported by Devi Mandiri. Public domain.
var u64 = function (h, l) {
h = h|0; l = l|0;
this.hi = h >>> 0;
@devi
devi / keccak.js
Last active August 29, 2015 14:03
keccak.js
// keccak
//
// Implementation derived from https://github.com/floodyberry/scrypt-jane
//
// Ported by Devi Mandiri. Public domain
//
var u64 = function (h, l) {
h = h|0; l = l|0;
this.hi = h >>> 0;
this.lo = l >>> 0;
@devi
devi / keccak-compat.js
Last active August 29, 2015 14:03
keccak-compat.js
// keccak
//
// Implementation derived from https://github.com/floodyberry/scrypt-jane
//
// Ported by Devi Mandiri. Public domain
//
var u64 = function (h, l) {
h = h|0; l = l|0;
this.hi = h >>> 0;
this.lo = l >>> 0;
@devi
devi / multi shape
Last active June 12, 2018 15:46 — forked from eqhmcow/multi shape
#!/bin/bash
# As the "bufferbloat" folks have recently re-discovered and/or more widely
# publicized, congestion avoidance algorithms (such as those found in TCP) do
# a great job of allowing network endpoints to negotiate transfer rates that
# maximize a link's bandwidth usage without unduly penalizing any particular
# stream. This allows bulk transfer streams to use the maximum available
# bandwidth without affecting the latency of non-bulk (e.g. interactive)
# streams.