@@ -47,6 +47,7 @@ import (
47
47
type PrecompiledContract interface {
48
48
RequiredGas (input []byte ) uint64 // RequiredPrice calculates the contract gas use
49
49
Run (input []byte ) ([]byte , error ) // Run runs the precompiled contract
50
+ Name () string
50
51
}
51
52
52
53
// PrecompiledContracts contains the precompiled contracts supported at the given fork.
@@ -309,6 +310,10 @@ func (c *ecrecover) Run(input []byte) ([]byte, error) {
309
310
return common .LeftPadBytes (crypto .Keccak256 (pubKey [1 :])[12 :], 32 ), nil
310
311
}
311
312
313
+ func (c * ecrecover ) Name () string {
314
+ return "ECREC"
315
+ }
316
+
312
317
// SHA256 implemented as a native contract.
313
318
type sha256hash struct {}
314
319
@@ -324,6 +329,10 @@ func (c *sha256hash) Run(input []byte) ([]byte, error) {
324
329
return h [:], nil
325
330
}
326
331
332
+ func (c * sha256hash ) Name () string {
333
+ return "SHA256"
334
+ }
335
+
327
336
// RIPEMD160 implemented as a native contract.
328
337
type ripemd160hash struct {}
329
338
@@ -340,6 +349,10 @@ func (c *ripemd160hash) Run(input []byte) ([]byte, error) {
340
349
return common .LeftPadBytes (ripemd .Sum (nil ), 32 ), nil
341
350
}
342
351
352
+ func (c * ripemd160hash ) Name () string {
353
+ return "RIPEMD160"
354
+ }
355
+
343
356
// data copy implemented as a native contract.
344
357
type dataCopy struct {}
345
358
@@ -354,6 +367,10 @@ func (c *dataCopy) Run(in []byte) ([]byte, error) {
354
367
return common .CopyBytes (in ), nil
355
368
}
356
369
370
+ func (c * dataCopy ) Name () string {
371
+ return "ID"
372
+ }
373
+
357
374
// bigModExp implements a native big integer exponential modular operation.
358
375
type bigModExp struct {
359
376
eip2565 bool
@@ -543,6 +560,10 @@ func (c *bigModExp) Run(input []byte) ([]byte, error) {
543
560
return common .LeftPadBytes (v , int (modLen )), nil
544
561
}
545
562
563
+ func (c * bigModExp ) Name () string {
564
+ return "MODEXP"
565
+ }
566
+
546
567
// newCurvePoint unmarshals a binary blob into a bn256 elliptic curve point,
547
568
// returning it, or an error if the point is invalid.
548
569
func newCurvePoint (blob []byte ) (* bn256.G1 , error ) {
@@ -592,6 +613,10 @@ func (c *bn256AddIstanbul) Run(input []byte) ([]byte, error) {
592
613
return runBn256Add (input )
593
614
}
594
615
616
+ func (c * bn256AddIstanbul ) Name () string {
617
+ return "BN254_ADD"
618
+ }
619
+
595
620
// bn256AddByzantium implements a native elliptic curve point addition
596
621
// conforming to Byzantium consensus rules.
597
622
type bn256AddByzantium struct {}
@@ -605,6 +630,10 @@ func (c *bn256AddByzantium) Run(input []byte) ([]byte, error) {
605
630
return runBn256Add (input )
606
631
}
607
632
633
+ func (c * bn256AddByzantium ) Name () string {
634
+ return "BN254_ADD"
635
+ }
636
+
608
637
// runBn256ScalarMul implements the Bn256ScalarMul precompile, referenced by
609
638
// both Byzantium and Istanbul operations.
610
639
func runBn256ScalarMul (input []byte ) ([]byte , error ) {
@@ -630,6 +659,10 @@ func (c *bn256ScalarMulIstanbul) Run(input []byte) ([]byte, error) {
630
659
return runBn256ScalarMul (input )
631
660
}
632
661
662
+ func (c * bn256ScalarMulIstanbul ) Name () string {
663
+ return "BN254_MUL"
664
+ }
665
+
633
666
// bn256ScalarMulByzantium implements a native elliptic curve scalar
634
667
// multiplication conforming to Byzantium consensus rules.
635
668
type bn256ScalarMulByzantium struct {}
@@ -643,6 +676,10 @@ func (c *bn256ScalarMulByzantium) Run(input []byte) ([]byte, error) {
643
676
return runBn256ScalarMul (input )
644
677
}
645
678
679
+ func (c * bn256ScalarMulByzantium ) Name () string {
680
+ return "BN254_MUL"
681
+ }
682
+
646
683
var (
647
684
// true32Byte is returned if the bn256 pairing check succeeds.
648
685
true32Byte = []byte {0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 1 }
@@ -698,6 +735,10 @@ func (c *bn256PairingIstanbul) Run(input []byte) ([]byte, error) {
698
735
return runBn256Pairing (input )
699
736
}
700
737
738
+ func (c * bn256PairingIstanbul ) Name () string {
739
+ return "BN254_PAIRING"
740
+ }
741
+
701
742
// bn256PairingByzantium implements a pairing pre-compile for the bn256 curve
702
743
// conforming to Byzantium consensus rules.
703
744
type bn256PairingByzantium struct {}
@@ -711,6 +752,10 @@ func (c *bn256PairingByzantium) Run(input []byte) ([]byte, error) {
711
752
return runBn256Pairing (input )
712
753
}
713
754
755
+ func (c * bn256PairingByzantium ) Name () string {
756
+ return "BN254_PAIRING"
757
+ }
758
+
714
759
type blake2F struct {}
715
760
716
761
func (c * blake2F ) RequiredGas (input []byte ) uint64 {
@@ -772,6 +817,10 @@ func (c *blake2F) Run(input []byte) ([]byte, error) {
772
817
return output , nil
773
818
}
774
819
820
+ func (c * blake2F ) Name () string {
821
+ return "BLAKE2F"
822
+ }
823
+
775
824
var (
776
825
errBLS12381InvalidInputLength = errors .New ("invalid input length" )
777
826
errBLS12381InvalidFieldElementTopBytes = errors .New ("invalid field element top bytes" )
@@ -815,6 +864,10 @@ func (c *bls12381G1Add) Run(input []byte) ([]byte, error) {
815
864
return encodePointG1 (p0 ), nil
816
865
}
817
866
867
+ func (c * bls12381G1Add ) Name () string {
868
+ return "BLS12_G1ADD"
869
+ }
870
+
818
871
// bls12381G1MultiExp implements EIP-2537 G1MultiExp precompile.
819
872
type bls12381G1MultiExp struct {}
820
873
@@ -875,6 +928,10 @@ func (c *bls12381G1MultiExp) Run(input []byte) ([]byte, error) {
875
928
return encodePointG1 (r ), nil
876
929
}
877
930
931
+ func (c * bls12381G1MultiExp ) Name () string {
932
+ return "BLS12_G1MSM"
933
+ }
934
+
878
935
// bls12381G2Add implements EIP-2537 G2Add precompile.
879
936
type bls12381G2Add struct {}
880
937
@@ -912,6 +969,10 @@ func (c *bls12381G2Add) Run(input []byte) ([]byte, error) {
912
969
return encodePointG2 (r ), nil
913
970
}
914
971
972
+ func (c * bls12381G2Add ) Name () string {
973
+ return "BLS12_G2ADD"
974
+ }
975
+
915
976
// bls12381G2MultiExp implements EIP-2537 G2MultiExp precompile.
916
977
type bls12381G2MultiExp struct {}
917
978
@@ -972,6 +1033,10 @@ func (c *bls12381G2MultiExp) Run(input []byte) ([]byte, error) {
972
1033
return encodePointG2 (r ), nil
973
1034
}
974
1035
1036
+ func (c * bls12381G2MultiExp ) Name () string {
1037
+ return "BLS12_G2MSM"
1038
+ }
1039
+
975
1040
// bls12381Pairing implements EIP-2537 Pairing precompile.
976
1041
type bls12381Pairing struct {}
977
1042
@@ -1035,6 +1100,10 @@ func (c *bls12381Pairing) Run(input []byte) ([]byte, error) {
1035
1100
return out , nil
1036
1101
}
1037
1102
1103
+ func (c * bls12381Pairing ) Name () string {
1104
+ return "BLS12_PAIRING_CHECK"
1105
+ }
1106
+
1038
1107
func decodePointG1 (in []byte ) (* bls12381.G1Affine , error ) {
1039
1108
if len (in ) != 128 {
1040
1109
return nil , errors .New ("invalid g1 point length" )
@@ -1153,6 +1222,10 @@ func (c *bls12381MapG1) Run(input []byte) ([]byte, error) {
1153
1222
return encodePointG1 (& r ), nil
1154
1223
}
1155
1224
1225
+ func (c * bls12381MapG1 ) Name () string {
1226
+ return "BLS12_MAP_FP_TO_G1"
1227
+ }
1228
+
1156
1229
// bls12381MapG2 implements EIP-2537 MapG2 precompile.
1157
1230
type bls12381MapG2 struct {}
1158
1231
@@ -1186,6 +1259,10 @@ func (c *bls12381MapG2) Run(input []byte) ([]byte, error) {
1186
1259
return encodePointG2 (& r ), nil
1187
1260
}
1188
1261
1262
+ func (c * bls12381MapG2 ) Name () string {
1263
+ return "BLS12_MAP_FP2_TO_G2"
1264
+ }
1265
+
1189
1266
// kzgPointEvaluation implements the EIP-4844 point evaluation precompile.
1190
1267
type kzgPointEvaluation struct {}
1191
1268
@@ -1242,6 +1319,10 @@ func (b *kzgPointEvaluation) Run(input []byte) ([]byte, error) {
1242
1319
return common .Hex2Bytes (blobPrecompileReturnValue ), nil
1243
1320
}
1244
1321
1322
+ func (b * kzgPointEvaluation ) Name () string {
1323
+ return "KZG_POINT_EVALUATION"
1324
+ }
1325
+
1245
1326
// kZGToVersionedHash implements kzg_to_versioned_hash from EIP-4844
1246
1327
func kZGToVersionedHash (kzg kzg4844.Commitment ) common.Hash {
1247
1328
h := sha256 .Sum256 (kzg [:])
@@ -1277,3 +1358,7 @@ func (c *p256Verify) Run(input []byte) ([]byte, error) {
1277
1358
}
1278
1359
return nil , nil
1279
1360
}
1361
+
1362
+ func (c * p256Verify ) Name () string {
1363
+ return "P256VERIFY"
1364
+ }
0 commit comments