mod.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 pub use cast::Cast; 20 pub use cast_lossy::CastLossy; 21 22 mod bytes; 23 mod cast; 24 mod cast_lossy; 25 mod equal; 26 mod from_bits; 27 mod parse; 28 mod sample; 29 mod serialize; 30 mod size_in_bits; 31 mod size_in_bytes; 32 mod to_bits; 33 mod to_type; 34 mod variant; 35 36 use crate::{LiteralType, ProgramID}; 37 use alphavm_console_account::{ComputeKey, PrivateKey, Signature}; 38 use alphavm_console_network::Network; 39 use alphavm_console_types::{prelude::*, Boolean}; 40 41 /// The literal enum represents all supported types in alphavm. 42 #[derive(Clone)] 43 pub enum Literal<N: Network> { 44 /// The Alpha address type. 45 Address(Address<N>), 46 /// The boolean type. 47 Boolean(Boolean<N>), 48 /// The field type. 49 Field(Field<N>), 50 /// The group type. 51 Group(Group<N>), 52 /// The 8-bit signed integer type. 53 I8(I8<N>), 54 /// The 16-bit signed integer type. 55 I16(I16<N>), 56 /// The 32-bit signed integer type. 57 I32(I32<N>), 58 /// The 64-bit signed integer type. 59 I64(I64<N>), 60 /// The 128-bit signed integer type. 61 I128(I128<N>), 62 /// The 8-bit unsigned integer type. 63 U8(U8<N>), 64 /// The 16-bit unsigned integer type. 65 U16(U16<N>), 66 /// The 32-bit unsigned integer type. 67 U32(U32<N>), 68 /// The 64-bit unsigned integer type. 69 U64(U64<N>), 70 /// The 128-bit unsigned integer type. 71 U128(U128<N>), 72 /// The scalar type. 73 Scalar(Scalar<N>), 74 /// The signature type. 75 Signature(Box<Signature<N>>), 76 /// The string type. 77 String(StringType<N>), 78 } 79 80 macro_rules! impl_from { 81 ($($name: ident)*) => { 82 $( 83 impl<N: Network> From<$name<N>> for Literal<N> { 84 fn from(value: $name<N>) -> Self { 85 Literal::$name(value) 86 } 87 } 88 )* 89 }; 90 } 91 92 impl_from! { 93 Address Boolean Field Group 94 I8 I16 I32 I64 I128 95 U8 U16 U32 U64 U128 96 Scalar 97 } 98 99 impl<N: Network> From<Signature<N>> for Literal<N> { 100 fn from(value: Signature<N>) -> Self { 101 Literal::Signature(Box::new(value)) 102 } 103 }