@@ -46,6 +46,7 @@ import (
46
46
type PrecompiledContract interface {
47
47
RequiredGas (input []byte ) uint64 // RequiredPrice calculates the contract gas use
48
48
Run (input []byte ) ([]byte , error ) // Run runs the precompiled contract
49
+ Name () string
49
50
}
50
51
51
52
// PrecompiledContracts contains the precompiled contracts supported at the given fork.
@@ -308,6 +309,10 @@ func (c *ecrecover) Run(input []byte) ([]byte, error) {
308
309
return common .LeftPadBytes (crypto .Keccak256 (pubKey [1 :])[12 :], 32 ), nil
309
310
}
310
311
312
+ func (c * ecrecover ) Name () string {
313
+ return "ECREC"
314
+ }
315
+
311
316
// SHA256 implemented as a native contract.
312
317
type sha256hash struct {}
313
318
@@ -323,6 +328,10 @@ func (c *sha256hash) Run(input []byte) ([]byte, error) {
323
328
return h [:], nil
324
329
}
325
330
331
+ func (c * sha256hash ) Name () string {
332
+ return "SHA256"
333
+ }
334
+
326
335
// RIPEMD160 implemented as a native contract.
327
336
type ripemd160hash struct {}
328
337
@@ -339,6 +348,10 @@ func (c *ripemd160hash) Run(input []byte) ([]byte, error) {
339
348
return common .LeftPadBytes (ripemd .Sum (nil ), 32 ), nil
340
349
}
341
350
351
+ func (c * ripemd160hash ) Name () string {
352
+ return "RIPEMD160"
353
+ }
354
+
342
355
// data copy implemented as a native contract.
343
356
type dataCopy struct {}
344
357
@@ -353,6 +366,10 @@ func (c *dataCopy) Run(in []byte) ([]byte, error) {
353
366
return common .CopyBytes (in ), nil
354
367
}
355
368
369
+ func (c * dataCopy ) Name () string {
370
+ return "ID"
371
+ }
372
+
356
373
// bigModExp implements a native big integer exponential modular operation.
357
374
type bigModExp struct {
358
375
eip2565 bool
@@ -537,6 +554,10 @@ func (c *bigModExp) Run(input []byte) ([]byte, error) {
537
554
return common .LeftPadBytes (v , int (modLen )), nil
538
555
}
539
556
557
+ func (c * bigModExp ) Name () string {
558
+ return "MODEXP"
559
+ }
560
+
540
561
// newCurvePoint unmarshals a binary blob into a bn256 elliptic curve point,
541
562
// returning it, or an error if the point is invalid.
542
563
func newCurvePoint (blob []byte ) (* bn256.G1 , error ) {
@@ -586,6 +607,10 @@ func (c *bn256AddIstanbul) Run(input []byte) ([]byte, error) {
586
607
return runBn256Add (input )
587
608
}
588
609
610
+ func (c * bn256AddIstanbul ) Name () string {
611
+ return "BN256_ADD"
612
+ }
613
+
589
614
// bn256AddByzantium implements a native elliptic curve point addition
590
615
// conforming to Byzantium consensus rules.
591
616
type bn256AddByzantium struct {}
@@ -599,6 +624,10 @@ func (c *bn256AddByzantium) Run(input []byte) ([]byte, error) {
599
624
return runBn256Add (input )
600
625
}
601
626
627
+ func (c * bn256AddByzantium ) Name () string {
628
+ return "BN256_ADD"
629
+ }
630
+
602
631
// runBn256ScalarMul implements the Bn256ScalarMul precompile, referenced by
603
632
// both Byzantium and Istanbul operations.
604
633
func runBn256ScalarMul (input []byte ) ([]byte , error ) {
@@ -624,6 +653,10 @@ func (c *bn256ScalarMulIstanbul) Run(input []byte) ([]byte, error) {
624
653
return runBn256ScalarMul (input )
625
654
}
626
655
656
+ func (c * bn256ScalarMulIstanbul ) Name () string {
657
+ return "BN256_MUL"
658
+ }
659
+
627
660
// bn256ScalarMulByzantium implements a native elliptic curve scalar
628
661
// multiplication conforming to Byzantium consensus rules.
629
662
type bn256ScalarMulByzantium struct {}
@@ -637,6 +670,10 @@ func (c *bn256ScalarMulByzantium) Run(input []byte) ([]byte, error) {
637
670
return runBn256ScalarMul (input )
638
671
}
639
672
673
+ func (c * bn256ScalarMulByzantium ) Name () string {
674
+ return "BN256_MUL"
675
+ }
676
+
640
677
var (
641
678
// true32Byte is returned if the bn256 pairing check succeeds.
642
679
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 }
@@ -692,6 +729,10 @@ func (c *bn256PairingIstanbul) Run(input []byte) ([]byte, error) {
692
729
return runBn256Pairing (input )
693
730
}
694
731
732
+ func (c * bn256PairingIstanbul ) Name () string {
733
+ return "BN256_PAIRING"
734
+ }
735
+
695
736
// bn256PairingByzantium implements a pairing pre-compile for the bn256 curve
696
737
// conforming to Byzantium consensus rules.
697
738
type bn256PairingByzantium struct {}
@@ -705,6 +746,10 @@ func (c *bn256PairingByzantium) Run(input []byte) ([]byte, error) {
705
746
return runBn256Pairing (input )
706
747
}
707
748
749
+ func (c * bn256PairingByzantium ) Name () string {
750
+ return "BN256_PAIRING"
751
+ }
752
+
708
753
type blake2F struct {}
709
754
710
755
func (c * blake2F ) RequiredGas (input []byte ) uint64 {
@@ -766,6 +811,10 @@ func (c *blake2F) Run(input []byte) ([]byte, error) {
766
811
return output , nil
767
812
}
768
813
814
+ func (c * blake2F ) Name () string {
815
+ return "BLAKE2F"
816
+ }
817
+
769
818
var (
770
819
errBLS12381InvalidInputLength = errors .New ("invalid input length" )
771
820
errBLS12381InvalidFieldElementTopBytes = errors .New ("invalid field element top bytes" )
@@ -809,6 +858,10 @@ func (c *bls12381G1Add) Run(input []byte) ([]byte, error) {
809
858
return encodePointG1 (p0 ), nil
810
859
}
811
860
861
+ func (c * bls12381G1Add ) Name () string {
862
+ return "BLS12_G1ADD"
863
+ }
864
+
812
865
// bls12381G1MultiExp implements EIP-2537 G1MultiExp precompile.
813
866
type bls12381G1MultiExp struct {}
814
867
@@ -869,6 +922,10 @@ func (c *bls12381G1MultiExp) Run(input []byte) ([]byte, error) {
869
922
return encodePointG1 (r ), nil
870
923
}
871
924
925
+ func (c * bls12381G1MultiExp ) Name () string {
926
+ return "BLS12_G1MSM"
927
+ }
928
+
872
929
// bls12381G2Add implements EIP-2537 G2Add precompile.
873
930
type bls12381G2Add struct {}
874
931
@@ -906,6 +963,10 @@ func (c *bls12381G2Add) Run(input []byte) ([]byte, error) {
906
963
return encodePointG2 (r ), nil
907
964
}
908
965
966
+ func (c * bls12381G2Add ) Name () string {
967
+ return "BLS12_G2ADD"
968
+ }
969
+
909
970
// bls12381G2MultiExp implements EIP-2537 G2MultiExp precompile.
910
971
type bls12381G2MultiExp struct {}
911
972
@@ -966,6 +1027,10 @@ func (c *bls12381G2MultiExp) Run(input []byte) ([]byte, error) {
966
1027
return encodePointG2 (r ), nil
967
1028
}
968
1029
1030
+ func (c * bls12381G2MultiExp ) Name () string {
1031
+ return "BLS12_G2MSM"
1032
+ }
1033
+
969
1034
// bls12381Pairing implements EIP-2537 Pairing precompile.
970
1035
type bls12381Pairing struct {}
971
1036
@@ -1029,6 +1094,10 @@ func (c *bls12381Pairing) Run(input []byte) ([]byte, error) {
1029
1094
return out , nil
1030
1095
}
1031
1096
1097
+ func (c * bls12381Pairing ) Name () string {
1098
+ return "BLS12_PAIRING_CHECK"
1099
+ }
1100
+
1032
1101
func decodePointG1 (in []byte ) (* bls12381.G1Affine , error ) {
1033
1102
if len (in ) != 128 {
1034
1103
return nil , errors .New ("invalid g1 point length" )
@@ -1147,6 +1216,10 @@ func (c *bls12381MapG1) Run(input []byte) ([]byte, error) {
1147
1216
return encodePointG1 (& r ), nil
1148
1217
}
1149
1218
1219
+ func (c * bls12381MapG1 ) Name () string {
1220
+ return "BLS12_MAP_FP_TO_G1"
1221
+ }
1222
+
1150
1223
// bls12381MapG2 implements EIP-2537 MapG2 precompile.
1151
1224
type bls12381MapG2 struct {}
1152
1225
@@ -1180,6 +1253,10 @@ func (c *bls12381MapG2) Run(input []byte) ([]byte, error) {
1180
1253
return encodePointG2 (& r ), nil
1181
1254
}
1182
1255
1256
+ func (c * bls12381MapG2 ) Name () string {
1257
+ return "BLS12_MAP_FP2_TO_G2"
1258
+ }
1259
+
1183
1260
// kzgPointEvaluation implements the EIP-4844 point evaluation precompile.
1184
1261
type kzgPointEvaluation struct {}
1185
1262
@@ -1236,6 +1313,10 @@ func (b *kzgPointEvaluation) Run(input []byte) ([]byte, error) {
1236
1313
return common .Hex2Bytes (blobPrecompileReturnValue ), nil
1237
1314
}
1238
1315
1316
+ func (c * kzgPointEvaluation ) Name () string {
1317
+ return "KZG_POINT_EVALUATION"
1318
+ }
1319
+
1239
1320
// kZGToVersionedHash implements kzg_to_versioned_hash from EIP-4844
1240
1321
func kZGToVersionedHash (kzg kzg4844.Commitment ) common.Hash {
1241
1322
h := sha256 .Sum256 (kzg [:])
@@ -1271,3 +1352,7 @@ func (c *p256Verify) Run(input []byte) ([]byte, error) {
1271
1352
}
1272
1353
return nil , nil
1273
1354
}
1355
+
1356
+ func (c * p256Verify ) Name () string {
1357
+ return "P256VERIFY"
1358
+ }
0 commit comments