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  #![forbid(unsafe_code)]
 20  #![allow(clippy::too_many_arguments)]
 21  
 22  mod environment;
 23  pub use environment::*;
 24  
 25  mod helpers;
 26  pub use helpers::*;
 27  
 28  pub mod traits;
 29  pub use traits::*;
 30  
 31  pub mod prelude {
 32      pub use crate::{
 33          environment::*,
 34          helpers::*,
 35          traits::{
 36              algorithms::*,
 37              arithmetic::*,
 38              bitwise::*,
 39              from_bits::*,
 40              from_field::*,
 41              parse::*,
 42              parse_string::*,
 43              to_bits_le,
 44              to_field::*,
 45              type_name::*,
 46              types::{
 47                  integer_magnitude::Magnitude,
 48                  integer_type::{
 49                      CheckedPow,
 50                      CheckedShl,
 51                      IntegerProperties,
 52                      IntegerType,
 53                      WrappingDiv,
 54                      WrappingPow,
 55                      WrappingRem,
 56                  },
 57                  *,
 58              },
 59              visibility::*,
 60              ToBits,
 61              ToBitsRaw,
 62          },
 63      };
 64  
 65      pub use alphavm_curves::{AffineCurve, MontgomeryParameters, ProjectiveCurve, TwistedEdwardsParameters};
 66      pub use alphavm_fields::{Field as _, PrimeField as _, SquareRootField as _, Zero as _};
 67      pub use alphavm_utilities::{
 68          cfg_chunks,
 69          cfg_chunks_mut,
 70          cfg_find,
 71          cfg_find_map,
 72          cfg_into_iter,
 73          cfg_iter,
 74          cfg_iter_mut,
 75          cfg_keys,
 76          cfg_par_bridge,
 77          cfg_reduce,
 78          cfg_reduce_with,
 79          cfg_sort_by_cached_key,
 80          cfg_sort_unstable_by,
 81          cfg_sorted_by,
 82          cfg_values,
 83          cfg_zip_fold,
 84          error,
 85          has_duplicates,
 86          into_io_error,
 87          io_error,
 88          DeserializeExt,
 89          FromBits as _,
 90          FromBytes,
 91          FromBytesDeserializer,
 92          FromBytesUncheckedDeserializer,
 93          LimitedWriter,
 94          TestRng,
 95          ToBits as _,
 96          ToBitsRaw as _,
 97          ToBytes,
 98          ToBytesSerializer,
 99          Uniform,
100      };
101  
102      pub use std::io::{Read, Result as IoResult, Write};
103  
104      pub use core::{
105          cmp::Ordering,
106          fmt::{self, Debug, Display, Formatter},
107          hash::Hash as _,
108          iter::{Product, Sum},
109          ops::{
110              Add,
111              AddAssign,
112              BitAnd,
113              BitAndAssign,
114              BitOr,
115              BitOrAssign,
116              BitXor,
117              BitXorAssign,
118              Deref,
119              DerefMut,
120              Div,
121              DivAssign,
122              Mul,
123              MulAssign,
124              Neg,
125              Not,
126              Rem,
127              RemAssign,
128              Shl,
129              ShlAssign,
130              Shr,
131              ShrAssign,
132              Sub,
133              SubAssign,
134          },
135          str::{self, FromStr},
136      };
137  
138      pub use anyhow::{anyhow, bail, ensure, Error, Result};
139      pub use bech32::{self, FromBase32, ToBase32};
140      pub use itertools::Itertools;
141      pub use nom::{
142          branch::alt,
143          bytes::{complete::tag, streaming::take},
144          character::complete::{alpha1, alphanumeric1, char, one_of},
145          combinator::{complete, fail, map, map_res, opt, recognize},
146          error::{make_error, ErrorKind},
147          multi::{count, many0, many0_count, many1, separated_list0, separated_list1},
148          sequence::{pair, terminated},
149          Err,
150      };
151      pub use num_traits::{AsPrimitive, One, Pow, Zero};
152      pub use rand::{
153          distributions::{Alphanumeric, Distribution, Standard},
154          CryptoRng,
155          Rng,
156      };
157      pub use serde::{
158          de,
159          de::{DeserializeOwned, EnumAccess, MapAccess, SeqAccess, VariantAccess, Visitor},
160          ser::{self, SerializeSeq, SerializeStruct},
161          Deserialize,
162          Deserializer,
163          Serialize,
164          Serializer,
165      };
166  }