Skip to content

Instantly share code, notes, and snippets.

Dmitry Chestnykh dchest

Block or report user

Report or block dchest

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@dchest
dchest / utils.js
Last active Aug 2, 2019
Short Utils
View utils.js
// String ranges: strange('A-Za-z0-9+/') -> "ABCDEFGHIJKLMNOPQRSTUVWXYabcdefghijklmnopqrstuvwxy012345678+/"
const strange = s => s.replace(/(.)-(.)/g, (_, x, y) => { for (var i = x.charCodeAt(0) + 1; i < y.charCodeAt(0); i++) x += String.fromCharCode(i); return x })
// Base64 encoding of Uint8Array of ArrayBuffer and decoding to Uint8Array
const encodeBase64 = a => btoa(Array.from(a instanceof ArrayBuffer ? new Uint8Array(a) : a).map(x => String.fromCharCode(x)).join(''));
const encodeBase64url = a => encodeBase64(a).replace(/\+/g, '-').replace(/\//g, '_').replace(/=/g, ''); // no padding
const decodeBase64 = s => Uint8Array.from(atob(s), x => x.charCodeAt(0));
// TODO: decodeBase64url
@dchest
dchest / chrome.md
Last active Jan 16, 2019
How to properly use Chrome
View chrome.md
  1. Install uBlock Origin extension. (If you're not from US, check its options to turn on ad block lists for your country)

  2. Do not install any other extensions ever! (exceptions: 1Password, Google Arts & Culture).

  3. Create separate "people" for different activities: e.g. home, work, browsing sketchy websites. (Click on avatar > Manage People)

  4. If you want to turn on sync, set up encryption passphrase. It's a separate passphrase from your Google account — your sync data will be encrypted locally with it before hitting Google servers.

  5. Disable saving/auto fill of passwords, payment, and addresses. (https://twitter.com/Sc00bzT/status/1085521985017466881)

@dchest
dchest / 3B-Plus.txt
Last active Mar 22, 2018
Raspberry Pi 3B+ and 3B openssl speed (ran just once, likely in different ambient temperature, completely non-scientific)
View 3B-Plus.txt
OpenSSL 1.1.0f 25 May 2017
built on: reproducible build, date unspecified
options:bn(64,32) rc4(char) des(long) aes(partial) blowfish(ptr)
compiler: gcc -DDSO_DLFCN -DHAVE_DLFCN_H -DNDEBUG -DOPENSSL_THREADS -DOPENSSL_NO_STATIC_ENGINE -DOPENSSL_PIC -DOPENSSL_BN_ASM_MONT -DOPENSSL_BN_ASM_GF2m -DSHA1_ASM -DSHA256_ASM -DSHA512_ASM -DAES_ASM -DBSAES_ASM -DGHASH_ASM -DECP_NISTZ256_ASM -DPOLY1305_ASM -DOPENSSLDIR="\"/usr/lib/ssl\"" -DENGINESDIR="\"/usr/lib/arm-linux-gnueabihf/engines-1.1\""
The 'numbers' are in 1000s of bytes per second processed.
type 16 bytes 64 bytes 256 bytes 1024 bytes 8192 bytes 16384 bytes
md2 0.00 0.00 0.00 0.00 0.00 0.00
mdc2 0.00 0.00 0.00 0.00 0.00 0.00
md4 8692.17k 34247.02k 107042.56k 230394.14k 347587.38k 357886.63k
md5 24228.71k 74809.73k 155908.93k 211904.17k 238160.55k 239976.45k
@dchest
dchest / gist:e7d1296911f75b0fb4ad0301173a186f
Last active Jan 2, 2018
NIST PQC submissions by key/signature/encryption size
View gist:e7d1296911f75b0fb4ad0301173a186f
Source: https://groups.google.com/a/list.nist.gov/d/msg/pqc-forum/1lDNio0sKq4/fzAd9fewAAAJ
From: D. J. Bernstein
Compared to Ryo Fujita's table, I would list Giophantus as multivariate,
Lepton as code-based (I see LWE->LPN as crossing the lattices->codes
line), and Mersenne/Ramstake/Three Bears in a separate category. I also
think it's a bit silly for NIST to count (e.g.) two pqRSA submissions.
Another way to categorize submissions is by sizes. This is correlated
View gist:dd3a51ad428c0702675a1f7680ee890b
Analysis of sampling openssl (pid 42557) every 1 millisecond
Process: openssl [42557]
Path: /usr/bin/openssl
Load Address: 0x108287000
Identifier: openssl
Version: 22
Code Type: X86-64
Parent Process: bash [37567]
Date/Time: 2017-10-10 20:17:15.049 +0200
View gist:24a66dd3cd4097f8c15eb16645ec394a
IconSizes | string | gtk-menu=48,48:panel-menu=32,32:panel=16,16:gtk-button=32,32:gtk-large-toolbar=48,48:gtk-small-toolbar=32,32
@dchest
dchest / gimli.js
Last active Jun 2, 2019
Gimli permutation in JavaScript. EXPERIMENTAL VERSION
View gimli.js
/** Gimli permutation - https://gimli.cr.yp.to */
function gimli(s) {
var r, x, y, z,
a = s[ 0] | s[ 1] << 8 | s[ 2] << 16 | s[ 3] << 24,
b = s[ 4] | s[ 5] << 8 | s[ 6] << 16 | s[ 7] << 24,
c = s[ 8] | s[ 9] << 8 | s[10] << 16 | s[11] << 24,
d = s[12] | s[13] << 8 | s[14] << 16 | s[15] << 24,
e = s[16] | s[17] << 8 | s[18] << 16 | s[19] << 24,
f = s[20] | s[21] << 8 | s[22] << 16 | s[23] << 24,
g = s[24] | s[25] << 8 | s[26] << 16 | s[27] << 24,
@dchest
dchest / buzhash.ts
Created Jun 20, 2017
Buzhash with secret key
View buzhash.ts
import { wipe } from "@stablelib/wipe";
/**
* Buzhash implements cyclic polymomial rolling hash function.
* It is a custom developed keyed variant with protections against plain text
* recovery from chunk lengths.
*
* Reading:
*
* http://www.serve.net/buz/Notes.1st.year/HTML/C6/rand.012.html
You can’t perform that action at this time.