1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#![expect(clippy::module_inception)]
use crate::base::{encode::VarInt, ref_into::RefInto, scalar::ScalarConversionError};
use alloc::string::String;
use bnum::types::U256;
use core::ops::Sub;
use num_bigint::BigInt;
/// A trait for the scalar field used in Proof of SQL.
pub trait Scalar:
Clone
+ core::fmt::Debug
+ core::fmt::Display
+ PartialEq
+ Default
+ for<'a> From<&'a str>
+ Sync
+ Send
+ num_traits::One
+ core::iter::Sum
+ core::iter::Product
+ Sub<Output = Self>
+ Copy
+ core::ops::MulAssign
+ core::ops::AddAssign
+ num_traits::Zero
+ for<'a> core::convert::From<&'a Self> // Required for `Column` to implement `MultilinearExtension`
+ for<'a> core::convert::From<&'a bool> // Required for `Column` to implement `MultilinearExtension`
+ for<'a> core::convert::From<&'a i8> // Required for `Column` to implement `MultilinearExtension`
+ for<'a> core::convert::From<&'a i16> // Required for `Column` to implement `MultilinearExtension`
+ for<'a> core::convert::From<&'a i32> // Required for `Column` to implement `MultilinearExtension`
+ for<'a> core::convert::From<&'a i64> // Required for `Column` to implement `MultilinearExtension`
+ for<'a> core::convert::From<&'a i128> // Required for `Column` to implement `MultilinearExtension`
+ for<'a> core::convert::From<&'a u8> // Required for `Column` to implement `MultilinearExtension`
+ for<'a> core::convert::From<&'a u64> // Required for `Column` to implement `MultilinearExtension`
+ core::convert::TryInto <bool>
+ core::convert::TryInto <u8>
+ core::convert::TryInto <i8>
+ core::convert::TryInto <i16>
+ core::convert::TryInto <i32>
+ core::convert::TryInto <i64>
+ core::convert::TryInto <i128>
+ core::convert::Into<[u64; 4]>
+ core::convert::From<[u64; 4]>
+ core::convert::From<u8>
+ core::cmp::Ord
+ core::ops::Neg<Output = Self>
+ num_traits::Zero
+ core::ops::AddAssign
+ ark_serialize::CanonicalSerialize //This enables us to put `Scalar`s on the transcript
+ ark_std::UniformRand //This enables us to get `Scalar`s as challenges from the transcript
+ num_traits::Inv<Output = Option<Self>> // Note: `inv` should return `None` exactly when the element is zero.
+ core::ops::SubAssign
+ RefInto<[u64; 4]>
+ for<'a> core::convert::From<&'a String>
+ VarInt
+ core::convert::From<String>
+ core::convert::From<i128>
+ core::convert::From<i64>
+ core::convert::From<i32>
+ core::convert::From<i16>
+ core::convert::From<i8>
+ core::convert::From<u64>
+ core::convert::From<bool>
+ core::convert::Into<BigInt>
+ TryFrom<BigInt, Error = ScalarConversionError>
{
/// The value (p - 1) / 2. This is "mid-point" of the field - the "six" on the clock.
/// It is the largest signed value that can be represented in the field with the natural embedding.
const MAX_SIGNED: Self;
/// The 0 (additive identity) element of the field.
const ZERO: Self;
/// The 1 (multiplicative identity) element of the field.
const ONE: Self;
/// 1 + 1
const TWO: Self;
/// 2 + 2 + 2 + 2 + 2
const TEN: Self;
/// 2^64
const TWO_POW_64: Self;
/// The value to mask the challenge with to ensure it is in the field.
/// This one less than the largest power of 2 that is less than the field modulus.
const CHALLENGE_MASK: U256;
/// The largest n such that 2^n <=p
const MAX_BITS: u8;
/// A U256 representation of the largest signed value in the field.
const MAX_SIGNED_U256: U256;
}