Skip to content

Instantly share code, notes, and snippets.

View arnabmitra's full-sized avatar
🙈

Arnab Mitra arnabmitra

🙈
View GitHub Profile
@arnabmitra
arnabmitra / exposed-tricks.kt
Created June 14, 2021 04:35 — forked from bastman/exposed-tricks.kt
exposed tricks
# =========
# demo: https://github.com/JetBrains/Exposed/tree/master/src/test/kotlin/demo
# dml tests: https://github.com/JetBrains/Exposed/blob/master/src/test/kotlin/org/jetbrains/exposed/sql/tests/shared/DMLTests.kt
# ===== GIS
https://github.com/JetBrains/Exposed/issues/459
# === native
P2PKH(1), // pay to pubkey hash (aka pay to address)
P2PK(2), // pay to pubkey
P2SH(3), // pay to script hash
P2WPKH(4), // pay to witness pubkey hash
P2WSH(5); // pay to witness script hash
Native SegWit Bech32 uses the SegWit technology (segregated witness)
developed around 5 years ago. This is now the standard.
BIP32 - is a method for generating a tree of private keys from a master private key.
BIP39 - is a method for encoding 128-256 bits of random data into 12-24 word phrases from a list of interchangeable 2018 words, and then turn those phrases into a 64-byte hash.
BIP44 - is a method for structuring a private key tree in a specific way that will facilitate usage/restoration/discovery of multiple accounts for multiple purposes.
@arnabmitra
arnabmitra / 00_README.md
Created May 26, 2021 20:20 — forked from reagent/00_README.md
Custom HTTP Routing in Go

Custom HTTP Routing in Go

Basic Routing

Responding to requests via simple route matching is built in to Go's net/http standard library package. Just register the path prefixes and callbacks you want invoked and then call the ListenAndServe to have the default request handler invoked on each request. For example:

package main

import (
classDiagram
class baseContract
class instance1
class instance2
class instance3
class API
baseContract <|.. base
base <|-- instance1
base &lt;|-- instance2
Essentially, a hardened child key is is computed with hash(parent private key + index), whereas a non-hardened child key is computed with hash(parent public key + index).
So what practical consequences does this have?
With an extended public key, you can derive non-hardened child public keys. This is useful in situations where you want to accept payments without immediately being able to spend them. For example, if you had a website selling alpaca socks, your server could use an extended public key to accept payments without losing all of your money if it got hacked. So that's a reason why you might use non-hardened derivation.
With an extended private key, you can also derive hardened keys.
However, non-hardened public keys are weaker when an attacker has 1) the extended public key and 2) one of the non-hardened private keys that was derived from it. In that circumstance, the attacker can work out the private key of the extended public key, and therefore get every key that can be derived from that, harde
suspend inline fun <T, R> T.letInCoroutine(
crossinline block: suspend CoroutineScope.(T) -> R
): R = coroutineScope {
block(this@letInCoroutine)
}
suspend inline fun scheduleRepeating(
startFrom: ZonedDateTime,
schedule: Schedule,

Keybase proof

I hereby claim:

  • I am arnabmitra on github.
  • I am amitra (https://keybase.io/amitra) on keybase.
  • I have a public key ASDNt9mi-9DAeSlGieLN6_DQQCh_zo0CVxJqFDoOU4WoyQo

To claim this, I am signing this object:

DER
The Distinguished Encoding Rules (DER) format is used to encode ECDSA signatures in Bitcoin. An ECDSA signature is generated using a private key and a hash of the signed message. It consists of two 32-byte numbers (r,s). As described by Pieter here the DER signature format has six components:
0x30 byte: header byte to indicate compound structure
one byte to encode the length of the following data
0x02: header byte indicating an integer
the r value as a big-endian integer
0x02: header byte indicating an integer
the s value as a big-endian integer
Note that the r and s value must be prepended with 0x00 if their first byte is greater than 0x7F. This causes variable signature lengths in the case that the r value is in the upper half of the range (referred to as "high r"). Signatures with high s values are non-standard and usually don't appear in the wild. Also note that in rare cases r or s can be shorter than 32 bytes which is legal and leads to shorter signatures.
https://crypto.stackexchange.com/questions/18105/how-does-recovering-the-public-key-from-an-ecdsa-signature-work
https://stackoverflow.com/questions/30445997/loading-raw-64-byte-long-ecdsa-public-key-in-java
https://stackoverflow.com/questions/19665491/how-do-i-get-an-ecdsa-public-key-from-just-a-bitcoin-signature-sec1-4-1-6-k