Skip to content

Instantly share code, notes, and snippets.

@tychobrailleur
tychobrailleur / index.js
Created September 21, 2024 16:54
node-seal example
// https://github.com/s0l0ist/node-seal/blob/main/FULL-EXAMPLE.md
// https://github.com/s0l0ist/node-seal/blob/main/USAGE.md
// See also https://inferati.com/blog/fhe-schemes-bfv
;(async () => {
const SEAL = require('node-seal')
const seal = await SEAL()
const schemeType = seal.SchemeType.bgv
const securityLevel = seal.SecurityLevel.tc128
const polyModulusDegree = 4096
@tychobrailleur
tychobrailleur / gist:103b0ca90461ac8971c627819a06a3c1
Created June 29, 2022 10:41
Kernel config file for Raspberry Pi QEMU image to run Docker (hopefully)
#
# Automatically generated file; DO NOT EDIT.
# Buildroot 2022.02.3 Configuration
#
BR2_HAVE_DOT_CONFIG=y
BR2_HOST_GCC_AT_LEAST_4_9=y
BR2_HOST_GCC_AT_LEAST_5=y
BR2_HOST_GCC_AT_LEAST_6=y
BR2_HOST_GCC_AT_LEAST_7=y
BR2_HOST_GCC_AT_LEAST_8=y
@tychobrailleur
tychobrailleur / mydes.erl
Created March 13, 2022 15:48
Shows DES complementation property
-module(mydes).
-export([test/0, complement/1]).
complement(<<>>) ->
<<>>;
complement(<<1:1, Rest/bitstring>>) ->
Complement = complement(Rest),
<<0:1, Complement/bitstring>>;
(ns chan_hash)
(import '[org.apache.commons.codec.binary Hex])
(import '[java.nio ByteBuffer])
(require '[clojure.core.async :as async :refer [chan go >! <! pipeline go-loop <!!]])
(def sha256-digest (java.security.MessageDigest/getInstance "SHA-256"))
(defn hexify [bb]
(Hex/encodeHexString bb))
const bcrypt = require('bcrypt');
const saltRounds = 12;
const myPassword = "password";
bcrypt.genSalt(saltRounds, function(err, salt) {
bcrypt.hash(myPassword, salt, function(err, hash) {
console.log("Hash: " + hash);
// Store hash in your password DB.
});
});
@tychobrailleur
tychobrailleur / des.py
Created September 30, 2021 19:56
Weak key
from Crypto.Cipher import DES
from bitarray import *
def int_to_nibble(i):
bnr = bin(i).replace('0b','')
x = bnr[::-1]
while len(x) < 4:
x += '0'
bnr = x[::-1]
return bnr
@tychobrailleur
tychobrailleur / my-script.bash
Created September 27, 2021 16:58
Experiment with env variables in bash
#!/usr/bin/env bash
# Call script with:
# VAL=pouet ./my-script.bash
var_val="${VAL}"
echo ${var_val}
output="$(
echo "[${VAL}]"
@tychobrailleur
tychobrailleur / TreeExample.java
Created February 24, 2021 19:41
NPE with darklaf when using a custom `TreeCellRenderer`
package com.weblogism.darklaf;
import com.github.weisj.darklaf.LafManager;
import com.github.weisj.darklaf.theme.DarculaTheme;
import javax.swing.*;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.TreeCellRenderer;
import java.awt.*;
@tychobrailleur
tychobrailleur / BLS_Signature.md
Created September 6, 2020 16:52
BLS Signature for Busy People

BLS Signature for Busy People

Summary

  • BLS stands for

    • Barreto-Lynn-Scott: BLS12, a Pairing Friendly Elliptic Curve.
    • Boneh-Lynn-Shacham: A Signature Scheme.
  • Signature Aggregation

  • It is possible to verify n aggregate signatures on the same message with just 2 pairings instead of n+1.

diff --git a/build.gradle b/build.gradle
index ce4ed682..2afa9261 100644
--- a/build.gradle
+++ b/build.gradle
@@ -169,6 +169,9 @@ ospackage {
from(jar.outputs.files) {
into 'lib\\ho'
}
+ from(configurations.runtime) {
+ into 'lib\\ho'