Zeth - Zerocash on Ethereum  0.8
Reference implementation of the Zeth protocol by Clearmatics
Public Member Functions | Static Public Member Functions | List of all members
test_contracts.test_bls12_377_contract.TestBLS12_377Contract Class Reference
Inheritance diagram for test_contracts.test_bls12_377_contract.TestBLS12_377Contract:
Inheritance graph
[legend]
Collaboration diagram for test_contracts.test_bls12_377_contract.TestBLS12_377Contract:
Collaboration graph
[legend]

Public Member Functions

None test_bls12_ecadd (self)
 
None test_bls12_ecmul (self)
 
None test_bls12_ecpairing (self)
 

Static Public Member Functions

None setUpClass ()
 

Detailed Description

Definition at line 81 of file test_bls12_377_contract.py.

Member Function Documentation

◆ setUpClass()

None test_contracts.test_bls12_377_contract.TestBLS12_377Contract.setUpClass ( )
static

Definition at line 84 of file test_bls12_377_contract.py.

84  def setUpClass() -> None:
85  print("Deploying TestBLS12_377.sol")
86  _web3, eth = mock.open_test_web3()
87  _bls12_interface, bls12_instance = mock.deploy_contract(
88  eth,
89  eth.accounts[0],
90  "TestBLS12_377",
91  {})
92  global BLS12_INSTANCE # pylint: disable=global-statement
93  BLS12_INSTANCE = bls12_instance
94 

◆ test_bls12_ecadd()

None test_contracts.test_bls12_377_contract.TestBLS12_377Contract.test_bls12_ecadd (   self)
Check that [6] == [2] + [4]

Definition at line 95 of file test_bls12_377_contract.py.

95  def test_bls12_ecadd(self) -> None:
96  """
97  Check that [6] == [2] + [4]
98  """
99  result = BLS12_INSTANCE.functions.testECAdd(G1_2 + G1_4).call()
100  self.assertEqual(G1_6, result)
101 

◆ test_bls12_ecmul()

None test_contracts.test_bls12_377_contract.TestBLS12_377Contract.test_bls12_ecmul (   self)
Check that [-8] == -2 * [4]

Definition at line 102 of file test_bls12_377_contract.py.

102  def test_bls12_ecmul(self) -> None:
103  """
104  Check that [-8] == -2 * [4]
105  """
106  result = BLS12_INSTANCE.functions.testECMul(G1_4 + FR_MINUS_2).call()
107  self.assertEqual(G1_MINUS_8, result)
108 

◆ test_bls12_ecpairing()

None test_contracts.test_bls12_377_contract.TestBLS12_377Contract.test_bls12_ecpairing (   self)
Check that e([6], [4]) * e([3],[8]) * e([4],[4]) * e([-8], [8]) == 1

Definition at line 109 of file test_bls12_377_contract.py.

109  def test_bls12_ecpairing(self) -> None:
110  """
111  Check that e([6], [4]) * e([3],[8]) * e([4],[4]) * e([-8], [8]) == 1
112  """
113  # Note, return result here is uint256(1) or uint256(0) depending on the
114  # pairing check result.
115  points = G1_6 + G2_4 + G1_3 + G2_8 + G1_4 + G2_4 + G1_MINUS_8 + G2_8
116  result = BLS12_INSTANCE.functions.testECPairing(points).call()
117  self.assertEqual(1, result)
118 
119  points = G1_6 + G2_4 + G1_3 + G2_8 + G1_4 + G2_4 + G1_MINUS_8 + G2_4
120  result = BLS12_INSTANCE.functions.testECPairing(points).call()
121  self.assertEqual(0, result)

The documentation for this class was generated from the following file: