Skip to content

Commit

Permalink
rename internal var vs. public func params
Browse files Browse the repository at this point in the history
Signed-off-by: Jim Zhang <[email protected]>
  • Loading branch information
jimthematrix committed Dec 16, 2024
1 parent e02bf1c commit 30b3715
Show file tree
Hide file tree
Showing 16 changed files with 181 additions and 178 deletions.
2 changes: 1 addition & 1 deletion go-sdk/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ require (
github.com/iden3/go-rapidsnark/types v0.0.2 // indirect
github.com/iden3/go-rapidsnark/witness/v2 v2.0.0
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
golang.org/x/crypto v0.30.0 // indirect
golang.org/x/crypto v0.31.0 // indirect
golang.org/x/sys v0.28.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
gorm.io/driver/postgres v1.5.9
Expand Down
2 changes: 2 additions & 0 deletions go-sdk/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ github.com/x-cray/logrus-prefixed-formatter v0.5.2 h1:00txxvfBM9muc0jiLIEAkAcIMJ
github.com/x-cray/logrus-prefixed-formatter v0.5.2/go.mod h1:2duySbKsL6M18s5GU7VPsoEPHyzalCE06qoARUCeBBE=
golang.org/x/crypto v0.30.0 h1:RwoQn3GkWiMkzlX562cLB7OxWvjH1L8xutO2WoJcRoY=
golang.org/x/crypto v0.30.0/go.mod h1:kDsLvtWBEx7MV9tJOj9bnXsPbxwJQ6csT/x4KIN4Ssk=
golang.org/x/crypto v0.31.0 h1:ihbySMvVjLAeSH1IbfcRTkD/iNscyz8rGzjF/E5hV6U=
golang.org/x/crypto v0.31.0/go.mod h1:kDsLvtWBEx7MV9tJOj9bnXsPbxwJQ6csT/x4KIN4Ssk=
golang.org/x/net v0.21.0 h1:AQyQV4dYCvJ7vGmJyKki9+PBdyvhkSd8EIx/qb0AYv4=
golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44=
golang.org/x/sync v0.10.0 h1:3NQrjDixjgGwUOCaF8w2+VYHv0Ve/vGYSbdkTa98gmQ=
Expand Down
14 changes: 7 additions & 7 deletions go-sdk/integration-test/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ func (s *E2ETestSuite) TearDownSuite() {
assert.NoError(s.T(), err)
}

func (s *E2ETestSuite) TestZeto_1_SuccessfulProving() {
func (s *E2ETestSuite) TestZeto_anon_SuccessfulProving() {
calc, provingKey, err := loadCircuit("anon")
assert.NoError(s.T(), err)
assert.NotNil(s.T(), calc)
Expand Down Expand Up @@ -193,7 +193,7 @@ func (s *E2ETestSuite) TestZeto_1_SuccessfulProving() {
assert.Equal(s.T(), 4, len(proof.PubSignals))
}

func (s *E2ETestSuite) TestZeto_2_SuccessfulProving() {
func (s *E2ETestSuite) TestZeto_anon_enc_SuccessfulProving() {
calc, provingKey, err := loadCircuit("anon_enc")
assert.NoError(s.T(), err)
assert.NotNil(s.T(), calc)
Expand Down Expand Up @@ -271,7 +271,7 @@ func (s *E2ETestSuite) TestZeto_2_SuccessfulProving() {
assert.Equal(s.T(), output1.String(), calculatedHash.String())
}

func (s *E2ETestSuite) TestZeto_3_SuccessfulProving() {
func (s *E2ETestSuite) TestZeto_anon_nullifier_SuccessfulProving() {
calc, provingKey, err := loadCircuit("anon_nullifier")
assert.NoError(s.T(), err)
assert.NotNil(s.T(), calc)
Expand Down Expand Up @@ -355,7 +355,7 @@ func (s *E2ETestSuite) TestZeto_3_SuccessfulProving() {
assert.Equal(s.T(), 7, len(proof.PubSignals))
}

func (s *E2ETestSuite) TestZeto_4_SuccessfulProving() {
func (s *E2ETestSuite) TestZeto_anon_enc_nullifier_SuccessfulProving() {
calc, provingKey, err := loadCircuit("anon_enc_nullifier")
assert.NoError(s.T(), err)
assert.NotNil(s.T(), calc)
Expand Down Expand Up @@ -444,7 +444,7 @@ func (s *E2ETestSuite) TestZeto_4_SuccessfulProving() {
assert.Equal(s.T(), 18, len(proof.PubSignals))
}

func (s *E2ETestSuite) TestZeto_5_SuccessfulProving() {
func (s *E2ETestSuite) TestZeto_nf_anon_SuccessfulProving() {
calc, provingKey, err := loadCircuit("nf_anon")
assert.NoError(s.T(), err)
assert.NotNil(s.T(), calc)
Expand Down Expand Up @@ -503,7 +503,7 @@ func (s *E2ETestSuite) TestZeto_5_SuccessfulProving() {

}

func (s *E2ETestSuite) TestZeto_5_SuccessfulProvingWithConcurrency() {
func (s *E2ETestSuite) TestZeto_nf_anon_SuccessfulProvingWithConcurrency() {
concurrency := 10
resultChan := make(chan struct{}, concurrency)

Expand Down Expand Up @@ -582,7 +582,7 @@ func (s *E2ETestSuite) TestZeto_5_SuccessfulProvingWithConcurrency() {

}

func (s *E2ETestSuite) TestZeto_6_SuccessfulProving() {
func (s *E2ETestSuite) TestZeto_nf_anon_nullifier_SuccessfulProving() {
calc, provingKey, err := loadCircuit("nf_anon_nullifier")
assert.NoError(s.T(), err)
assert.NotNil(s.T(), calc)
Expand Down
18 changes: 9 additions & 9 deletions solidity/contracts/lib/zeto_fungible.sol
Original file line number Diff line number Diff line change
Expand Up @@ -25,23 +25,23 @@ import {OwnableUpgradeable} from "@openzeppelin/contracts-upgradeable/access/Own
/// @author Kaleido, Inc.
/// @dev Defines the verifier library for checking UTXOs against a claimed value.
abstract contract ZetoFungible is OwnableUpgradeable {
// depositVerifier library for checking UTXOs against a claimed value.
// _depositVerifier library for checking UTXOs against a claimed value.
// this can be used in the optional deposit calls to verify that
// the UTXOs match the deposited value
Groth16Verifier_CheckHashesValue internal depositVerifier;
Groth16Verifier_CheckHashesValue internal _depositVerifier;

error WithdrawArrayTooLarge(uint256 maxAllowed);

IERC20 internal erc20;
IERC20 internal _erc20;

function __ZetoFungible_init(
Groth16Verifier_CheckHashesValue _depositVerifier
Groth16Verifier_CheckHashesValue depositVerifier
) public onlyInitializing {
depositVerifier = _depositVerifier;
_depositVerifier = depositVerifier;
}

function setERC20(IERC20 _erc20) public onlyOwner {
erc20 = _erc20;
function setERC20(IERC20 erc20) public onlyOwner {
_erc20 = erc20;
}

function _deposit(
Expand All @@ -59,7 +59,7 @@ abstract contract ZetoFungible is OwnableUpgradeable {

// Check the proof
require(
depositVerifier.verifyProof(
_depositVerifier.verifyProof(
proof.pA,
proof.pB,
proof.pC,
Expand All @@ -69,7 +69,7 @@ abstract contract ZetoFungible is OwnableUpgradeable {
);

require(
erc20.transferFrom(msg.sender, address(this), amount),
_erc20.transferFrom(msg.sender, address(this), amount),
"Failed to transfer ERC20 tokens"
);
}
Expand Down
23 changes: 12 additions & 11 deletions solidity/contracts/lib/zeto_fungible_withdraw.sol
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,18 @@ abstract contract ZetoFungibleWithdraw is ZetoFungible {
// nullifierVerifier library for checking nullifiers against a claimed value.
// this can be used in the optional withdraw calls to verify that the nullifiers
// match the withdrawn value
Groth16Verifier_CheckInputsOutputsValue internal withdrawVerifier;
Groth16Verifier_CheckInputsOutputsValueBatch internal batchWithdrawVerifier;
Groth16Verifier_CheckInputsOutputsValue internal _withdrawVerifier;
Groth16Verifier_CheckInputsOutputsValueBatch
internal _batchWithdrawVerifier;

function __ZetoFungibleWithdraw_init(
Groth16Verifier_CheckHashesValue _depositVerifier,
Groth16Verifier_CheckInputsOutputsValue _withdrawVerifier,
Groth16Verifier_CheckInputsOutputsValueBatch _batchWithdrawVerifier
Groth16Verifier_CheckHashesValue depositVerifier,
Groth16Verifier_CheckInputsOutputsValue withdrawVerifier,
Groth16Verifier_CheckInputsOutputsValueBatch batchWithdrawVerifier
) public onlyInitializing {
__ZetoFungible_init(_depositVerifier);
withdrawVerifier = _withdrawVerifier;
batchWithdrawVerifier = _batchWithdrawVerifier;
__ZetoFungible_init(depositVerifier);
_withdrawVerifier = withdrawVerifier;
_batchWithdrawVerifier = batchWithdrawVerifier;
}

function constructPublicInputs(
Expand Down Expand Up @@ -92,7 +93,7 @@ abstract contract ZetoFungibleWithdraw is ZetoFungible {
}
// Check the proof
require(
batchWithdrawVerifier.verifyProof(
_batchWithdrawVerifier.verifyProof(
proof.pA,
proof.pB,
proof.pC,
Expand All @@ -114,7 +115,7 @@ abstract contract ZetoFungibleWithdraw is ZetoFungible {
}
// Check the proof
require(
withdrawVerifier.verifyProof(
_withdrawVerifier.verifyProof(
proof.pA,
proof.pB,
proof.pC,
Expand All @@ -125,7 +126,7 @@ abstract contract ZetoFungibleWithdraw is ZetoFungible {
}

require(
erc20.transfer(msg.sender, amount),
_erc20.transfer(msg.sender, amount),
"Failed to transfer ERC20 tokens"
);
}
Expand Down
22 changes: 11 additions & 11 deletions solidity/contracts/lib/zeto_fungible_withdraw_nullifier.sol
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,17 @@ abstract contract ZetoFungibleWithdrawWithNullifiers is ZetoFungible {
// nullifierVerifier library for checking nullifiers against a claimed value.
// this can be used in the optional withdraw calls to verify that the nullifiers
// match the withdrawn value
Groth16Verifier_CheckNullifierValue internal withdrawVerifier;
Groth16Verifier_CheckNullifierValueBatch internal batchWithdrawVerifier;
Groth16Verifier_CheckNullifierValue internal _withdrawVerifier;
Groth16Verifier_CheckNullifierValueBatch internal _batchWithdrawVerifier;

function __ZetoFungibleWithdrawWithNullifiers_init(
Groth16Verifier_CheckHashesValue _depositVerifier,
Groth16Verifier_CheckNullifierValue _withdrawVerifier,
Groth16Verifier_CheckNullifierValueBatch _batchWithdrawVerifier
Groth16Verifier_CheckHashesValue depositVerifier,
Groth16Verifier_CheckNullifierValue withdrawVerifier,
Groth16Verifier_CheckNullifierValueBatch batchWithdrawVerifier
) internal onlyInitializing {
__ZetoFungible_init(_depositVerifier);
withdrawVerifier = _withdrawVerifier;
batchWithdrawVerifier = _batchWithdrawVerifier;
__ZetoFungible_init(depositVerifier);
_withdrawVerifier = withdrawVerifier;
_batchWithdrawVerifier = batchWithdrawVerifier;
}

function constructPublicInputs(
Expand Down Expand Up @@ -103,7 +103,7 @@ abstract contract ZetoFungibleWithdrawWithNullifiers is ZetoFungible {
}
// Check the proof
require(
batchWithdrawVerifier.verifyProof(
_batchWithdrawVerifier.verifyProof(
proof.pA,
proof.pB,
proof.pC,
Expand All @@ -126,7 +126,7 @@ abstract contract ZetoFungibleWithdrawWithNullifiers is ZetoFungible {
}
// Check the proof
require(
withdrawVerifier.verifyProof(
_withdrawVerifier.verifyProof(
proof.pA,
proof.pB,
proof.pC,
Expand All @@ -137,7 +137,7 @@ abstract contract ZetoFungibleWithdrawWithNullifiers is ZetoFungible {
}

require(
erc20.transfer(msg.sender, amount),
_erc20.transfer(msg.sender, amount),
"Failed to transfer ERC20 tokens"
);
}
Expand Down
16 changes: 8 additions & 8 deletions solidity/contracts/lib/zeto_lock.sol
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,15 @@ abstract contract ZetoLock is IZetoBase, IZetoLockable, OwnableUpgradeable {
// by the same party that did the locking.
mapping(uint256 => address) internal lockedUTXOs;

ILockVerifier internal lockVerifier;
IBatchLockVerifier internal batchLockVerifier;
ILockVerifier internal _lockVerifier;
IBatchLockVerifier internal _batchLockVerifier;

function __ZetoLock_init(
ILockVerifier _lockVerifier,
IBatchLockVerifier _batchLockVerifier
ILockVerifier lockVerifier,
IBatchLockVerifier batchLockVerifier
) public onlyInitializing {
lockVerifier = _lockVerifier;
batchLockVerifier = IBatchLockVerifier(_batchLockVerifier);
_lockVerifier = lockVerifier;
_batchLockVerifier = batchLockVerifier;
}

// should be called by escrow contracts that will use uploaded proofs
Expand Down Expand Up @@ -112,14 +112,14 @@ abstract contract ZetoLock is IZetoBase, IZetoLockable, OwnableUpgradeable {
uint256[2] memory utxos,
Commonlib.Proof calldata proof
) internal view returns (bool) {
return lockVerifier.verifyProof(proof.pA, proof.pB, proof.pC, utxos);
return _lockVerifier.verifyProof(proof.pA, proof.pB, proof.pC, utxos);
}

function _verifyBatchLockProof(
uint256[10] memory utxos,
Commonlib.Proof calldata proof
) internal view returns (bool) {
return
batchLockVerifier.verifyProof(proof.pA, proof.pB, proof.pC, utxos);
_batchLockVerifier.verifyProof(proof.pA, proof.pB, proof.pC, utxos);
}
}
34 changes: 17 additions & 17 deletions solidity/contracts/zeto_anon.sol
Original file line number Diff line number Diff line change
Expand Up @@ -49,28 +49,28 @@ contract Zeto_Anon is
ZetoLock,
UUPSUpgradeable
{
Groth16Verifier_Anon internal verifier;
Groth16Verifier_AnonBatch internal batchVerifier;
Groth16Verifier_Anon internal _verifier;
Groth16Verifier_AnonBatch internal _batchVerifier;

function initialize(
address initialOwner,
Groth16Verifier_Anon _verifier,
Groth16Verifier_CheckHashesValue _depositVerifier,
Groth16Verifier_CheckInputsOutputsValue _withdrawVerifier,
Groth16Verifier_AnonBatch _batchVerifier,
Groth16Verifier_CheckInputsOutputsValueBatch _batchWithdrawVerifier,
ILockVerifier _lockVerifier,
IBatchLockVerifier _batchLockVerifier
Groth16Verifier_Anon verifier,
Groth16Verifier_CheckHashesValue depositVerifier,
Groth16Verifier_CheckInputsOutputsValue withdrawVerifier,
Groth16Verifier_AnonBatch batchVerifier,
Groth16Verifier_CheckInputsOutputsValueBatch batchWithdrawVerifier,
ILockVerifier lockVerifier,
IBatchLockVerifier batchLockVerifier
) public initializer {
__ZetoBase_init(initialOwner);
__ZetoFungibleWithdraw_init(
_depositVerifier,
_withdrawVerifier,
_batchWithdrawVerifier
depositVerifier,
withdrawVerifier,
batchWithdrawVerifier
);
__ZetoLock_init(_lockVerifier, _batchLockVerifier);
verifier = _verifier;
batchVerifier = _batchVerifier;
__ZetoLock_init(lockVerifier, batchLockVerifier);
_verifier = verifier;
_batchVerifier = batchVerifier;
}

function _authorizeUpgrade(address) internal override onlyOwner {}
Expand Down Expand Up @@ -132,7 +132,7 @@ contract Zeto_Anon is

// Check the proof using batchVerifier
require(
batchVerifier.verifyProof(
_batchVerifier.verifyProof(
proof.pA,
proof.pB,
proof.pC,
Expand All @@ -153,7 +153,7 @@ contract Zeto_Anon is
}
// Check the proof
require(
verifier.verifyProof(
_verifier.verifyProof(
proof.pA,
proof.pB,
proof.pC,
Expand Down
34 changes: 17 additions & 17 deletions solidity/contracts/zeto_anon_enc.sol
Original file line number Diff line number Diff line change
Expand Up @@ -51,28 +51,28 @@ contract Zeto_AnonEnc is
ZetoLock,
UUPSUpgradeable
{
Groth16Verifier_AnonEnc internal verifier;
Groth16Verifier_AnonEncBatch internal batchVerifier;
Groth16Verifier_AnonEnc internal _verifier;
Groth16Verifier_AnonEncBatch internal _batchVerifier;

function initialize(
address initialOwner,
Groth16Verifier_AnonEnc _verifier,
Groth16Verifier_CheckHashesValue _depositVerifier,
Groth16Verifier_CheckInputsOutputsValue _withdrawVerifier,
Groth16Verifier_AnonEncBatch _batchVerifier,
Groth16Verifier_CheckInputsOutputsValueBatch _batchWithdrawVerifier,
ILockVerifier _lockVerifier,
IBatchLockVerifier _batchLockVerifier
Groth16Verifier_AnonEnc verifier,
Groth16Verifier_CheckHashesValue depositVerifier,
Groth16Verifier_CheckInputsOutputsValue withdrawVerifier,
Groth16Verifier_AnonEncBatch batchVerifier,
Groth16Verifier_CheckInputsOutputsValueBatch batchWithdrawVerifier,
ILockVerifier lockVerifier,
IBatchLockVerifier batchLockVerifier
) public initializer {
__ZetoBase_init(initialOwner);
__ZetoFungibleWithdraw_init(
_depositVerifier,
_withdrawVerifier,
_batchWithdrawVerifier
depositVerifier,
withdrawVerifier,
batchWithdrawVerifier
);
__ZetoLock_init(_lockVerifier, _batchLockVerifier);
verifier = _verifier;
batchVerifier = _batchVerifier;
__ZetoLock_init(lockVerifier, batchLockVerifier);
_verifier = verifier;
_batchVerifier = batchVerifier;
}

function _authorizeUpgrade(address) internal override onlyOwner {}
Expand Down Expand Up @@ -154,7 +154,7 @@ contract Zeto_AnonEnc is

// Check the proof using batchVerifier
require(
batchVerifier.verifyProof(
_batchVerifier.verifyProof(
proof.pA,
proof.pB,
proof.pC,
Expand All @@ -178,7 +178,7 @@ contract Zeto_AnonEnc is
}
// Check the proof
require(
verifier.verifyProof(
_verifier.verifyProof(
proof.pA,
proof.pB,
proof.pC,
Expand Down
Loading

0 comments on commit 30b3715

Please sign in to comment.