Skip to content

Instantly share code, notes, and snippets.

@blmalone
blmalone / ReceiveFallback.sol
Created November 8, 2022 13:35
Receive & Fallback
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.13;
contract ReceiveFallback {
event Log(string func, uint value, address sender, bytes data);
fallback() external payable {
emit Log("fallback", msg.value, msg.sender, msg.data);
}
@blmalone
blmalone / curl-protected-resources.sh
Created February 1, 2021 17:40
Example Curl Command to Access protected AWS resources
curl -H "x-api-key: <api_gateway_api_key>" -H "Authorization: <google_jwt_token>" https://<api_gateway_uri>/prod/example/1
@blmalone
blmalone / index.html
Created January 30, 2021 00:11
Sample Google Website Sign-In - Token retrieval
<html lang="en">
<head>
<meta name="google-signin-scope" content="email" />
<meta
name="google-signin-client_id"
content="enter_google_client_id_here"
/>
<script src="https://apis.google.com/js/platform.js" async defer></script>
</head>
<body>
@blmalone
blmalone / google-authorizer.ts
Last active April 21, 2021 14:23
Google Token Authorizer
import { OAuth2Client } from "google-auth-library";
/**
* Unique client ID for application.
*/
const CLIENT_ID: string = process.env.GOOGLE_CLIENT_ID as string;
export const handler = async (event: any, _: any, callback: any) => {
const token = event.authorizationToken;
return verify(token, event);
@blmalone
blmalone / aws-cdk-secured-api.ts
Last active June 10, 2021 19:26
Secure AWS API Gateway with Google using Custom Authorizers
import * as lambda from "@aws-cdk/aws-lambda";
import * as cdk from "@aws-cdk/core";
import * as apigw from "@aws-cdk/aws-apigateway";
import { TokenAuthorizer } from "@aws-cdk/aws-apigateway";
export class CdkExampleStack extends cdk.Stack {
constructor(
scope: cdk.App,
id: string,
props?: cdk.StackProps
Order of secp256k1 curve: fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141
### MASTER KEY DERIVATION ###
Master Private Key: e8f32e723decf4051aefac8e2c93c9c5b214313817cdb01a1494b917c8436b35 (Alice's parent private key)
Master Public Key: 0439a36013301597daef41fbe593a02cc513d0b55527ec2df1050e2e8ff49c85c23cbe7ded0e7ce6a594896b8f62888fdbc5c8821305e2ea42bf01e37300116281
Master Compressed Public Key: 0339a36013301597daef41fbe593a02cc513d0b55527ec2df1050e2e8ff49c85c2
Master Chain Code: 873dff81c02f525623fd1fe5167eac3a55a049de3d314bb42ee227ffed37d508 (Alice's parent chain code)
### HARDENED DERIVATION ###
@blmalone
blmalone / extended_key.ts
Last active November 11, 2022 03:10
Creating an extended private key from bip32 test vector
import { algo, enc } from 'crypto-js';
import { ec as EC } from "elliptic";
import * as bs58check from "bs58check";
const ec = new EC("secp256k1");
const TEST_VECTOR_1_SEED = "000102030405060708090a0b0c0d0e0f";
const MASTER_KEY_DERIVATION_KEY = "Bitcoin seed";
const mainnetVersionBytesPriv = "0488ADE4";
const mainnetVersionBytesPub = "0488B21E";