snarkvm_console_network_environment/helpers/mod.rs
1// Copyright (c) 2019-2026 Provable Inc.
2// This file is part of the snarkVM library.
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
16mod or_halt;
17pub use or_halt::OrHalt;
18
19mod sanitizer;
20pub use sanitizer::Sanitizer;
21
22pub mod variable_length;
23pub use variable_length::{read_variable_length_integer, variable_length_integer};
24
25/// A bech32m checksum with no hard length limit.
26///
27/// bech32 0.11 caps [`bech32::Bech32m`] at 1023 characters, but Aleo types such as
28/// ciphertexts, state paths, and snark keys can legitimately exceed this. This type
29/// uses identical generator coefficients and target residue as `Bech32m`, so encoded
30/// strings are valid bech32m and round-trip correctly with any standard decoder that
31/// does not enforce a maximum length.
32pub enum LongBech32m {}
33
34impl bech32::primitives::checksum::Checksum for LongBech32m {
35 type MidstateRepr = u32;
36
37 const CHECKSUM_LENGTH: usize = 6;
38 const CODE_LENGTH: usize = usize::MAX;
39 const GENERATOR_SH: [u32; 5] = [0x3b6a_57b2, 0x2650_8e6d, 0x1ea1_19fa, 0x3d42_33dd, 0x2a14_62b3];
40 const TARGET_RESIDUE: u32 = 0x2bc830a3;
41}