Skip to content
Open
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,5 @@ profile.cov
logs/

tests/spec-tests/

datadir
5 changes: 5 additions & 0 deletions core/vm/contracts.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import (
"github.com/ethereum/go-ethereum/crypto/kzg4844"
"github.com/ethereum/go-ethereum/crypto/secp256r1"
"github.com/ethereum/go-ethereum/params"
"github.com/ethereum/go-ethereum/lyraprecompiles"
"golang.org/x/crypto/ripemd160"
)

Expand Down Expand Up @@ -95,6 +96,8 @@ var PrecompiledContractsBerlin = map[common.Address]PrecompiledContract{
common.BytesToAddress([]byte{0x7}): &bn256ScalarMulIstanbul{},
common.BytesToAddress([]byte{0x8}): &bn256PairingIstanbul{},
common.BytesToAddress([]byte{0x9}): &blake2F{},

common.BytesToAddress([]byte{0x2,0x0}): &lyraprecompiles.Black76{},
}

// PrecompiledContractsCancun contains the default set of pre-compiled Ethereum
Expand All @@ -110,6 +113,8 @@ var PrecompiledContractsCancun = map[common.Address]PrecompiledContract{
common.BytesToAddress([]byte{0x8}): &bn256PairingIstanbul{},
common.BytesToAddress([]byte{0x9}): &blake2F{},
common.BytesToAddress([]byte{0xa}): &kzgPointEvaluation{},

common.BytesToAddress([]byte{0x2,0x0}): &lyraprecompiles.Black76{},
}

// PrecompiledContractsPrague contains the set of pre-compiled Ethereum
Expand Down
7 changes: 7 additions & 0 deletions core/vm/contracts_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (

"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/params"
"github.com/ethereum/go-ethereum/lyraprecompiles"
)

// precompiledTest defines the input/output pairs for precompiled contract tests.
Expand Down Expand Up @@ -70,6 +71,8 @@ var allPrecompiles = map[common.Address]PrecompiledContract{
common.BytesToAddress([]byte{0x0f, 0x10}): &bls12381Pairing{},
common.BytesToAddress([]byte{0x0f, 0x11}): &bls12381MapG1{},
common.BytesToAddress([]byte{0x0f, 0x12}): &bls12381MapG2{},

common.BytesToAddress([]byte{0x2,0x0}): &lyraprecompiles.Black76{},
}

// EIP-152 test vectors
Expand Down Expand Up @@ -421,3 +424,7 @@ func BenchmarkPrecompiledP256Verify(bench *testing.B) {
}

func TestPrecompiledP256Verify(t *testing.T) { testJson("p256Verify", "100", t) }

func TestPrecompiledBlack76(t *testing.T) { testJson("black76", "200", t) }

func BenchmarkPrecompiledBlack76(b *testing.B) { benchJson("black76", "200", b) }
65 changes: 65 additions & 0 deletions core/vm/testdata/precompiles/black76.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
[
{
"Input": "00093A800DE0B6B3A764000000000000000000000DE0B6B3A7640000000000000000005150AE84A8CDF00000000000000000005150AE84A8CDF0000012",
"Expected": "0000000000000000000000000000000000000000000000047d26bda2bce78ce40000000000000000000000000000000000000000000000047d26bda2bce78ce400000000000000000000000000000000000000000000000007526af1dc1ef614",
"Name": "black76 1",
"Gas": 300,
"NoBenchmark": false
},
{
"Input": "00278D000DDDCB7A9FCEDAF8000000000000000003782DACE9D90000000000000000003635C9ADC5DEA0000000000000000000410D586A20A4C0000012",
"Expected": "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000ad546f7ccd99b11c00000000000000000000000000000000000000000000000000721a300e4a35043",
"Name": "black76 2",
"Gas": 300,
"NoBenchmark": false
},
{
"Input": "0002A3000DE053095D6E30B400000000000000000A688906BD8B0000000000000000003635C9ADC5DEA000000000000000000025F273933DB570000012",
"Expected": "00000000000000000000000000000000000000000000000926a43e3aebc0c828000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000007177efd90ece175",
"Name": "black76 3",
"Gas": 300,
"NoBenchmark": false
},
{
"Input": "01E133800D9A5D8003C220E400000000000000015AF1D78B58C40000000000000000003635C9ADC5DEA000000000000000000025F273933DB570000012",
"Expected": "00000000000000000000000000000000000000000000003522fd3c0eae507aa00000000000000000000000000000000000000000000000253217aa0a46d1ef700000000000000000000000000000000000000000000000000d9a5d8003c220e4",
"Name": "black76 4",
"Gas": 300,
"NoBenchmark": false
},
{
"Input": "01E133800D9A5D8003C220E400000000000000004563918244F40000000000000000003635C9ADC5DEA000000000000000000025F273933DB570000012",
"Expected": "0000000000000000000000000000000000000000000000349363e2d72bce5aa4000000000000000000000000000000000000000000000024a27e50d2c44fcf740000000000000000000000000000000000000000000000000d84bdac67d29dd3",
"Name": "black76 5",
"Gas": 300,
"NoBenchmark": false
},
{
"Input": "01E133800DE0B6B3A764000000000000000000003782DACE9D90000000000000000000000000000000000001FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF12",
"Expected": "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000fffffffffffffffffffffffffffffffe0000000000000000000000000000000000000000000000000d8fe393ca06b0f7",
"Name": "black76 6",
"Gas": 300,
"NoBenchmark": false
},
{
"Input": "01E133800DE0B6B3A764000000000000000000003782DACE9D900000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF0000000000000000000000000000000112",
"Expected": "00000000000000000000000000000000fa2d0c1f4d89e7f85970d5733e37d8a900000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000d8fe393ca06b0f7",
"Name": "black76 7",
"Gas": 300,
"NoBenchmark": false
},
{
"Input": "01E133800DBD2FC137A3000000000000000000003782DACE9D900000000000000000003635C9ADC5DEA000000000000000000000000000000000000012",
"Expected": "000000000000000000000000000000000000000000000035ab028ac154b8000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000dbd2fc137a30000",
"Name": "black76 8",
"Gas": 300,
"NoBenchmark": false
},
{
"Input": "01E133800DBD2FC137A3000000000000000000003782DACE9D90000000000000000000000000000000000000000000000000003635C9ADC5DEA0000012",
"Expected": "0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000035ab028ac154b800000000000000000000000000000000000000000000000000000000000000000000",
"Name": "black76 9",
"Gas": 300,
"NoBenchmark": false
}
]
Loading