commit_verify/
stl.rs

1// Client-side-validation foundation libraries.
2//
3// SPDX-License-Identifier: Apache-2.0
4//
5// Written in 2019-2024 by
6//     Dr. Maxim Orlovsky <orlovsky@lnp-bp.org>
7//
8// Copyright (C) 2019-2024 LNP/BP Standards Association. All rights reserved.
9//
10// Licensed under the Apache License, Version 2.0 (the "License");
11// you may not use this file except in compliance with the License.
12// You may obtain a copy of the License at
13//
14//     http://www.apache.org/licenses/LICENSE-2.0
15//
16// Unless required by applicable law or agreed to in writing, software
17// distributed under the License is distributed on an "AS IS" BASIS,
18// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19// See the License for the specific language governing permissions and
20// limitations under the License.
21
22use strict_types::{CompileError, LibBuilder, TypeLib};
23
24use crate::{mpc, MerkleHash, MerkleNode, ReservedBytes, StrictHash, LIB_NAME_COMMIT_VERIFY};
25
26pub const LIB_ID_COMMIT_VERIFY: &str =
27    "stl:egMd32l9-y$Kod0o-$FRcNAV-Q4U$O5h-pskW9YM-$irF0yY#miller-pancake-elastic";
28
29fn _commit_verify_stl() -> Result<TypeLib, CompileError> {
30    LibBuilder::new(libname!(LIB_NAME_COMMIT_VERIFY), tiny_bset! {
31        strict_types::stl::std_stl().to_dependency()
32    })
33    .transpile::<ReservedBytes<1>>()
34    .transpile::<ReservedBytes<2>>()
35    .transpile::<ReservedBytes<4>>()
36    .transpile::<mpc::MerkleConcealed>()
37    .transpile::<mpc::MerkleTree>()
38    .transpile::<mpc::MerkleBlock>()
39    .transpile::<mpc::MerkleProof>()
40    .transpile::<mpc::Leaf>()
41    .transpile::<mpc::Commitment>()
42    .transpile::<MerkleNode>()
43    .transpile::<MerkleHash>()
44    .transpile::<StrictHash>()
45    .compile()
46}
47
48pub fn commit_verify_stl() -> TypeLib {
49    _commit_verify_stl().expect("invalid strict type CommitVerify library")
50}
51
52#[cfg(test)]
53mod test {
54    use super::*;
55
56    #[test]
57    fn lib_id() {
58        let lib = commit_verify_stl();
59        assert_eq!(lib.id().to_string(), LIB_ID_COMMIT_VERIFY);
60    }
61}