Skip to content
Closed
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
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