Skip to content

Commit

Permalink
Testnet rampup
Browse files Browse the repository at this point in the history
  • Loading branch information
eitanz-coti committed Sep 17, 2024
1 parent fd72263 commit 88b86ed
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion confidentiality-contracts
22 changes: 11 additions & 11 deletions examples/precompiles/precompiles_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,9 @@ def get_user_key(tx_params):
tx_receipt = exec_func_via_transaction(func, tx_params)
print(tx_receipt)
make_sure_tx_didnt_fail(tx_receipt)
encrypted_user_key = tx_receipt.logs[0].data[64:]
decrypted_aes_key = decrypt_rsa(private_key, encrypted_user_key)
result1, result2, result3, result4, result5, result6, result7, result8 \
= get_result(contract, "getUserKeyShares")
decrypted_aes_key = recover_user_key(private_key, result1, result2)
return decrypted_aes_key


Expand Down Expand Up @@ -108,7 +109,7 @@ def test(function_name, kwargs, expected_result1, get_result_function_name, tx_p
return
if function_name == "offboardToUserTest":
return result1, result2, result3, result4
if get_result_function_name == "getRandom":
if get_result_function_name == "getRandom" or get_result_function_name == "getRandomBounded":
assert result1 != expected_result1
last_random_value = result1
return
Expand Down Expand Up @@ -156,26 +157,25 @@ def run_tests(a, b, shift, bit, numBits, bool_a, bool_b, tx_params):
test("ltTest", {'a': a, 'b': b}, a < b, "getLtResult", tx_params)
test("muxTest", {'selectionBit': bit, 'a': a, 'b': b}, a if bit == 0 else b, "getMuxResult", tx_params)
test("transferTest", {'amount': b, 'a': a, 'b': b}, a - b, "getResults", tx_params, b + b)
test("transferScalarTest", {'amount': b, 'a': a, 'b': b}, a - b, "getResults", tx_params, b + b)
test("offboardOnboardTest", {'a8': a, 'a16': a, 'a32': a, 'a64': a}, a, "getOnboardOffboardResult", tx_params)
test("notTest", {'a': bit}, not bit, "getBoolResult", tx_params)
test_user_key("offboardToUserTest", {'a': a, 'addr': tx_params['web3'].eth.default_account.address},
a, "getCTs", tx_params)
test_user_key_failure("offboardToUserTest", {'a': a, 'addr': tx_params['web3'].eth.default_account.address},
a, "getCTs", tx_params)
test("randomTest", {}, last_random_value, "getRandom", tx_params)
test("randomBoundedTest", {'numBits': numBits}, last_random_value, "getRandomBounded", tx_params)
test("booleanTest", {"a": bool_a, "b": bool_b, "bit": bit}, bool_a and bool_b,
"getBooleanResults", tx_params, bool_a or bool_b, bool_a ^ bool_b, not bool_a,
bool_a == bool_b, bool_a != bool_b, bool_b if bit else bool_a, bool_a)
test("transferScalarTest", {'amount': b, 'a': a, 'b': b}, a - b, "getResults", tx_params, b + b)



# *** Not supported in testnet
# test("randomBoundedTest", {'numBits': numBits}, last_random_value, "getRandom", tx_params)
# test("shlTest", {'a': a, 'b': shift}, (a << shift) & 0xFF, "getAllShiftResults",
# tx_params, (a << shift) & 0xFFFF, (a << shift) & 0xFFFFFFFF, (a << shift) & 0xFFFFFFFFFFFFFFFF)
# test("shrTest", {'a': a, 'b': shift}, a >> shift, "getResult", tx_params)
# test_user_key("offboardToUserTest", {'a': a, 'addr': tx_params['web3'].eth.default_account.address},
# a, "getCTs", tx_params)
# test_user_key_failure("offboardToUserTest", {'a': a, 'addr': tx_params['web3'].eth.default_account.address},
# a, "getCTs", tx_params)




def main():
Expand Down

0 comments on commit 88b86ed

Please sign in to comment.