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
+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.