Performs arithmetic operations (addition, subtraction, and multiplication) on different bit-length values and ensures consistency across various data types.
The contract defines several structures to hold values and results for different bit-lengths:
AllGTCastingValues
: Holds 8-bit, 16-bit, 32-bit, and 64-bit unsigned integers.Check16
,Check32
,Check64
: Hold the results of operations for different bit-length combinations.CheckMul16
,CheckMul32
: Hold the multiplication results for different bit-length combinations.
result
: Stores an 8-bit result.result16
: Stores a 16-bit result.
getResult
: Returns the 8-bit result.getResult16
: Returns the 16-bit result.setPublicValues
: Sets the public values for different bit-lengths usingMpcCore.setPublic
methods.decryptAndCompareResults16
: Decrypts and compares 16-bit results to ensure consistency.decryptAndCompareResults32
: Decrypts and compares 32-bit results to ensure consistency.decryptAndCompareResults64
: Decrypts and compares 64-bit results to ensure consistency.
-
addTest
: Performs addition on the given 8-bit values and checks consistency across different bit-lengths:- Sets the public values for different bit-lengths.
- Calculates the expected result.
- Checks the addition results for 16-bit, 32-bit, and 64-bit values.
- Ensures the results are consistent across different data types and with scalars.
-
subTest
: Similar toaddTest
, but performs subtraction:- Sets the public values for different bit-lengths.
- Calculates the expected result.
- Checks the subtraction results for 16-bit, 32-bit, and 64-bit values.
- Ensures the results are consistent across different data types and with scalars.
-
mulTest
: Similar toaddTest
, but performs multiplication:- Sets the public values for different bit-lengths.
- Calculates the expected result.
- Checks the multiplication results for 16-bit, 32-bit, and 64-bit values.
- Ensures the results are consistent across different data types and with scalars.
The contract relies on the MpcCore
library for:
- Setting public values (
setPublic8
,setPublic16
,setPublic32
,setPublic64
). - Performing arithmetic operations (
add
,sub
,mul
). - Decrypting results (
decrypt
).
The contract ensures that arithmetic operations on various bit-length values are consistent and correct by performing the operations, decrypting the results, and comparing them across different types and combinations. This can be particularly useful for testing and validating the correctness of arithmetic operations in a decentralized environment.
Performs bitwise operations (AND, OR, XOR) on different bit-length values and ensures consistency across various data types.
The contract defines several structures to hold values and results for different bit-lengths:
AllGTCastingValues
: Holds 8-bit, 16-bit, 32-bit, and 64-bit unsigned integers.Check16
,Check32
,Check64
: Hold the results of operations for different bit-length combinations.
result
: Stores an 8-bit result.
getResult
: Returns the 8-bit result.setPublicValues
: Sets the public values for different bit-lengths usingMpcCore.setPublic
methods.decryptAndCompareResults16
: Decrypts and compares 16-bit results to ensure consistency.decryptAndCompareResults32
: Decrypts and compares 32-bit results to ensure consistency.decryptAndCompareResults64
: Decrypts and compares 64-bit results to ensure consistency.
-
andTest
: Performs bitwise AND on the given 8-bit values and checks consistency across different bit-lengths:- Sets the public values for different bit-lengths.
- Calculates the expected result.
- Checks the AND results for 16-bit, 32-bit, and 64-bit values.
- Ensures the results are consistent across different data types and with scalars.
-
orTest
: Similar toandTest
, but performs bitwise OR:- Sets the public values for different bit-lengths.
- Calculates the expected result.
- Checks the OR results for 16-bit, 32-bit, and 64-bit values.
- Ensures the results are consistent across different data types and with scalars.
-
xorTest
: Similar toandTest
, but performs bitwise XOR:- Sets the public values for different bit-lengths.
- Calculates the expected result.
- Checks the XOR results for 16-bit, 32-bit, and 64-bit values.
- Ensures the results are consistent across different data types and with scalars.
The contract relies on the MpcCore
library for:
- Setting public values (
setPublic8
,setPublic16
,setPublic32
,setPublic64
). - Performing bitwise operations (
and
,or
,xor
). - Decrypting results (
decrypt
).
The contract ensures that bitwise operations on various bit-length values are consistent and correct by performing the operations, decrypting the results, and comparing them across different types and combinations. This can be particularly useful for testing and validating the correctness of bitwise operations in a decentralized environment.
Performs comparison operations (greater than, less than or equal to, and less than) on different bit-length values and ensures consistency across various data types.
The contract defines several structures to hold values and results for different bit-lengths:
AllGTCastingValues
: Holds 8-bit, 16-bit, 32-bit, and 64-bit unsigned integers.Check16
,Check32
,Check64
: Hold the results of operations for different bit-length combinations.
result
: Stores a boolean result.
getResult
: Returns the boolean result.setPublicValues
: Sets the public values for different bit-lengths usingMpcCore.setPublic
methods.decryptAndCompareResults16
: Decrypts and compares 16-bit results to ensure consistency.decryptAndCompareResults32
: Decrypts and compares 32-bit results to ensure consistency.decryptAndCompareResults64
: Decrypts and compares 64-bit results to ensure consistency.
-
gtTest
: Performs a greater-than comparison on the given 8-bit values and checks consistency across different bit-lengths:- Sets the public values for different bit-lengths.
- Calculates the expected result.
- Checks the greater-than results for 16-bit, 32-bit, and 64-bit values.
- Ensures the results are consistent across different data types and with scalars.
-
leTest
: Similar togtTest
, but performs a less-than-or-equal-to comparison:- Sets the public values for different bit-lengths.
- Calculates the expected result.
- Checks the less-than-or-equal-to results for 16-bit, 32-bit, and 64-bit values.
- Ensures the results are consistent across different data types and with scalars.
-
ltTest
: Similar togtTest
, but performs a less-than comparison:- Sets the public values for different bit-lengths.
- Calculates the expected result.
- Checks the less-than results for 16-bit, 32-bit, and 64-bit values.
- Ensures the results are consistent across different data types and with scalars.
The contract relies on the MpcCore
library for:
- Setting public values (
setPublic8
,setPublic16
,setPublic32
,setPublic64
). - Performing comparison operations (
gt
,le
,lt
). - Decrypting results (
decrypt
).
The contract ensures that comparison operations on various bit-length values are consistent and correct by performing the operations, decrypting the results, and comparing them across different types and combinations. This can be particularly useful for testing and validating the correctness of comparison operations in a decentralized environment.
Performs additional comparison operations (equal to, not equal to, greater than or equal to) on different bit-length values and ensures consistency across various data types.
The contract defines several structures to hold values and results for different bit-lengths:
AllGTCastingValues
: Holds 8-bit, 16-bit, 32-bit, and 64-bit unsigned integers.Check16
,Check32
,Check64
: Hold the results of operations for different bit-length combinations.
result
: Stores a boolean result.
getResult
: Returns the boolean result.setPublicValues
: Sets the public values for different bit-lengths usingMpcCore.setPublic
methods.decryptAndCompareResults16
: Decrypts and compares 16-bit results to ensure consistency.decryptAndCompareResults32
: Decrypts and compares 32-bit results to ensure consistency.decryptAndCompareResults64
: Decrypts and compares 64-bit results to ensure consistency.
-
eqTest
: Performs an equal-to comparison on the given 8-bit values and checks consistency across different bit-lengths:- Sets the public values for different bit-lengths.
- Calculates the expected result.
- Checks the equal-to results for 16-bit, 32-bit, and 64-bit values.
- Ensures the results are consistent across different data types and with scalars.
-
neTest
: Similar toeqTest
, but performs a not-equal-to comparison:- Sets the public values for different bit-lengths.
- Calculates the expected result.
- Checks the not-equal-to results for 16-bit, 32-bit, and 64-bit values.
- Ensures the results are consistent across different data types and with scalars.
-
geTest
: Similar toeqTest
, but performs a greater-than-or-equal-to comparison:- Sets the public values for different bit-lengths.
- Calculates the expected result.
- Checks the greater-than-or-equal-to results for 16-bit, 32-bit, and 64-bit values.
- Ensures the results are consistent across different data types and with scalars.
The contract relies on the MpcCore
library for:
- Setting public values (
setPublic8
,setPublic16
,setPublic32
,setPublic64
). - Performing comparison operations (
eq
,ne
,ge
). - Decrypting results (
decrypt
).
The contract ensures that comparison operations on various bit-length values are consistent and correct by performing the operations, decrypting the results, and comparing them across different types and combinations. This can be particularly useful for testing and validating the correctness of comparison operations in a decentralized environment.
Performs minimum and maximum operations on different bit-length values and ensures consistency across various data types.
The contract defines several structures to hold values and results for different bit-lengths:
AllGTCastingValues
: Holds 8-bit, 16-bit, 32-bit, and 64-bit unsigned integers.Check16
,Check32
,Check64
: Hold the results of operations for different bit-length combinations.
result
: Stores an 8-bit result.
getResult
: Returns the 8-bit result.setPublicValues
: Sets the public values for different bit-lengths usingMpcCore.setPublic
methods.decryptAndCompareResults16
: Decrypts and compares 16-bit results to ensure consistency.decryptAndCompareResults32
: Decrypts and compares 32-bit results to ensure consistency.decryptAndCompareResults64
: Decrypts and compares 64-bit results to ensure consistency.
-
minTest
: Performs a minimum comparison on the given 8-bit values and checks consistency across different bit-lengths:- Sets the public values for different bit-lengths.
- Calculates the expected result.
- Checks the minimum results for 16-bit, 32-bit, and 64-bit values.
- Ensures the results are consistent across different data types and with scalars.
-
maxTest
: Similar tominTest
, but performs a maximum comparison:- Sets the public values for different bit-lengths.
- Calculates the expected result.
- Checks the maximum results for 16-bit, 32-bit, and 64-bit values.
- Ensures the results are consistent across different data types and with scalars.
The contract relies on the MpcCore
library for:
- Setting public values (
setPublic8
,setPublic16
,setPublic32
,setPublic64
). - Performing min/max operations (
min
,max
). - Decrypting results (
decrypt
).
The contract ensures that min/max operations on various bit-length values are consistent and correct by performing the operations, decrypting the results, and comparing them across different types and combinations. This can be particularly useful for testing and validating the correctness of min/max operations in a decentralized environment.
Performs various miscellaneous operations including random number generation and boolean logic operations.
random
: Stores a 64-bit random number.andRes
,orRes
,xorRes
,notRes
,eqRes
,neqRes
,muxRes
,onboardRes
: Store the results of boolean operations.
getRandom
: Returns the 64-bit random number.getBooleanResults
: Returns the results of the boolean operations as a tuple.
MAX_SIZE_8_BITS
: Maximum size for 8-bit operations.MAX_SIZE_16_BITS
: Maximum size for 16-bit operations.MAX_SIZE_32_BITS
: Maximum size for 32-bit operations.MAX_SIZE_64_BITS
: Maximum size for 64-bit operations.MAX_BOOL_SIZE
: Maximum size for boolean operations.
checkNotAllEqual
: Ensures that not all generated random numbers are equal.checkBound
: Ensures that all generated random numbers are within the specified bounds.
randomTest
: Generates random numbers and ensures they are not all equal.randomBoundedTest
: Generates bounded random numbers and ensures they are within the specified bounds.randTest_
: Core function for generating random numbers, both bounded and unbounded.
booleanTest
: Performs various boolean operations (AND, OR, XOR, NOT, EQ, NEQ, MUX) and stores the results.
The contract relies on the MpcCore
library for:
- Generating random numbers (
rand8
,rand16
,rand32
,rand64
). - Generating bounded random numbers (
randBoundedBits8
,randBoundedBits16
,randBoundedBits32
,randBoundedBits64
). - Performing boolean operations (
and
,or
,xor
,not
,eq
,ne
,mux
). - Decrypting results (
decrypt
). - Onboarding and offboarding boolean values (
offBoard
,onBoard
).
The contract ensures the correctness of random number generation and boolean operations by performing the operations, decrypting the results, and comparing them as necessary. This can be particularly useful for testing and validating the correctness of these operations in a decentralized environment.
Performs various miscellaneous operations including division, remainder, mux, offboard/onboard, and boolean NOT operations.
The contract defines several structures to hold values and results for different bit-lengths:
AllGTCastingValues
: Holds 8-bit, 16-bit, 32-bit, and 64-bit unsigned integers.Check16
,Check32
,Check64
: Hold the results of operations for different bit-length combinations.
result
: Stores an 8-bit result.boolResult
: Stores a boolean result.
getResult
: Returns the 8-bit result.getBoolResult
: Returns the boolean result.setPublicValues
: Sets the public values for different bit-lengths usingMpcCore.setPublic
methods.decryptAndCompareResults16
: Decrypts and compares 16-bit results to ensure consistency.decryptAndCompareResults32
: Decrypts and compares 32-bit results to ensure consistency.decryptAndCompareResults64
: Decrypts and compares 64-bit results to ensure consistency.
-
divTest
: Performs division on the given 8-bit values and checks consistency across different bit-lengths:- Sets the public values for different bit-lengths.
- Calculates the expected result.
- Checks the division results for 16-bit, 32-bit, and 64-bit values.
- Ensures the results are consistent across different data types and with scalars.
-
remTest
: Similar todivTest
, but performs remainder operation:- Sets the public values for different bit-lengths.
- Calculates the expected result.
- Checks the remainder results for 16-bit, 32-bit, and 64-bit values.
- Ensures the results are consistent across different data types and with scalars.
-
muxTest
: Performs a mux operation on the given 8-bit values and checks consistency across different bit-lengths:- Sets the public values for different bit-lengths.
- Calculates the expected result.
- Checks the mux results for 16-bit, 32-bit, and 64-bit values.
- Ensures the results are consistent across different data types and with scalars.
-
offboardOnboardTest
: Tests offboarding and onboarding of values:- Sets the public values for different bit-lengths.
- Offboards and onboards the values.
- Ensures the results are consistent across different data types.
-
notTest
: Performs a NOT operation on the given boolean value and returns the result.
The contract relies on the MpcCore
library for:
- Setting public values (
setPublic8
,setPublic16
,setPublic32
,setPublic64
). - Performing miscellaneous operations (
div
,rem
,mux
,not
,offBoard
,onBoard
). - Decrypting results (
decrypt
).
The contract ensures the correctness of various miscellaneous operations by performing the operations, decrypting the results, and comparing them as necessary. This can be particularly useful for testing and validating the correctness of these operations in a decentralized environment.
Performs operations involving offboarding data to a user key and handling various cryptographic operations.
userKey
: Stores the user's key as bytes.x
: Stores an 8-bit unsigned integer.ctUserKey
: Stores the ciphertext of the user's key.ct8
,ct16
,ct32
,ct64
: Store ciphertexts of various bit-lengths.
getCTs
: Returns the ciphertexts of various bit-lengths.getUserKeyTest
:- Sets a public 8-bit value
a
. - Adds
a
to 5 and offboards the result to the user's key. - Offboards the result to the system key and decrypts it.
- Returns the decrypted value.
- Sets a public 8-bit value
getX
: Returns the value ofx
.getUserKey
: Returns the user's key.getCt
: Returns the ciphertext of the user's key.userKeyTest
: Returns the user's key based on the signed encryption key and signature.offboardToUserTest
:- Sets public values for 8-bit, 16-bit, 32-bit, and 64-bit.
- Offboards these values to the user's key.
- Stores and returns the ciphertexts.
The contract relies on the MpcCore
library for:
- Setting public values (
setPublic8
,setPublic16
,setPublic32
,setPublic64
). - Performing arithmetic operations (
add
). - Offboarding data to the user's key (
offBoardToUser
). - Offboarding data to the system key (
offBoard
). - Onboarding data (
onBoard
). - Decrypting results (
decrypt
). - Retrieving the user's key (
getUserKey
).
The contract ensures the correctness of operations involving offboarding to user keys by performing the operations, decrypting the results, and comparing them as necessary. This can be particularly useful for testing and validating the correctness of these operations in a decentralized environment.
Performs various shift operations (left and right) on different bit-length values and ensures consistency across various data types.
The contract defines several structures to hold values and results for different bit-lengths:
AllGTCastingValues
: Holds 8-bit, 16-bit, 32-bit, and 64-bit unsigned integers.Check16
,Check32
,Check64
: Hold the results of operations for different bit-length combinations.
result
: Stores an 8-bit result.result16
: Stores a 16-bit result.result32
: Stores a 32-bit result.result64
: Stores a 64-bit result.
getResult
: Returns the 8-bit result.getAllShiftResults
: Returns the results of the shift operations as a tuple (8-bit, 16-bit, 32-bit, 64-bit).setPublicValues
: Sets the public values for different bit-lengths usingMpcCore.setPublic
methods.decryptAndCompareResults16
: Decrypts and compares 16-bit results to ensure consistency.decryptAndCompareResults32
: Decrypts and compares 32-bit results to ensure consistency.decryptAndCompareResults64
: Decrypts and compares 64-bit results to ensure consistency.
-
shlTest
: Performs a left shift on the given 8-bit values and checks consistency across different bit-lengths:- Sets the public values for different bit-lengths.
- Calculates the expected result.
- Checks the left shift results for 16-bit, 32-bit, and 64-bit values.
- Ensures the results are consistent across different data types and with scalars.
-
shrTest
: Similar toshlTest
, but performs a right shift:- Sets the public values for different bit-lengths.
- Calculates the expected result.
- Checks the right shift results for 16-bit, 32-bit, and 64-bit values.
- Ensures the results are consistent across different data types and with scalars.
The contract relies on the MpcCore
library for:
- Setting public values (
setPublic8
,setPublic16
,setPublic32
,setPublic64
). - Performing shift operations (
shl
,shr
). - Decrypting results (
decrypt
).
The contract ensures the correctness of shift operations on various bit-length values by performing the operations, decrypting the results, and comparing them as necessary. This can be particularly useful for testing and validating the correctness of these operations in a decentralized environment.
Performs transfer operations with scalar values, checking the correctness of these operations across different bit-length values.
The contract defines several structures to hold values and results for different bit-lengths:
AllGTCastingValues
: Holds 8-bit, 16-bit, 32-bit, and 64-bit unsigned integers.
new_a
: Stores the new value ofa
after the transfer.new_b
: Stores the new value ofb
after the transfer.res
: Stores the result of the transfer operation as a boolean.
getResults
: Returns the values ofnew_a
,new_b
, andres
.computeAndChekTransfer16
: Checks the transfer operation for 16-bit values with a scalar amount:- Ensures consistency of the operation for different bit-length combinations involving 16-bit values.
computeAndChekTransfer32
: Checks the transfer operation for 32-bit values with a scalar amount:- Ensures consistency of the operation for different bit-length combinations involving 32-bit values.
computeAndChekTransfer64
: Checks the transfer operation for 64-bit values with a scalar amount:- Ensures consistency of the operation for different bit-length combinations involving 64-bit values.
transferScalarTest
: Performs the transfer operation with a scalar amount and checks the results across different bit-length values:- Sets the public values for different bit-lengths.
- Calculates the expected result.
- Checks the transfer results for 16-bit, 32-bit, and 64-bit values.
- Ensures the results are consistent across different data types and with scalars.
The contract relies on the MpcCore
library for:
- Setting public values (
setPublic8
,setPublic16
,setPublic32
,setPublic64
). - Performing transfer operations (
transfer
). - Decrypting results (
decrypt
).
The contract ensures the correctness of transfer operations with scalar values by performing the operations, decrypting the results, and comparing them as necessary. This can be particularly useful for testing and validating the correctness of these operations in a decentralized environment.
Designed to test the transfer functionality of the MpcCore
library with different data types and casting scenarios. The contract includes several key components and functions.
AllGTCastingValues
: This struct holds various data types (8, 16, 32, and 64-bit unsigned integers) to be used in the transfer tests.AllAmountValues
: This struct holds different data types for the amount to be transferred, as well as an 8-bit unsigned integer amount.
newA
,newB
: These variables store the new values ofa
andb
after the transfer.result
: This boolean variable stores the result of the transfer.
getResults()
: A public view function that returns the current values ofnewA
,newB
, andresult
.computeAndChekTransfer16()
,computeAndChekTransfer32()
,computeAndChekTransfer64()
: These functions test the transfer functionality with different data types and casting scenarios (16, 32, and 64-bit). They use theMpcCore.transfer
function and compare the results with the expected values usingMpcCore.decrypt
.transferTest()
: This function initiates the transfer tests. It sets up the casting values and amount values, performs the transfer using 8-bit values, and then calls thecomputeAndChekTransfer16
,computeAndChekTransfer32
, andcomputeAndChekTransfer64
functions to test the transfer functionality with different casting scenarios.
The contract relies on the MpcCore
library for its core operations, which include:
MpcCore.transfer
: This function performs the transfer of values based on the provided casting and amount values.MpcCore.decrypt
: This function decrypts the results of the transfer to verify the correctness of the operation.MpcCore.setPublic*
: These functions set the public values for different data types (8, 16, 32, and 64-bit unsigned integers).
The PrecompilesTransferTestsContract
ensures that the transfer functionality of the MpcCore
library works correctly with various data types and casting scenarios by comparing the results of the MpcCore.transfer
function with the expected values using MpcCore.decrypt
.