From edf2030b34aa9ce8b8d4eed67efe7b17f30b3c58 Mon Sep 17 00:00:00 2001 From: Peter Harpending Date: Thu, 3 Sep 2026 15:47:09 -0700 Subject: [PATCH] scratch --- ct/rubicon.aes | 35 +++++++++++------------------------ rq/.gitignore | 15 +++++++++++++++ rq/Emakefile | 1 + rq/ebin/rq.app | 7 +++++++ rq/src/rq.erl | 19 +++++++++++++++++++ rq/zomp.meta | 18 ++++++++++++++++++ x04-noisy-echo/nechoc | 11 +++++++++-- x04-noisy-echo/nechod | 2 +- x04-noisy-echo/scratch.txt | 11 +++++++++++ x05-rq/rq | 1 - 10 files changed, 92 insertions(+), 28 deletions(-) create mode 100644 rq/.gitignore create mode 100644 rq/Emakefile create mode 100644 rq/ebin/rq.app create mode 100644 rq/src/rq.erl create mode 100644 rq/zomp.meta delete mode 100755 x05-rq/rq diff --git a/ct/rubicon.aes b/ct/rubicon.aes index b57bf2c..b898359 100644 --- a/ct/rubicon.aes +++ b/ct/rubicon.aes @@ -4,41 +4,28 @@ * Author: Peter Harpending * Date: 2026-08-12 */ - contract Rubicon = // this could/should be a record, but records aren't really // portable across contracts/languages/APIs // - // I think records are returned to caller as a FATE tuple with - // fields in this order. I don't really know though and that's - // kind of a hack and not something that we should build around i - // feel like - // // record rbx = // {ip : string, // port : int, // protocol : string, // "tcp", "udp", "sctp", etc // noise : string, // Noise_Foo_Bar_Baz_Quux - // pubkey : bytes, // service's pubkey - // salt : bytes} // ??? + // pubkey : bytes, // responder static pubkey (noise rs field) + // prologue : bytes} // noise prologue (empty = no prologue) - // (ip, port, protocol, noise, pubkey) - type rbx_tuple = string * int * string * string * bytes + // (ip, port, protocol, noise, pubkey, prologue) + type rbx_tuple = string * int * string * string * bytes * bytes type state = list(rbx_tuple) - entrypoint - init : list(rbx_tuple) => state - init(services) = - services + entrypoint init(tuples: list(rbx_tuple)): state = + tuples - stateful entrypoint - set_services : list(rbx_tuple) => () - set_services(_) | Call.caller != Contract.creator = - abort("Not allowed") - set_services(svs) = - put(svs) + stateful entrypoint set(tuples: list(rbx_tuple)): unit = + require(Call.caller == Contract.creator, "Not allowed") + put(tuples) - entrypoint - get_services : () => list(rbx_tuple) - get_services() = - state + entrypoint lookup(): list(rbx_tuple) = + state diff --git a/rq/.gitignore b/rq/.gitignore new file mode 100644 index 0000000..20177b4 --- /dev/null +++ b/rq/.gitignore @@ -0,0 +1,15 @@ +.eunit +deps +*.o +*.beam +*.plt +*.swp +erl_crash.dump +ebin/*.beam +doc/*.html +doc/*.css +doc/edoc-info +doc/erlang.png +rel/example_project +.concrete/DEV_MODE +.rebar diff --git a/rq/Emakefile b/rq/Emakefile new file mode 100644 index 0000000..68c7b67 --- /dev/null +++ b/rq/Emakefile @@ -0,0 +1 @@ +{"src/*", [debug_info, {i, "include/"}, {outdir, "ebin/"}]}. diff --git a/rq/ebin/rq.app b/rq/ebin/rq.app new file mode 100644 index 0000000..74b0787 --- /dev/null +++ b/rq/ebin/rq.app @@ -0,0 +1,7 @@ +{application,rq, + [{description,[]}, + {registered,[]}, + {included_applications,[]}, + {applications,[stdlib,kernel]}, + {vsn,"0.1.0"}, + {modules,[rq]}]}. diff --git a/rq/src/rq.erl b/rq/src/rq.erl new file mode 100644 index 0000000..9616766 --- /dev/null +++ b/rq/src/rq.erl @@ -0,0 +1,19 @@ +%% @doc rubicon querier +-module(rq). +-vsn("0.1.0"). +-author("Peter Harpending"). +-copyright("Peter Harpending"). + + +-export([start/1]). + + +-spec start(ArgV) -> ok + when ArgV :: [string()]. + +start(ArgV) -> + ok = application:ensure_started(hakuzaru), + ok = hz:chain_nodes([{"testnet.tsuriai.jp", 3013}, + {"testnet.gajumaru.io", 3013}]), + ok = io:format("Hello, World! Args: ~tp~n", [ArgV]), + zx:silent_stop(). diff --git a/rq/zomp.meta b/rq/zomp.meta new file mode 100644 index 0000000..e0e033b --- /dev/null +++ b/rq/zomp.meta @@ -0,0 +1,18 @@ +{name,"rq"}. +{type,cli}. +{modules,[]}. +{mod,"rq"}. +{author,"Peter Harpending"}. +{prefix,none}. +{desc,[]}. +{package_id,{"otpr","rq",{0,1,0}}}. +{deps,[{"otpr","hakuzaru",{0,9,1}}]}. +{key_name,none}. +{a_email,[]}. +{c_email,[]}. +{copyright,"Peter Harpending"}. +{file_exts,[]}. +{license,skip}. +{repo_url,[]}. +{tags,[]}. +{ws_url,[]}. diff --git a/x04-noisy-echo/nechoc b/x04-noisy-echo/nechoc index a7ca7e0..071c62e 100755 --- a/x04-noisy-echo/nechoc +++ b/x04-noisy-echo/nechoc @@ -1,5 +1,6 @@ #!/usr/bin/env escript +%% authentication %% needs: %% - line parsing %% - keyboard input @@ -29,15 +30,21 @@ main_ii(PortNum) -> spawn_link(fun() -> kbd_loop(Self) end), j_loop(#js{tsock = TSock, nsock = NSock}). + +server_pubkey() -> + <<116, 159, 91, 248, 138, 250, 73, 40, 231, 50, 81, 110, 137, + 163, 44, 76, 48, 130, 225, 95, 168, 121, 93, 44, 148, 42, 180, + 103, 11, 40, 168, 96>>. + noise_options() -> % totally safe crypto KP = enoise_keypair:new(dh25519), - [{noise, "Noise_NN_25519_ChaChaPoly_BLAKE2b"}, + [{noise, "Noise_NK_25519_ChaChaPoly_BLAKE2b"}, + {rs, server_pubkey()}, {e, KP}]. j_loop(JS = #js{rcv = Rcv, tsock = TSock, nsock = NSock}) -> - %ok = inet:setopts(TSock, [{active, once}]), receive {noise, NSock, Bytes} -> NewRcv = <>, diff --git a/x04-noisy-echo/nechod b/x04-noisy-echo/nechod index 8e89f81..80bd21d 100755 --- a/x04-noisy-echo/nechod +++ b/x04-noisy-echo/nechod @@ -39,7 +39,7 @@ noise_options() -> 148, 42, 180, 103, 11, 40, 168, 96>>, KP = enoise_keypair:new(dh25519, Secret, Public), [{noise, "Noise_NN_25519_ChaChaPoly_BLAKE2b"}, - {e, KP}]. + {s, KP}]. % pimp process startup diff --git a/x04-noisy-echo/scratch.txt b/x04-noisy-echo/scratch.txt index c629f18..638d4a8 100644 --- a/x04-noisy-echo/scratch.txt +++ b/x04-noisy-echo/scratch.txt @@ -1,3 +1,14 @@ +pubkey: + +<<116, 159, 91, 248, 138, 250, 73, 40, 231, 50, 81, 110, 137, 163, 44, 76, 48, 130, 225, 95, 168, 121, 93, 44, 148, 42, 180, 103, 11, 40, 168, 96>> + +rbx_tuple = +<<116,159,91,248,138,250,73,40,231,50,81,110,137,163,44,76,48,130,225,95,168,121,93,44,148,42,180,103,11,40,168,96>> + +[{"127.0.0.1", 6969, "tcp", "Noise_NN_25519_ChaChaPoly_BLAKE2b", <<116,159,91,248,138,250,73,40,231,50,81,110,137,163,44,76,48,130,225,95,168,121,93,44,148,42,180,103,11,40,168,96>>, <<>>}] + + {"127.0.0.1", 6970, "tcp", <<116,159,91,248,138,250,73,40,231,50,81,110,137,163,44,76,48,130,225,95,168,121,93,44,148,42,180,103,11,40,168,96>>, <<>>}, + {"127.0.0.1", 6971, "tcp", <<116,159,91,248,138,250,73,40,231,50,81,110,137,163,44,76,48,130,225,95,168,121,93,44,148,42,180,103,11,40,168,96>>, <<>>}] liquidate_hos([{HoPid, _HoRef} | Hos]) -> p_logfln("liquidating ~tp", [HoPid]), diff --git a/x05-rq/rq b/x05-rq/rq deleted file mode 100755 index ae72a5e..0000000 --- a/x05-rq/rq +++ /dev/null @@ -1 +0,0 @@ -#!/usr/bin/env escrip