Skip to content

Instantly share code, notes, and snippets.

@davidp94
davidp94 / snarktest.solidity
Created October 14, 2017 01:15 — forked from chriseth/snarktest.solidity
zkSNARKs test code
// This file is MIT Licensed.
//
// Copyright 2017 Christian Reitwiessner
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
// The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF O
@davidp94
davidp94 / generate_secp256k1.py
Created March 20, 2018 11:50
generate secp256k1 and print in hex string
# might require pip install ecdsa
from ecdsa import SigningKey, SECP256k1
sk = SigningKey.generate(curve=SECP256k1) # uses SECP256k1
vk = sk.get_verifying_key()
print('This is the secret key {} \nThis is the public key {}'.format(sk.to_string().hex(), vk.to_string().hex()))
@davidp94
davidp94 / generate_rsa_3072.py
Created March 20, 2018 13:07
Generate RSA 3072 bits public keys and private keys python with cryptography package and print them in PEM/PKCS format
from cryptography.hazmat.primitives import serialization as crypto_serialization
from cryptography.hazmat.primitives.asymmetric import rsa
from cryptography.hazmat.backends import default_backend as crypto_default_backend
key = rsa.generate_private_key(
backend=crypto_default_backend(),
public_exponent=65537,
key_size=3072
)
private_key = key.private_bytes(
sudo apt-get update
sudo apt-get install golang-go -y
wget https://dist.ipfs.io/go-ipfs/v0.4.15/go-ipfs_v0.4.15_linux-386.tar.gz
tar xvfz go-ipfs_v0.4.15_linux-386.tar.gz
sudo mv go-ipfs/ipfs /usr/local/bin/ipfs
curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
sudo apt-get install -y nodejs
@davidp94
davidp94 / check_permissions_s3.py
Created July 6, 2018 09:52
Check read only and read-write permissions on S3 bucket
import boto3, botocore
BUCKET_NAME = ''
READ_ONLY_ID = ''
READ_ONLY_KEY = ''
RW_ID = ''
RW_KEY = ''
# List objects in an Amazon S3 bucket
# http://boto3.readthedocs.io/en/latest/reference/services/s3.html#id209
@davidp94
davidp94 / metamask_js_call_console_sign.js
Created August 14, 2018 14:20
Call Metamask to sign random data from web developers console
web3.eth.sign(web3.toChecksumAddress(web3.eth.accounts[0]), web3.sha3("hello this is a message to be signed"), console.log)
@davidp94
davidp94 / metamask_signing_form.html
Created August 14, 2018 15:55
Metamask signing form
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<!--
Created using JS Bin
http://jsbin.com
Copyright (c) 2018 by anonymous (http://jsbin.com/fovamotoca/2/edit)
@davidp94
davidp94 / gist:e32bd9f51a6cc34ba303713cb557b358
Created October 3, 2018 19:59
remove untagged images docker
docker rmi $(docker images -a | grep "^<none>" | awk '{print $3}')
@davidp94
davidp94 / borromean.py
Created February 8, 2019 09:18 — forked from badmofo/borromean.py
Pure Python Borromean Ring Signatures
'''
Pure Python Borromean Ring Signatures
DEPENDS ON: pip install ecdsa
WARNING: THIS IS A PEDAGOGICAL IMPLEMENTATION.
PERFORMANCE IS HORRIBLE AND NON-CONSTANT.
CORNER CASES ARE NOT PROPERLY CHECKED.
FOR THE LOVE OF GOD USE THE CODE FROM THE ELEMENTS PROJECT.
https://gist.github.com/badmofo/2d6e66630e4a6748edb7
'''
from hashlib import sha256