Skip to content

Instantly share code, notes, and snippets.

@marekyggdrasil
marekyggdrasil / README.md
Last active April 3, 2024 13:59
Playing with AGE (actually good encryption) to try some test vectors from ツ.

This repository contains my simplified AGE (Actually Good Encryption) http://age-encryption.org/v1 heavily based on pyage library.

It's purpose is to demonstrate the fact that GRIN core wallet implementation is producing incorrect HMAC signatures in its AGE-encrypted payloads.

  1. slateage.py contains values implementated by the GRIN core wallet. My code correctly decrypts it only if HMAC verification is ignored. Decrypted payload contains the sender address.
  2. validage.py contains official AGE test vector. My code correctly decrypts it and verifies the HMAC and matches the expected file key. Decrypted payload hash matches the expected value.

Another indicator the GRIN core wallet is producing flawed HMAC signatures is the fact that in grin++ wallet the HMAC verification also had to be commented out.

To run it, first setup

@marekyggdrasil
marekyggdrasil / mcm.py
Created March 13, 2024 09:10
Computing the bong-bing-bang-and-gong number for https://x.com/botnetzprovider/status/1767680709726978051?s=20
def numberToBase(n, b):
if n == 0:
return [0]
digits = []
while n:
digits.append(int(n % b))
n //= b
return digits[::-1]
@marekyggdrasil
marekyggdrasil / plotting.py
Last active January 11, 2024 17:28
Tutorial covering the concept of geometric phase for a qubit, tutorial available under https://mareknarozniak.com/2021/01/09/qubit-berry-phase/
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 / README.md
Created February 4, 2019 09:19
How to fix Ruby TLS support

OSX Sierra version 10.12.6

if you are getting error like

ERROR:  Could not find a valid gem '<some package name>' (>= 0), here is why:
          Unable to download data from https://rubygems.org/ - SSL_connect retur

test your TLS v1.2 support

@marekyggdrasil
marekyggdrasil / diophantine.py
Last active April 17, 2023 00:32
Code repository for tutorial on constraint programming available on https://mareknarozniak.com/2020/06/22/constraint-programming/
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):

This is code repository for Quantum Adiabatic Optimization article.

Start by running instance.py that will build list-based definiton of the graph from its set-based definition, this will let you keep consistent indices between all the runs.

The run.py is the adiabatic optimization code.

Energy spectrum can be examined by running eigenenergies.py with single command line argument being one of HMVC, HMVC_, HMIS or HMIS_. I don't suggest running all the diagonalizations in single run, graphs are big and you are likely to get a segmentation fault error. This is why it is good to keep consistent indices and store your graph using lists and not sets.

You can plot figures using plot.py.

@marekyggdrasil
marekyggdrasil / figures_thumbnail.sh
Last active December 20, 2022 15:33
Example code for the tutorial on Pedersen Commitments and Confidential Transactions available under https://mareknarozniak.com/2021/06/22/ct/
#!/bin/sh
convert -background none inputs_before.png inputs_after.png +append inputs.png
@marekyggdrasil
marekyggdrasil / README.md
Last active December 5, 2022 21:38
MINA zkApp that allows deposits and withdrawals

A very simple zkApp that allows user to deposit and withdraw. Run it with

node --experimental-vm-modules --experimental-wasm-modules --experimental-wasm-threads node_modules/jest/bin/jest.js -- fakemac.test.ts
@marekyggdrasil
marekyggdrasil / run.py
Last active November 24, 2022 17:29
Simulation of the 1D Tight-Binding Model, full tutorial https://mareknarozniak.com/2020/05/07/tight-binding/
import matplotlib.pyplot as plt
import numpy as np
from qutip import basis
def _ket(n, N):
return basis(N, n)
def _bra(n, N):
@marekyggdrasil
marekyggdrasil / example.pl
Created August 18, 2022 12:42
how to use class decorators with arguments in Python
from functools import wraps
class ForbiddenDrink:
def __init__(self, drinks):
self.do_not_drink_that = drinks
def __call__(self, func):
@wraps(func)
def wrapper(*args, **kwargs):
innerself = args[0]