arnaucube
arnaucube/ark-r1cs-stdPublic Self-hosted repository
ark-r1cs-std/r1cs-std/src/lib.rs
r1cs-std/src/lib.rsRaw
 1#![cfg_attr(not(feature = "std"), no_std)]
 2#![deny(
 3    unused_import_braces,
 4    unused_qualifications,
 5    trivial_casts,
 6    trivial_numeric_casts
 7)]
 8#![deny(
 9    unused_qualifications,
10    variant_size_differences,
11    stable_features,
12    unreachable_pub
13)]
14#![deny(
15    non_shorthand_field_patterns,
16    unused_attributes,
17    unused_imports,
18    unused_extern_crates
19)]
20#![deny(
21    renamed_and_removed_lints,
22    stable_features,
23    unused_allocation,
24    unused_comparisons,
25    bare_trait_objects
26)]
27#![deny(
28    const_err,
29    unused_must_use,
30    unused_mut,
31    unused_unsafe,
32    private_in_public,
33    unsafe_code
34)]
35#![forbid(unsafe_code)]
36
37#[cfg(all(test, not(feature = "std")))]
38#[macro_use]
39extern crate std;
40
41#[cfg(not(feature = "std"))]
42extern crate alloc as ralloc;
43
44#[macro_use]
45extern crate algebra;
46
47#[macro_use]
48extern crate derivative;
49
50/// used by test_constraint_system
51#[cfg(not(feature = "std"))]
52macro_rules! println {
53    () => {};
54    ($($arg: tt)*) => {};
55}
56
57#[cfg(not(feature = "std"))]
58use ralloc::{collections::BTreeMap, string::String, vec::Vec};
59
60#[cfg(feature = "std")]
61use std::{collections::BTreeMap, string::String, vec::Vec};
62
63pub mod test_constraint_system;
64
65pub mod bits;
66pub use self::bits::*;
67
68pub mod fields;
69
70pub mod groups;
71
72pub mod pairing;
73
74pub mod alloc;
75pub mod eq;
76pub mod select;
77
78pub mod prelude {
79    pub use crate::{
80        alloc::*,
81        bits::{boolean::Boolean, uint32::UInt32, uint8::UInt8, ToBitsGadget, ToBytesGadget},
82        eq::*,
83        fields::FieldGadget,
84        groups::GroupGadget,
85        pairing::PairingGadget,
86        select::*,
87    };
88}
89
90pub trait Assignment<T> {
91    fn get(self) -> Result<T, r1cs_core::SynthesisError>;
92}
93
94impl<T> Assignment<T> for Option<T> {
95    fn get(self) -> Result<T, r1cs_core::SynthesisError> {
96        self.ok_or_else(|| r1cs_core::SynthesisError::AssignmentMissing)
97    }
98}