Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

code adapt according to changes from crypto #340

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion common/prove/change_pub_key.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ func toCryptoChangePubKeyTx(txInfo *txtypes.ChangePubKeyInfo) (info *cryptoTypes
AccountIndex: txInfo.AccountIndex,
L1Address: common.AddressStrToBytes(txInfo.L1Address),
PubKey: pk,
Nonce: txInfo.Nonce,
GasFeeAssetId: txInfo.GasFeeAssetId,
GasFeeAssetAmount: packedFee,
}
Expand Down
2 changes: 0 additions & 2 deletions common/prove/create_collection.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,6 @@ func toCryptoCreateCollectionTx(txInfo *txtypes.CreateCollectionTxInfo) (info *c
GasAccountIndex: txInfo.GasAccountIndex,
GasFeeAssetId: txInfo.GasFeeAssetId,
GasFeeAssetAmount: packedFee,
ExpiredAt: txInfo.ExpiredAt,
Nonce: txInfo.Nonce,
}
return info, nil
}
1 change: 0 additions & 1 deletion common/prove/mint_nft.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ func toCryptoMintNftTx(txInfo *txtypes.MintNftTxInfo) (info *cryptoTypes.MintNft
GasFeeAssetId: txInfo.GasFeeAssetId,
GasFeeAssetAmount: packedFee,
CollectionId: txInfo.NftCollectionId,
ExpiredAt: txInfo.ExpiredAt,
NftContentType: txInfo.NftContentType,
}
return info, nil
Expand Down
5 changes: 1 addition & 4 deletions common/prove/withdraw.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@
package prove

import (
"math/big"

"github.com/consensys/gnark-crypto/ecc/bn254/twistededwards/eddsa"

cryptoTypes "github.com/bnb-chain/zkbnb-crypto/circuit/types"
Expand Down Expand Up @@ -53,15 +51,14 @@ func toCryptoWithdrawTx(txInfo *txtypes.WithdrawTxInfo) (info *cryptoTypes.Withd
if err != nil {
return nil, err
}
addrBytes := txtypes.PaddingAddressToBytes32(txInfo.ToAddress)
info = &cryptoTypes.WithdrawTx{
FromAccountIndex: txInfo.FromAccountIndex,
AssetId: txInfo.AssetId,
AssetAmount: txInfo.AssetAmount,
GasAccountIndex: txInfo.GasAccountIndex,
GasFeeAssetId: txInfo.GasFeeAssetId,
GasFeeAssetAmount: packedFee,
ToAddress: new(big.Int).SetBytes(addrBytes),
ToAddress: common.AddressStrToBytes(txInfo.ToAddress),
}
return info, nil
}
2 changes: 1 addition & 1 deletion common/prove/withdraw_nft.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func toCryptoWithdrawNftTx(txInfo *txtypes.WithdrawNftTxInfo) (info *cryptoTypes
RoyaltyRate: txInfo.RoyaltyRate,
NftIndex: txInfo.NftIndex,
NftContentHash: txInfo.NftContentHash,
ToAddress: txInfo.ToAddress,
ToAddress: common.AddressStrToBytes(txInfo.ToAddress),
GasAccountIndex: txInfo.GasAccountIndex,
GasFeeAssetId: txInfo.GasFeeAssetId,
GasFeeAssetAmount: packedFee,
Expand Down
2 changes: 2 additions & 0 deletions common/prove/witness_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,7 @@ func (w *WitnessHelper) constructAccountWitness(
w.gasAccountInfo.Nonce = nonce
w.gasAccountInfo.CollectionNonce = collectionNonce
w.gasAccountInfo.AssetRoot = common.Bytes2Hex(w.assetTrees.Get(accountKey).Root())
w.gasAccountInfo.PublicKey = nPubKey
}

// set account info before
Expand Down Expand Up @@ -841,6 +842,7 @@ func (w *WitnessHelper) ResetCache(height int64) error {
gasAccount.CollectionNonce = history.CollectionNonce
gasAccount.AssetInfo = history.AssetInfo
gasAccount.AssetRoot = history.AssetRoot
gasAccount.PublicKey = history.PublicKey
formatGasAccount, err := chain.ToFormatAccountInfo(gasAccount)
if err != nil {
return err
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ require (
)

require (
github.com/bnb-chain/zkbnb-crypto v0.0.8-0.20230616090644-79f2f1c77e61
github.com/bnb-chain/zkbnb-crypto v0.0.8-0.20230627022843-b2a562cd2f69
github.com/bnb-chain/zkbnb-eth-rpc v0.0.3-0.20230605074525-1c3e46d3b694
github.com/bnb-chain/zkbnb-smt v0.0.3-0.20230519064631-0f9993341ee0
github.com/consensys/gnark v0.8.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,8 @@ github.com/bnb-chain/gnark v0.7.2-0.20230425010344-8e482963e1ae h1:4b/b0pp1RAWQ6
github.com/bnb-chain/gnark v0.7.2-0.20230425010344-8e482963e1ae/go.mod h1:fmHUzzss1n32K3COWMvrQj7uo7GjIeIr1wXzjj5gmj8=
github.com/bnb-chain/gnark-crypto v0.8.1-0.20230412133626-30223a679fb7 h1:ME5Nif4WgGgWKH2omB6ybic5bsU22bHy43xBsgMBHgM=
github.com/bnb-chain/gnark-crypto v0.8.1-0.20230412133626-30223a679fb7/go.mod h1:a2DQL4+5ywF6safEeZFEPGRiiGbjzGFRUN2sg06VuU4=
github.com/bnb-chain/zkbnb-crypto v0.0.8-0.20230616090644-79f2f1c77e61 h1:3v9Sd4mMPpQboZDE65rPlWkmcznT1pKQxE2qJQRtyVg=
github.com/bnb-chain/zkbnb-crypto v0.0.8-0.20230616090644-79f2f1c77e61/go.mod h1:Bi+kI5RYhV3Fgu6upQyAXz2HVxp+Ah9AzvwIBuBDYMM=
github.com/bnb-chain/zkbnb-crypto v0.0.8-0.20230627022843-b2a562cd2f69 h1:Nqt3ttCcUFVVl2rYRcfamIPGUpDVL/LEeURD57RtFRQ=
github.com/bnb-chain/zkbnb-crypto v0.0.8-0.20230627022843-b2a562cd2f69/go.mod h1:Bi+kI5RYhV3Fgu6upQyAXz2HVxp+Ah9AzvwIBuBDYMM=
github.com/bnb-chain/zkbnb-eth-rpc v0.0.3-0.20230605074525-1c3e46d3b694 h1:UeTRF5m2TmCXFTaMxbwhY5PYp5QYFyXv5+MGCCb1L28=
github.com/bnb-chain/zkbnb-eth-rpc v0.0.3-0.20230605074525-1c3e46d3b694/go.mod h1:zZ9uTj1GJOc5OxgojQbA8TZjEQhESUnp4MEWOYk/OVs=
github.com/bnb-chain/zkbnb-go-sdk v1.0.7-0.20230522134048-bcfa8070ef7e h1:jwUKimro0Rgv0kO7yenoVvL5BaEXxGZ7JZddX45m+FY=
Expand Down