Skip to content

Commit

Permalink
Try remove privacy pkg (#466)
Browse files Browse the repository at this point in the history
* try removing privacy pkg

* rm more reference

* trigger CI
  • Loading branch information
wanwiset25 committed Mar 4, 2024
1 parent e324d7d commit b86c7f6
Show file tree
Hide file tree
Showing 6 changed files with 1 addition and 2,926 deletions.
43 changes: 1 addition & 42 deletions core/vm/contracts.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ import (
"errors"
"math/big"

"github.com/XinFinOrg/XDPoSChain/core/vm/privacy"

"github.com/XinFinOrg/XDPoSChain/common"
"github.com/XinFinOrg/XDPoSChain/common/math"
"github.com/XinFinOrg/XDPoSChain/crypto"
Expand Down Expand Up @@ -63,8 +61,6 @@ var PrecompiledContractsByzantium = map[common.Address]PrecompiledContract{
common.BytesToAddress([]byte{6}): &bn256AddByzantium{},
common.BytesToAddress([]byte{7}): &bn256ScalarMulByzantium{},
common.BytesToAddress([]byte{8}): &bn256PairingByzantium{},
common.BytesToAddress([]byte{30}): &ringSignatureVerifier{},
common.BytesToAddress([]byte{40}): &bulletproofVerifier{},
common.BytesToAddress([]byte{41}): &XDCxLastPrice{},
common.BytesToAddress([]byte{42}): &XDCxEpochPrice{},
}
Expand All @@ -81,8 +77,6 @@ var PrecompiledContractsIstanbul = map[common.Address]PrecompiledContract{
common.BytesToAddress([]byte{7}): &bn256ScalarMulIstanbul{},
common.BytesToAddress([]byte{8}): &bn256PairingIstanbul{},
common.BytesToAddress([]byte{9}): &blake2F{},
common.BytesToAddress([]byte{30}): &ringSignatureVerifier{},
common.BytesToAddress([]byte{40}): &bulletproofVerifier{},
common.BytesToAddress([]byte{41}): &XDCxLastPrice{},
common.BytesToAddress([]byte{42}): &XDCxEpochPrice{},
}
Expand Down Expand Up @@ -426,42 +420,6 @@ func runBn256Pairing(input []byte) ([]byte, error) {
return false32Byte, nil
}

type ringSignatureVerifier struct{}
type bulletproofVerifier struct{}

func (c *bulletproofVerifier) RequiredGas(input []byte) uint64 {
//the gas should depends on the ringsize
return 100000
}

func (c *ringSignatureVerifier) RequiredGas(input []byte) uint64 {
//the gas should depends on the ringsize
return 100000
}

func (c *ringSignatureVerifier) Run(proof []byte) ([]byte, error) {
der, err := privacy.Deserialize(proof)
if err != nil {
return []byte{}, errors.New("Fail to deserialize proof")
}
if !privacy.Verify(der, false) {
return []byte{}, errors.New("Fail to verify ring signature")
}
return []byte{}, nil
}

func (c *bulletproofVerifier) Run(proof []byte) ([]byte, error) {
mrp := new(privacy.MultiRangeProof)
if mrp.Deserialize(proof) != nil {
return []byte{}, errors.New("failed to deserialize bulletproofs")
}

if !privacy.MRPVerify(mrp) {
return []byte{}, errors.New("failed to verify bulletproof")
}
return []byte{}, nil
}

// bn256PairingIstanbul implements a pairing pre-compile for the bn256 curve
// conforming to Istanbul consensus rules.
type bn256PairingIstanbul struct{}
Expand All @@ -488,6 +446,7 @@ func (c *bn256PairingByzantium) Run(input []byte) ([]byte, error) {
return runBn256Pairing(input)
}


type blake2F struct{}

func (c *blake2F) RequiredGas(input []byte) uint64 {
Expand Down
Loading

0 comments on commit b86c7f6

Please sign in to comment.