Skip to content

Instantly share code, notes, and snippets.

View elmariachi111's full-sized avatar
🦜
meow

Stefan Adolf elmariachi111

🦜
meow
View GitHub Profile
If you need to auth against Nillion using an external wallet (and not a keypair), e.g. Privy / Metamask, you have several options. Good to know: Tim / Nillion Core already has merged EIP-712 support for account auth against NUCs / the Nillion nodes. This will solve *a lot* that I built customly.
Here's the approach that I built at https://welshare.health to make something similar work, but we're additionally deriving purpose driven keypairs from Privy keys, using their signature over purpose-oriented EIP-712 payloads. Here's our docs: https://docs.welshare.app/basics/key-management. We're caching the private keys ephemerally on the user's client. This might change, as `did:nil` seems to be deprecated and replaced with the well understood did:key method soon (ask Nillion for reasoning, I'm just a "client" here ;) )
If you feel adventurous, Privy actually *can* sign raw data, that would imo also work for other ecdsa / secp256 based chains (like Cosmos): https://docs.privy.io/wallets/using-wallets/other-chains
@elmariachi111
elmariachi111 / skincare.questionnaire.json
Created September 21, 2025 08:21
A fhir questionnaire that captures base properties for skin care research
{
"resourceType": "Questionnaire",
"id": "dermadao-skin-care-assessment-v1",
"version": "1.0.0",
"name": "SkinCareAssessmentQuestionnaire",
"title": "Skin Care Assessment Questionnaire",
"status": "active",
"experimental": false,
"date": "2025-09-15T00:00:00Z",
"publisher": "DermaDAO",
@elmariachi111
elmariachi111 / findrisc-loinc.json
Created August 25, 2025 08:24
loinc's findrisc fhir spec
{
"resourceType": "Questionnaire",
"id": "97055-8",
"meta": {
"versionId": "9",
"lastUpdated": "2025-02-26T20:49:17.503+00:00",
"source": "#e6hBXlNCA3ym4tDd"
},
"url": "http://loinc.org/q/97055-8",
"name": "FINDRISC_pnl_FINDRISC",
@elmariachi111
elmariachi111 / nil.js
Last active July 24, 2025 18:57
secp256k1 signature verification
import { secp256k1 } from "@noble/curves/secp256k1";
import { sha256 } from "@noble/hashes/sha2";
import { bytesToHex } from "@noble/hashes/utils";
import { toHex } from "viem";
// this is some public address, which deals as the message to be signed
const ADDRESS = "0x70997970c51812dc3a010c7d01b50e0d17dc79c8";
/**
* this is nillion's implemenation of the sign function
@elmariachi111
elmariachi111 / lit.ts
Last active June 5, 2025 08:29
Lit capacity credit delegation & session sig creation
import {
createSiweMessage,
generateAuthSig,
LitAbility,
LitAccessControlConditionResource,
newSessionCapabilityObject,
type AuthSig,
} from '@lit-protocol/auth-helpers'
import {
decryptToFile,
@elmariachi111
elmariachi111 / blind_attestation.md
Created June 2, 2025 13:13
blinded proof of participation

Proof of Study Participation

We enable users to prove that they participated in a clinical trial / study without the conducting service or company (RH) being aware of the "crypto" aspect of their user identity. On the other hand, the prover (us) shouldn't learn anything about the actual user. Welshare's protocol also neither publicy correlates any user ids or personally idenitifiable information.

To enable this blindfolded proof issuance, we require minimal action on the service company's (RH) side. To initiate the proof creation process, they must be able to

  • identify one user by an unique identifier (UID) that can be unique for a trial instance
  • store a random array of bytes ("nonce") per user, ideally using a crypograpically sufficiently safe RNG. The nonce helps deidentifying the user
  • display the UID & the indidual nonce to the user / allow them to request it
  • invite study participants by their preferred means of communication to a decentralized web application, hosted by welshare
@elmariachi111
elmariachi111 / predictL2Address.test.ts
Created May 16, 2025 15:57
predict ERC20 address on L2 when deployed via OptimismMintableERC20Factory
import { base, baseSepolia } from 'viem/chains'
import { describe, expect, it } from 'vitest'
import { predictL2TokenAddress } from './predictL2Address'
describe('Predict L2 Token Addresses', () => {
it('[BASE SEPOLIA] can predict an ERC20 token address created by the standard bridge on Base Sepolia', async () => {
expect.hasAssertions()
const expectedAddress = '0xDa8Df672aCfa4Ee1be95FBC1c2e0FA97d49F7BDe'
@elmariachi111
elmariachi111 / gase_price.1m.py
Created November 14, 2024 20:51
read gas price from etherscan
#!/usr/bin/env python3
import requests
import os
def get_gas_price():
"""
Gets current gas price using the Etherscan API
Returns price in gwei
"""
@elmariachi111
elmariachi111 / LaunchPage.tsx
Created August 28, 2024 20:19
smart contract wallet transaction preparation for Catalyst V2 spawns (Alchemy Account Kit & Gas Policiues / Privy Signer)
import { Button, Flex, Text, useToast } from '@chakra-ui/react'
import { useOnChange } from '@moleculexyz/common'
import { usePrivy } from '@privy-io/react-auth'
import { useRouter } from 'next/router'
import { useCallback, useMemo, useState } from 'react'
import { Address, Chain } from 'viem'
import { Alert } from '@/components/atoms/Alert'
import { BackButton } from '@/components/atoms/BackButton'
import { ContinueButton } from '@/components/atoms/ContinueButton'
export const DEFAULT_CACHE_SECONDS = 15
/**
* We're **not** using upstash or the Vercel KV SDK here to avoid package conflicts
* instead we're using vercel KV's REST API directly: https://vercel.com/docs/storage/vercel-kv/rest-api
*/
const createClient = <T>({ token, url }: { token: string; url: string }) => {
return {
get: async (key: string): Promise<T | null> => {
const result = await (