Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/aienux/blob/main/crates/aienos-artifact/src/canonical.rs # aienux Aienux, the AienOS kernel: boot, scheduling, IPC and capability boundaries. Pre-alpha; host, emulator and physical evidence are labelled separately. Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `aienux / crates / aienos-artifact / src / canonical.rs` 60 lines ยท 2191 bytes Raw Blame History 1 // SPDX-License-Identifier: Apache-2.0 2 // Copyright 2026 Drake Stapleton (AIEN / aien-dev) 3 // 4 // Licensed under the Apache License, Version 2.0 (the "License"); 5 // you may not use this file except in compliance with the License. 6 // You may obtain a copy of the License at 7 // 8 // http://www.apache.org/licenses/LICENSE-2.0 9 // 10 // Unless required by applicable law or agreed to in writing, software 11 // distributed under the License is distributed on an "AS IS" BASIS, 12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 // See the License for the specific language governing permissions and 14 // limitations under the License. 15 16 use aienos_crypto::sha256::{hash, Digest, Sha256}; 17 18 use crate::format::Artifact; 19 20 pub const REQUESTS_DOMAIN: &[u8] = b"AIENOS-ARTIFACT-CAP-REQUESTS-V1\0"; 21 pub const GRANTS_DOMAIN: &[u8] = b"AIENOS-ADMISSION-CAP-GRANTS-V1\0"; 22 pub const RESOURCES_DOMAIN: &[u8] = b"AIENOS-ARTIFACT-RESOURCES-V1\0"; 23 pub const POLICY_DOMAIN: &[u8] = b"AIENOS-ADMISSION-POLICY-V1\0"; 24 pub const MACHINE_ID_DOMAIN: &[u8] = b"AIENOS-MACHINE-ID-V1\0"; 25 pub const VERIFIER_IDENTITY_DOMAIN: &[u8] = b"AIENOS-VERIFIER-IDENTITY-V1\0"; 26 27 pub fn payload_digest(artifact: &Artifact<'_>) -> Digest { 28 hash(artifact.payload) 29 } 30 31 pub fn requested_capability_digest(canonical_records: &[u8]) -> Digest { 32 digest_domain(REQUESTS_DOMAIN, canonical_records) 33 } 34 35 pub fn granted_capability_digest(canonical_records: &[u8]) -> Digest { 36 digest_domain(GRANTS_DOMAIN, canonical_records) 37 } 38 39 pub fn resource_envelope_digest(canonical_envelope: &[u8]) -> Digest { 40 digest_domain(RESOURCES_DOMAIN, canonical_envelope) 41 } 42 43 pub fn policy_digest(canonical_policy: &[u8]) -> Digest { 44 digest_domain(POLICY_DOMAIN, canonical_policy) 45 } 46 47 pub fn machine_id_digest(canonical_machine_id: &[u8]) -> Digest { 48 digest_domain(MACHINE_ID_DOMAIN, canonical_machine_id) 49 } 50 51 pub fn verifier_identity_digest(build_identity: &[u8]) -> Digest { 52 digest_domain(VERIFIER_IDENTITY_DOMAIN, build_identity) 53 } 54 55 fn digest_domain(domain: &[u8], canonical_bytes: &[u8]) -> Digest { 56 let mut digest = Sha256::new(); 57 digest.update(domain); 58 digest.update(canonical_bytes); 59 digest.finalize() 60 }