Skip to content

Instantly share code, notes, and snippets.

View webmaster128's full-sized avatar

Simon Warta webmaster128

View GitHub Profile
@webmaster128
webmaster128 / output.txt
Last active November 17, 2023 08:00
secp256k1 recover public key ("ecrecover") test vectors generated using CosmJS
recovery param: 1
message: 5c868fedb8026979ebd26f1ba07c27eedf4ff6d10443505a96ecaf21ba8c4f0937b3cd23ffdc3dd429d4cd1905fb8dbcceeff1350020e18b58d2ba70887baa3a9b783ad30d3fbf210331cdd7df8d77defa398cdacdfc2e359c7ba4cae46bb74401deb417f8b912a1aa966aeeba9c39c7dd22479ae2b30719dca2f2206c5eb4b7
messageHash (sha256): 5ae8317d34d1e595e3fa7247db80c0af4320cce1116de187f8f7e2e099c0d8d0
signature: 45c0b7f8c09a9e1f1cea0c25785594427b6bf8f9f878a8af0b1abbb48e16d0920d8becd0c220f67c51217eecfd7184ef0732481c843857e6bc7fc095c4f6b78801
pubkey: 044a071e8a6e10aada2b8cf39fa3b5fb3400b04e99ea8ae64ceea1a977dbeaf5d5f8c8fbd10b71ab14cd561f7df8eb6da50f8a8d81ba564342244d26d1d4211595
pubkey compressed: 034a071e8a6e10aada2b8cf39fa3b5fb3400b04e99ea8ae64ceea1a977dbeaf5d5
recovery param: 1
message: 17cd4a74d724d55355b6fb2b0759ca095298e3fd1856b87ca1cb2df5409058022736d21be071d820b16dfc441be97fbcea5df787edc886e759475469e2128b22f26b82ca993be6695ab190e673285d561d3b6d42fcc1edd6d12db12dcda0823e9d6079e7bc5ff54cd452dad308d52a15ce9c7edd6ef3dad6a27becd8e001e80f
m
@webmaster128
webmaster128 / secp256k1_tests.json
Last active February 1, 2021 12:36
Test vectors from https://github.com/cosmos/cosmjs/blob/v0.24.0-alpha.22/packages/crypto/src/secp256k1.spec.ts#L195-L394. prehash = sha256(message); pubkey is uncompressed; signature is fixed length 2x32 bytes r, s.
[
{
"message": "5c868fedb8026979ebd26f1ba07c27eedf4ff6d10443505a96ecaf21ba8c4f0937b3cd23ffdc3dd429d4cd1905fb8dbcceeff1350020e18b58d2ba70887baa3a9b783ad30d3fbf210331cdd7df8d77defa398cdacdfc2e359c7ba4cae46bb74401deb417f8b912a1aa966aeeba9c39c7dd22479ae2b30719dca2f2206c5eb4b7",
"message_hash": "5ae8317d34d1e595e3fa7247db80c0af4320cce1116de187f8f7e2e099c0d8d0",
"signature": "207082eb2c3dfa0b454e0906051270ba4074ac93760ba9e7110cd9471475111151eb0dbbc9920e72146fb564f99d039802bf6ef2561446eb126ef364d21ee9c4",
"pubkey": "04051c1ee2190ecfb174bfe4f90763f2b4ff7517b70a2aec1876ebcfd644c4633fb03f3cfbd94b1f376e34592d9d41ccaf640bb751b00a1fadeb0c01157769eb73"
},
{
"message": "17cd4a74d724d55355b6fb2b0759ca095298e3fd1856b87ca1cb2df5409058022736d21be071d820b16dfc441be97fbcea5df787edc886e759475469e2128b22f26b82ca993be6695ab190e673285d561d3b6d42fcc1edd6d12db12dcda0823e9d6079e7bc5ff54cd452dad308d52a15ce9c7edd6ef3dad6a27becd8e001e80f",
"message_hash": "586052916fb6f746e1d417766cceffbe1baf95579bab67ad49adda
@webmaster128
webmaster128 / TOUR_COMSJS_STARGATE.md
Last active March 10, 2025 03:18
CosmJS + Stargate – A guided tour

Support for Cosmos SDK Stargate in CosmJS has been ongoing work for several months now. Stargate is released and CosmJS is here to connect to it.

Starting points

Let's explore what is new for Stargate support:

@webmaster128
webmaster128 / heldernet.md
Last active October 28, 2020 18:09
What is Heldernet?

What is Heldernet?

Heldernet is an inofficial name of a Comsmos SDK (Launchpad) based blockchain with the x/wasm module enabled. It is brought to you by the Tendermint Inc. team and spawned for Hackatom V. It is expected to go down after the hackaton. Official resources can be found at the bottom of this site: https://five.hackatom.org/resources.

Confio has committed to co-maintain Heldernet during the hackatom and beyond, for as long as it is useful.

// 1 item
let user = new Person("Susi");
// 2 items
let userA = new Person("Susi");
let userB = new Person("Marc");
// 3 items
let users = [
new Person("Susi"),
@webmaster128
webmaster128 / nullptr-demo.md
Created May 27, 2020 14:50
Value of Rust's std::ptr::null when compiled to Wasm
mkdir ptr-null-wasm
cd ptr-null-wasm
cargo init
echo '#[no_mangle] extern "C" fn get_std_ptr_null_value() -> u32 { std::ptr::null::<String>() as u32 }' >> src/main.rs
echo '#[no_mangle] extern "C" fn get_seven() -> u32 { 7 as u32 }' >> src/main.rs
cargo build --target wasm32-unknown-unknown
wasm2wat target/wasm32-unknown-unknown/debug/ptr-null-wasm.wasm | grep -A 6 '(func $get_std_ptr_null_value (type'
@webmaster128
webmaster128 / why_json.md
Last active April 28, 2020 22:01
Note on alternative text dumps of a proto document for Comsmos SDK signing

So we'll not be using any feature from JSON other than the key/value structure, arrays and nesting. If all we need for signing is a textual representation of the proto document, what about using a protobuf specific text representation as shown by protoc:

$ protoc demo/awesome.proto --decode=awesomepackage.AwesomeMessage < demo/msg1.bin
title: "This is great"
awesome_number: 987654
created {
@webmaster128
webmaster128 / send_transactions.ts
Created September 26, 2019 08:12
Send send transactions to Babynet
const transactionsCount = 100;
const nodeUrl = "wss://rpc-private-a-vip-babynet.iov.one";
const mnemonic = "twin document gold guide asset false rival rib civil squeeze they upper";
const profile = new UserProfile();
const signer = new MultiChainSigner(profile);
const { connection } = await signer.addChain(createBnsConnector(nodeUrl));
const chainId = connection.chainId();
const wallet = profile.addWallet(Ed25519HdWallet.fromMnemonic(mnemonic));
@webmaster128
webmaster128 / create_names.ts
Created September 25, 2019 15:25
Create any number of usernames on Catnet using IOV-Core CLI
const registrations_count = 3;
const nodeUrl = "wss://rpc-private-a-vip-catnet.iov.one";
const mnemonic = "twin document gold guide asset false rival rib civil squeeze they upper";
const profile = new UserProfile();
const signer = new MultiChainSigner(profile);
const { connection } = await signer.addChain(createBnsConnector(nodeUrl));
const chainId = connection.chainId();
const wallet = profile.addWallet(Ed25519HdWallet.fromMnemonic(mnemonic));
{
"genesis_time": "2019-10-10T08:00:00Z",
"chain_id": "iov-mainnet",
"consensus_params": {
"block": {
"max_bytes": "500000",
"max_gas": "-1",
"time_iota_ms": "1000"
},
"evidence": {