Skip to content

Instantly share code, notes, and snippets.

Avatar

Marek marekyggdrasil

View GitHub Profile
@marekyggdrasil
marekyggdrasil / ecc.py
Last active May 25, 2021
Source code and results for the Schnorr signature tutorial available under https://mareknarozniak.com/2021/05/25/schnorr-signature/
View ecc.py
import numpy as np
# ECC addition in R
def eccContAddition(Px, Py, Qx, Qy, a, b):
if np.isclose([Px], [Qx])[0]:
m = (3.*Px**2.+a)/(2.*Py)
else:
m = (Py-Qy)/(Px-Qx)
Rx = m**2 - Px - Qx
@marekyggdrasil
marekyggdrasil / aes.py
Last active Apr 24, 2021
Examples for tutorial on symmetric ciphers available under https://mareknarozniak.com/2021/04/22/symmetric/
View aes.py
from Crypto.Cipher import AES
from getpass import getpass
ciphertext = None
with open('ciphertext3.txt', 'r') as file:
ciphertext = bytes.fromhex(file.read())
password = getpass('Password: ')
key = bytes(password, 'ascii')
key = key + b'\x00'*(16-len(key))
@marekyggdrasil
marekyggdrasil / ecc.py
Last active Mar 16, 2021
Tutorial covering the Eliptic Curve Digital Signature Algorithm (ECDSA) available under https://mareknarozniak.com/2021/03/16/ecdsa/
View ecc.py
import numpy as np
# ECC addition in R
def eccContAddition(Px, Py, Qx, Qy, a, b):
if np.isclose([Px], [Qx])[0]:
m = (3.*Px**2.+a)/(2.*Py)
else:
m = (Py-Qy)/(Px-Qx)
Rx = m**2 - Px - Qx
@marekyggdrasil
marekyggdrasil / distrib.png
Last active Jan 27, 2021
A source code for a probability plots for a trustless Mimblewimble transaction aggregator based on scalable BFT https://mareknarozniak.com/2021/01/27/aggrematon/
@marekyggdrasil
marekyggdrasil / plotting.py
Last active May 8, 2021
Tutorial covering the concept of geometric phase for a qubit, tutorial available under https://mareknarozniak.com/2021/01/09/qubit-berry-phase/
View plotting.py
import matplotlib.pyplot as plt
def plotQubit(angles, refrel, refimag, resrel, resimag, title, x_axis, filename, url=''):
fig, ax = plt.subplots(1, 1, constrained_layout=True)
ax.set_title(title)
x_axis += '\n' + url
ax.set_xlabel(x_axis)
ax.set_ylabel('phase')
@marekyggdrasil
marekyggdrasil / index.js
Last active Dec 10, 2020
node.js example on how to connect to the grin-wallet owner API based on: it is a modified official example from here: https://github.com/mimblewimble/grin-wallet/tree/1ced8990b9e21fa17c788d93a151ec1164ebbce5/doc/samples/v3_api_node
View index.js
/* Sample Code for connecting to the V3 Secure API via Node
*
* With thanks to xiaojay of Niffler Wallet:
* https://github.com/grinfans/Niffler/blob/gw3/src/shared/walletv3.js
*
*/
const http = require('http');
const crypto = require('crypto');
@marekyggdrasil
marekyggdrasil / ecc.py
Last active Jan 11, 2021
Tutorial covering the concept of Elliptic Curve Cryptography and Diffie-Hellman Key Exchange, tutorial available under https://mareknarozniak.com/2020/11/30/ecdh/
View ecc.py
import numpy as np
# ECC addition in R
def eccContAddition(Px, Py, Qx, Qy, a, b):
if np.isclose([Px], [Qx])[0]:
m = (3.*Px**2.+a)/(2.*Py)
else:
m = (Py-Qy)/(Px-Qx)
Rx = m**2 - Px - Qx
@marekyggdrasil
marekyggdrasil / phi1.cnf
Last active Jul 13, 2020
CNF files for online tutorial covering the concept of SAT and boolean satisfiability in general, tutorial available under https://mareknarozniak.com/2020/07/13/satisfiability/
View phi1.cnf
p cnf 3 3
1 -2 3 0
1 2 -3 0
-1 -2 3 0
@marekyggdrasil
marekyggdrasil / diophantine.py
Last active Jun 25, 2020
Code repository for tutorial on constraint programming available on https://mareknarozniak.com/2020/06/22/constraint-programming/
View diophantine.py
from constraint import Problem
problem = Problem()
problem.addVariable('x', range(1, 10))
problem.addVariable('y', range(1, 10))
problem.addVariable('z', range(1, 10))
def constraintCheck(x, y, z):