Here are the different ways of creating an algebraic datatype or a tagged value.
type Type = 'A' | 'B';
type Value = any;
type ADTTuple = [Type, Value];
type ADTNamed = { type: Type } & {};
{"payload":"eyJpYXQiOjE3MTgxNTI1NTUsImlzcyI6InZjajN1ZnVuMjUwNmpuNDRxN3JyOWJjMWh2NGM2ZWViaWN1c2ZqMWJsOXNyMjdvb2trbmxnIiwianRpIjoidjBwajh0bGxuZWhvMDE2OWh2N3ZiaDJnMzlvIiwibmJmIjoxNzE4MTUyNTU1LCJwcmV2Q2xhaW1JZCI6InYwcGhrbHI4Nzl0bzAxNjlodjd2YmgyZzM5byIsInByZXZEaWdlc3QiOiJ6MkRyamdiSnJadkxIMWgzMTlMclVNa2dlUVk0RFhyQUdNWHdab1JaYWV6QzRtcTRuTlAiLCJzZXEiOjIsInN1YiI6IltcImdpdGh1Yi5jb21cIixcIkNNQ0RyYWdvbmthaVwiXSIsInR5cCI6IkNsYWltTGlua0lkZW50aXR5In0","signatures":[{"protected":"eyJhbGciOiJFZERTQSIsImtpZCI6InZjajN1ZnVuMjUwNmpuNDRxN3JyOWJjMWh2NGM2ZWViaWN1c2ZqMWJsOXNyMjdvb2trbmxnIn0","signature":"AO2W5oPHUNBqlOTnLlGjnxMNLD7N8U6hkuq-bZATyiul6Rt5uK9azDQ9gXEylqYK-2JjaAlJAcZroPEmSNyXDw"}]} |
{"payload":"eyJpYXQiOjE3MTQ3Mjg2NTYsImlzcyI6InZjajN1ZnVuMjUwNmpuNDRxN3JyOWJjMWh2NGM2ZWViaWN1c2ZqMWJsOXNyMjdvb2trbmxnIiwianRpIjoidjBwaGtscjg3OXRvMDE2OWh2N3ZiaDJnMzlvIiwibmJmIjoxNzE0NzI4NjU2LCJwcmV2Q2xhaW1JZCI6bnVsbCwicHJldkRpZ2VzdCI6bnVsbCwic2VxIjoxLCJzdWIiOiJbXCJnaXRodWIuY29tXCIsXCJDTUNEcmFnb25rYWlcIl0iLCJ0eXAiOiJDbGFpbUxpbmtJZGVudGl0eSJ9","signatures":[{"protected":"eyJhbGciOiJFZERTQSIsImtpZCI6InZjajN1ZnVuMjUwNmpuNDRxN3JyOWJjMWh2NGM2ZWViaWN1c2ZqMWJsOXNyMjdvb2trbmxnIn0","signature":"9adrpi7MkQ31P3-rzNCrfRdy-AHsz_o1NH1te6PsUX-RNNVqx3PHmtUV8POzGTrUr4OIHRjUa0qFC4Uiakg7CQ"}]} |
// Extracted from https://github.com/paulmillr/noble-ed25519/blob/main/index.ts | |
// This is a minimal implementation of taking a 32 byte (256 bit) private key and deriving the public key | |
const hashed = await crypto.subtle.digest('SHA-512', privateKey); // data is Uint8Array or ArrayBuffer | |
type Bytes = Uint8Array; | |
const head = hashed.slice(0, 32); // slice creates a copy, unlike subarray | |
head[0] &= 248; // Clamp bits: 0b1111_1000, | |
head[31] &= 127; // 0b0111_1111, | |
head[31] |= 64; // 0b0100_0000 | |
const mod = (a: bigint, b = P) => { let r = a % b; return r >= 0n ? r : b + r; }; // mod division |
You can download Windows VM from https://developer.microsoft.com/en-us/windows/downloads/virtual-machines/.
After importing OVA, to run it, you need to change Display settings to be:
Enable 3D Acceleration
Otherwise you'll enter a boot-loop.
nmcli device wifi connect 'CapitalOneCafe'
Then visit: https://retailwifi.capitalone.com/ on Firefox.
Then click on the Connect to free WiFi
.
// I've deliberately named this `forP_` becaus it matches Haskell's `forP_` too | |
function forP_<T, P extends PromiseLike<void> = Promise<void>>( | |
items: readonly T[], | |
f: (item: T) => PromiseLike<void>, | |
seed?: P | |
): P { | |
return items.reduce((pChain, item) => { | |
return pChain.then(() => f(item)); | |
}, seed ?? Promise.resolve()) as P; |
import type { JsonWebKey } from 'crypto'; | |
import crypto from 'crypto'; | |
/** | |
* Generates equivalent to RSASSA-PKCS1-v1_5 keypair | |
*/ | |
async function generateKeyPairRSA(): Promise<{ | |
publicKey: JsonWebKey, | |
privateKey: JsonWebKey | |
}> { |
It's the relationship between entities that allow them to co-operate with each other.
For trust to be required, there must be vulnerability, as in chance that the counter party might cheat.
At the same time, for trust to exist, one must believe that the counter party has an incentive to co-operate instead of cheating.
If there is no vulnerability, there is no need for trust.