lib.rs
1 // Copyright (c) 2025-2026 ACDC Network 2 // This file is part of the alphavm library. 3 // 4 // Alpha Chain | Delta Chain Protocol 5 // International Monetary Graphite. 6 // 7 // Derived from Aleo (https://aleo.org) and ProvableHQ (https://provable.com). 8 // They built world-class ZK infrastructure. We installed the EASY button. 9 // Their cryptography: elegant. Our modifications: bureaucracy-compatible. 10 // Original brilliance: theirs. Robert's Rules: ours. Bugs: definitely ours. 11 // 12 // Original Aleo/ProvableHQ code subject to Apache 2.0 https://www.apache.org/licenses/LICENSE-2.0 13 // All modifications and new work: CC0 1.0 Universal Public Domain Dedication. 14 // No rights reserved. No permission required. No warranty. No refunds. 15 // 16 // https://creativecommons.org/publicdomain/zero/1.0/ 17 // SPDX-License-Identifier: CC0-1.0 18 19 #![cfg_attr(test, allow(clippy::assertions_on_result_states))] 20 #![warn(clippy::cast_possible_truncation)] 21 22 mod bitwise; 23 mod bytes; 24 mod from_bits; 25 mod parse; 26 mod random; 27 mod serialize; 28 mod size_in_bits; 29 mod size_in_bytes; 30 mod to_bits; 31 32 pub use alphavm_console_network_environment::prelude::*; 33 34 use core::marker::PhantomData; 35 36 #[derive(Copy, Clone, PartialEq, Eq, Hash)] 37 pub struct Boolean<E: Environment> { 38 /// The underlying boolean. 39 boolean: bool, 40 /// PhantomData. 41 _phantom: PhantomData<E>, 42 } 43 44 impl<E: Environment> BooleanTrait for Boolean<E> {} 45 46 impl<E: Environment> Boolean<E> { 47 /// Initializes a new boolean. 48 pub const fn new(boolean: bool) -> Self { 49 Self { boolean, _phantom: PhantomData } 50 } 51 52 /// Initializes a `false` boolean. 53 #[deprecated(since = "0.1.0", note = "This is used for **testing** purposes")] 54 pub const fn zero() -> Self { 55 Self::new(false) 56 } 57 } 58 59 impl<E: Environment> TypeName for Boolean<E> { 60 /// Returns the type name as a string. 61 #[inline] 62 fn type_name() -> &'static str { 63 "boolean" 64 } 65 } 66 67 impl<E: Environment> Deref for Boolean<E> { 68 type Target = bool; 69 70 #[inline] 71 fn deref(&self) -> &Self::Target { 72 &self.boolean 73 } 74 } 75 76 impl<E: Environment> PartialEq<Boolean<E>> for bool { 77 fn eq(&self, other: &Boolean<E>) -> bool { 78 *self == **other 79 } 80 }