From 5443ad041c4c054ff4bf113d7d0bb0f2f62fa1a6 Mon Sep 17 00:00:00 2001 From: Carl Niklas Rydberg Date: Sun, 21 Dec 2025 23:09:44 +0100 Subject: [PATCH] Enforced StoreConfig at the wrapper boundary by validating the configured encoding/hash and rejecting mismatched hash IDs before delegating to backend ops. This makes the amduat_asl_store_t wrapper actively use/validate its config instead of just storing it. --- src/near_core/asl/store.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/src/near_core/asl/store.c b/src/near_core/asl/store.c index 079b82a..b452074 100644 --- a/src/near_core/asl/store.c +++ b/src/near_core/asl/store.c @@ -1,4 +1,24 @@ #include "amduat/asl/store.h" +#include "amduat/enc/asl1_core.h" +#include "amduat/hash/asl1.h" + +static bool amduat_asl_store_config_supported( + const amduat_asl_store_config_t *config) { + const amduat_hash_asl1_desc_t *hash_desc; + + if (config == NULL) { + return false; + } + if (amduat_enc_asl1_core_desc_lookup(config->encoding_profile_id) == NULL) { + return false; + } + hash_desc = amduat_hash_asl1_desc_lookup(config->hash_id); + if (hash_desc == NULL || hash_desc->digest_len == 0 || + hash_desc->impl.digest == NULL) { + return false; + } + return true; +} void amduat_asl_store_init(amduat_asl_store_t *store, amduat_asl_store_config_t config, @@ -18,6 +38,9 @@ amduat_asl_store_error_t amduat_asl_store_put(amduat_asl_store_t *store, if (store == NULL || store->ops.put == NULL) { return AMDUAT_ASL_STORE_ERR_UNSUPPORTED; } + if (!amduat_asl_store_config_supported(&store->config)) { + return AMDUAT_ASL_STORE_ERR_UNSUPPORTED; + } return store->ops.put(store->ctx, artifact, out_ref); } @@ -27,5 +50,11 @@ amduat_asl_store_error_t amduat_asl_store_get(amduat_asl_store_t *store, if (store == NULL || store->ops.get == NULL) { return AMDUAT_ASL_STORE_ERR_UNSUPPORTED; } + if (!amduat_asl_store_config_supported(&store->config)) { + return AMDUAT_ASL_STORE_ERR_UNSUPPORTED; + } + if (ref.hash_id != store->config.hash_id) { + return AMDUAT_ASL_STORE_ERR_UNSUPPORTED; + } return store->ops.get(store->ctx, ref, out_artifact); }