Skip to content

Instantly share code, notes, and snippets.

View lucashenning's full-sized avatar
🌴
Miami

Lucas H. lucashenning

🌴
Miami
View GitHub Profile
@lucashenning
lucashenning / ecdsa-sig-parse.ts
Created November 3, 2020 12:27
Parse a ASN1 DER encoded Sig with ASN1.js
const EcdsaSigAsnParse = asn1.define('EcdsaSig', function(this: any) {
this.seq().obj(
this.key('r').int(),
this.key('s').int(),
);
});
@lucashenning
lucashenning / 01_install_libs.sh
Created September 6, 2022 23:06
Postdeploy platform hook for puppeteer on Amazon Linux 2 (Elastic Beanstalk)
#!/bin/bash
# Put this in your Amazon Elastic Beanstalk repo
# Tested on Amazon Linux 2, Node.JS v16, puppeteer v15.3.0
# File path: .platform/hooks/postdeploy/01_install_libs.sh
sudo amazon-linux-extras install epel -y
cd node_modules/puppeteer/
cd .local-chromium/linux-*/chrome-linux
@lucashenning
lucashenning / SocialLock_withdraw.sol
Created March 31, 2023 16:28
withdraw function in socialLock.sol
function withdraw(string memory headerJson, string memory payloadJson, bytes memory signature, uint amount) public {
// validate JWT
string memory email = validateJwt(headerJson, payloadJson, signature);
bytes32 emailHash = keccak256(abi.encodePacked(email));
// balance check
// this uses the email address from the Google JWT to check if there is a balance for this email
require(balances[emailHash] > 0, "No balance for this email");
require(balances[emailHash] >= amount, "Not enough balance for this email");