From fd12421d9e9589cc8d68a8a64bc2630266e3288f Mon Sep 17 00:00:00 2001 From: kaotisk Date: Tue, 22 Jul 2025 02:01:18 +0300 Subject: [ns] Provides -rp where proof and resolved query is provided --- bin/ak-ns | 3 +++ lib/_ak_ns | 26 +++++++++++++++++++++++--- 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/bin/ak-ns b/bin/ak-ns index 080538c..4238250 100755 --- a/bin/ak-ns +++ b/bin/ak-ns @@ -28,6 +28,8 @@ ## -ll, --list-long List names with keys ## -rn, --resolve-name Resolves value from name ## -rk, --resolve-key Resolves value from key +## -rp, --resolve-key-proof Resolves value from key and provides +## an akfs_map_v3 to clear signed proof ## -p, --publish Publishes value to key ## -pn, --publish2name Publishes value to name ## -pz, --publish-zchain Publishes zchain @@ -53,6 +55,7 @@ then -ll | --list-long) shift; _ak_ns_list_long; exit;; -rn | --resolve-name) shift; _ak_ns_resolve_from_name $1; exit;; -rk | --resolve-key) shift; _ak_ns_resolve_from_key $1; exit;; + -rp | --resolve-key-proof) shift; _ak_ns_resolve_from_key_with_proof $1; exit;; -ek | --encode-key) shift; _ak_ns_encode_key $1; exit;; -dk | --decode-key) shift; _ak_ns_decode_key $1; exit;; -p | --publish) shift; _ak_ns_publish $1 $2; exit;; diff --git a/lib/_ak_ns b/lib/_ak_ns index 32ac594..8afef83 100755 --- a/lib/_ak_ns +++ b/lib/_ak_ns @@ -82,6 +82,23 @@ function _ak_ns_resolve_from_key(){ _ak_gpg_verify_clear_signature ${AK_NS_DIR}/${key} } +function _ak_ns_resolve_from_key_with_proof(){ + # $1; exit;; + if [ -z $1 ] || [ ! -n "$1" ] + then + _ak_log_error "No key was given" + exit 1 + fi + key="$1" + _ak_log_info "${key} was given" + if [ ! -f ${AK_NS_DIR}/${key}.map ] + then + _ak_log_error "${key} was not found" + exit 1 + fi + cat ${AK_NS_DIR}/${key}.map +} + function _ak_ns_encode_key(){ # $1; exit;; if [ -z $1 ] || [ ! -n "$1" ] @@ -211,10 +228,11 @@ function _ak_ns_publish_zchain(){ printf '%s %s\n' "$(echo -n $signed_akfs_map)" \ "$(_ak_gpg_verify_clear_signature ${AK_NS_DIR}/${zchain_key})" \ >> ${AK_NS_DIR}/${zchain_key}.history_map - fi - echo ${signed_akfs_map} > ${AK_NS_DIR}/${zchain_key}.map mv ${zlatest_csigned_file} ${AK_NS_DIR}/${zchain_key} + printf '%s %s\n' "$(echo -n $signed_akfs_map)" \ + "$(_ak_gpg_verify_clear_signature ${AK_NS_DIR}/${zchain_key})" \ + > ${AK_NS_DIR}/${zchain_key}.map } function _ak_ns_publish_config(){ @@ -243,8 +261,10 @@ function _ak_ns_publish_config(){ >> ${AK_NS_DIR}/${zconfig_key}.history_map fi - echo ${signed_akfs_map} > ${AK_NS_DIR}/${zconfig_key}.map mv ${zconfig_csigned_file} ${AK_NS_DIR}/${zconfig_key} + printf '%s %s\n' "$(echo -n $signed_akfs_map)" \ + "$(_ak_gpg_verify_clear_signature ${AK_NS_DIR}/${zconfig_key})" \ + > ${AK_NS_DIR}/${zconfig_key}.map } _ak_log_debug "_ak_ns loaded $(caller)" -- cgit v1.2.3