rq rename

This commit is contained in:
2026-09-22 14:25:45 -07:00
parent fcd61c122e
commit 3683c12b1b
7 changed files with 28 additions and 33 deletions
+15
View File
@@ -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
+1
View File
@@ -0,0 +1 @@
{"src/*", [debug_info, {i, "include/"}, {outdir, "ebin/"}]}.
+19
View File
@@ -0,0 +1,19 @@
contract interface Rubicon =
entrypoint lookup: () => list(string * int * string * string * address * bytes)
contract Names =
type rbx_tuple = string * int * string * string * address * bytes
type state = map(string, Rubicon)
entrypoint init(): state =
{}
stateful entrypoint register(name: string, addr: Rubicon): unit =
put(state{[name] = addr})
stateful entrypoint lookup(name: string): option(list(rbx_tuple)) =
switch(Map.lookup(name, state))
Some(addr) =>
Some(addr.lookup())
None =>
None
+24
View File
@@ -0,0 +1,24 @@
contract Rubicon =
// record rbx =
// {ip : string,
// port : int,
// protocol : string, // "tcp", "udp", "sctp", etc
// noise : string, // Noise_Foo_Bar_Baz_Quux
// pubkey : address, // responder static pubkey (noise: rs field)
// prologue : bytes} // noise prologue (empty = no prologue)
// (ip, port, protocol, noise, pubkey, prologue)
type rbx_tuple = string * int * string * string * address * bytes
type state = list(rbx_tuple)
entrypoint init(tuples: list(rbx_tuple)): state =
tuples
stateful entrypoint set(tuples: list(rbx_tuple)): unit =
// this would be nice
// but unfortunately nobody knows how to do this
// require(Call.caller == Contract.creator, "Not allowed")
put(tuples)
entrypoint lookup(): list(rbx_tuple) =
state
+7
View File
@@ -0,0 +1,7 @@
{application,dindu,
[{description,[]},
{registered,[]},
{included_applications,[]},
{applications,[stdlib,kernel]},
{vsn,"0.1.0"},
{modules,[rq]}]}.
+151
View File
@@ -0,0 +1,151 @@
%% @doc rq: Decentralized Identity Namespace Disambiguation Utility
-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 = hz(),
du(ArgV).
du(["-s" | Rest]) -> rq(Rest);
du(["--shell" | Rest]) -> rq(Rest);
du(Rest) -> rq(Rest), zx:silent_stop().
rq(["nuffin"]) ->
ok = io:format("hz status: ~tp~n", [hz:status()]),
ok = io:format("rbx_tuples: ~tp~n", [rbx_tuples()]),
ok = io:format("my akstr:~n~ts~n~n", [my_akstr()]),
ok = io:format("names ct aaci:~n~tp~n~n", [nct_aaci()]),
ok = io:format("rubicon ct aaci:~n~tp~n~n", [rct_aaci()]),
ok;
rq(["src", "names.aes"]) ->
{ok, Bytes} = file:read_file(nct_filepath()),
io:format("~s", [Bytes]);
rq(["src", "rubicon.aes"]) ->
{ok, Bytes} = file:read_file(rct_filepath()),
io:format("~s", [Bytes]);
rq(["-h" | _]) -> rq_help();
rq(["--help" | _]) -> rq_help();
rq(["help" | _]) -> rq_help();
rq(BadArgs) ->
io:format("arguments are a failure: ~tp~n", [BadArgs]),
rq_help().
rq_help() ->
io:format("~ts~n", [help_screen()]).
help_screen() ->
"""
rq = Decentralized Identity Namespace Disambiguation Utility
version 0.0.0 + 0.0.1i
USAGE: rq [ARGS]
""".
%du_register(
%% name contract deployed address
nct_ctstr() ->
"ct_2CDom5hKimtKSsTykhBYBKMgGv7youakZPVgk5h9qgNL3P65oV".
nct_aaci() ->
hz:prepare_contract(nct_filepath()).
nct_filepath() ->
ct_dir() ++ "/names.aes".
%% rubicon contract deployed address
rct_ctstr() ->
"".
rct_aaci() ->
hz:prepare_contract(rct_filepath()).
rct_filepath() ->
ct_dir() ++ "/rubicon.aes".
ct_dir() ->
zx:get_home() ++ "/ct".
%% my keys
% "ak_2pr2BL1jK625Uedt888p3YKRUEk3GDTo5r2zKW6gMaZePQP5ou"
my_akstr() ->
unicode:characters_to_list(gmser_api_encoder:encode(account_pubkey, my_pubkey32())).
my_pubkey32() ->
maps:get(public, my_keypair()).
my_secret_key() ->
maps:get(secret, my_keypair()).
my_keypair() ->
ecu_eddsa:sign_seed_keypair(my_seed()).
my_seed() ->
crypto:hash(sha3_512, <<"p@ssw0rd">>).
%% hz setup
hz() ->
ok = application:ensure_started(hakuzaru),
ok = hz:tls(false),
ok = hz:chain_nodes(hz_nodes()).
hz_nodes() ->
[ {"tsuriai.jp", 4013}
].
rbx_tuples() ->
NoiseStr = "Noise_NK_25519_ChaChaPoly_BLAKE2b",
ServicePubkey = <<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>>,
NoisePrologue = <<>>,
[{"127.0.0.1", 6969, "tcp", NoiseStr, ServicePubkey, NoisePrologue}].
%% deploying
deploy_rct_with(RbxTuples) ->
case hz:contract_create(my_akstr(), rct_filepath(), [RbxTuples]) of
{ok, CreateTx} ->
deploy_rct_II(CreateTx);
Error ->
io:format("you are a failure: ~tp~n", [Error]),
error(Error)
end.
deploy_rct_II(UnsignedCreateTx) ->
SecretKey = my_secret_key(),
case hz:sign_tx(UnsignedCreateTx, SecretKey) of
{ok, SignedTx} ->
deploy_rct_III(SignedTx);
Error ->
io:format("you are a failure II: ~tp~n", [Error]),
error(Error)
end.
deploy_rct_III(SignedCreateTx) ->
case hz:post_tx(SignedCreateTx) of
{ok, Result_III} ->
io:format("Result the third: ~tp~n", [Result_III]);
Error ->
io:format("you are a failure III: ~tp~n", [Error]),
error(Error)
end.
+28
View File
@@ -0,0 +1,28 @@
{name,"rq"}.
{type,cli}.
{modules,[]}.
{mod,"rq"}.
{author,"Peter Harpending"}.
{prefix,none}.
{desc,[]}.
{package_id,{"otpr","rq",{0,1,0}}}.
{deps,[{"otpr","base58",{0,1,1}},
{"otpr","eblake2",{1,0,1}},
{"otpr","gmserialization",{0,1,3}},
{"otpr","ec_utils",{1,0,0}},
{"otpr","hakuzaru",{0,9,1}},
{"otpr", "sophia", {9,0,0}},
{"otpr", "gmserialization", {0,1,3}},
{"otpr", "gmbytecode", {3,4,1}},
{"otpr", "base58", {0,1,1}},
{"otpr", "zj", {1,1,0}},
{"otpr", "getopt", {1,0,2}}]}.
{key_name,none}.
{a_email,[]}.
{c_email,[]}.
{copyright,"Peter Harpending"}.
{file_exts,[]}.
{license,skip}.
{repo_url,[]}.
{tags,[]}.
{ws_url,[]}.