From 86e5228fbc53b6f456f744e3204d05d303b2c98c Mon Sep 17 00:00:00 2001 From: John Jannotti Date: Mon, 9 Jan 2023 15:22:37 -0500 Subject: [PATCH] Naming change to appease lint --- data/transactions/logic/TEAL_opcodes.md | 20 ++-- data/transactions/logic/fields.go | 24 ++--- data/transactions/logic/fields_string.go | 12 +-- data/transactions/logic/opcodes.go | 24 ++--- data/transactions/logic/pairing.go | 48 ++++----- data/transactions/logic/pairing_test.go | 104 +++++++++---------- data/transactions/logic/teal.tmLanguage.json | 2 +- 7 files changed, 117 insertions(+), 117 deletions(-) diff --git a/data/transactions/logic/TEAL_opcodes.md b/data/transactions/logic/TEAL_opcodes.md index 5ddca65cf5..91378aed40 100644 --- a/data/transactions/logic/TEAL_opcodes.md +++ b/data/transactions/logic/TEAL_opcodes.md @@ -1566,17 +1566,17 @@ For boxes that exceed 4,096 bytes, consider `box_create`, `box_extract`, and `bo - Opcode: 0xe0 {uint8 curve} - Stack: ..., A: []byte, B: []byte → ..., []byte - for curve points A and B, return the curve point A + B -- **Cost**: BN254_G1=310 BN254_G2=430 BLS12_381_G1=540 BLS12_381_G2=750 +- **Cost**: BN254g1=310 BN254g2=430 BLS12_381g1=540 BLS12_381g2=750 - Availability: v9 `EC` Groups: | Index | Name | Notes | | - | ------ | --------- | -| 0 | BN254_G1 | G1 of the BN254 curve. Points encoded as 32 byte X following by 32 byte Y | -| 1 | BN254_G2 | G2 of the BN254 curve. Points encoded as 64 byte X following by 64 byte Y | -| 2 | BLS12_381_G1 | G1 of the BLS 12-381 curve. Points encoded as 48 byte X following by 48 byte Y | -| 3 | BLS12_381_G2 | G2 of the BLS 12-381 curve. Points encoded as 96 byte X following by 48 byte Y | +| 0 | BN254g1 | G1 of the BN254 curve. Points encoded as 32 byte X following by 32 byte Y | +| 1 | BN254g2 | G2 of the BN254 curve. Points encoded as 64 byte X following by 64 byte Y | +| 2 | BLS12_381g1 | G1 of the BLS 12-381 curve. Points encoded as 48 byte X following by 48 byte Y | +| 3 | BLS12_381g2 | G2 of the BLS 12-381 curve. Points encoded as 96 byte X following by 48 byte Y | A and B are curve points in affine representation: X concatenated with Y. Fails if A or B is not in G. Does _not_ check if A and B are in the main prime-order subgroup. @@ -1586,7 +1586,7 @@ A and B are curve points in affine representation: X concatenated with Y. Fails - Opcode: 0xe1 {uint8 curve} - Stack: ..., A: []byte, B: []byte → ..., []byte - for curve point A and scalar B, return the curve point BA -- **Cost**: BN254_G1=2200 BN254_G2=4460 BLS12_381_G1=3640 BLS12_381_G2=8530 +- **Cost**: BN254g1=2200 BN254g2=4460 BLS12_381g1=3640 BLS12_381g2=8530 - Availability: v9 A is a curve point encoded and checked as described in `ec_add`. Scalar B is interpreted as a big-endian unsigned integer. @@ -1596,7 +1596,7 @@ A is a curve point encoded and checked as described in `ec_add`. Scalar B is int - Opcode: 0xe2 {uint8 curve} - Stack: ..., A: []byte, B: []byte → ..., uint64 - 1 if all points in A (concatenated points in group G) are paired with the corresponding points of B (concatenated points in the associated group), else 0 -- **Cost**: BN254_G1=18000 BN254_G2=18000 BLS12_381_G1=15000 BLS12_381_G2=15000 +- **Cost**: BN254g1=18000 BN254g2=18000 BLS12_381g1=15000 BLS12_381g2=15000 - Availability: v9 A and B are concatenated points, encoded and checked as described in `ec_add`. A contains points of the group G, B contains points of the associated group (G2 if G is G1, and vice versa). Fails is A and B have a different number of points, or if any point is not in its described group or outside the main prime-order subgroup - a stronger condition than other opcodes. @@ -1606,7 +1606,7 @@ A and B are concatenated points, encoded and checked as described in `ec_add`. A - Opcode: 0xe3 {uint8 curve} - Stack: ..., A: []byte, B: []byte → ..., []byte - for curve points A and scalars B, return curve point B0A0 + B1A1 + B2A2 + ... + BnAn -- **Cost**: BN254_G1=800 BN254_G2=1800 BLS12_381_G1=1400 BLS12_381_G2=3500 +- **Cost**: BN254g1=800 BN254g2=1800 BLS12_381g1=1400 BLS12_381g2=3500 - Availability: v9 ## ec_subgroup_check g @@ -1614,7 +1614,7 @@ A and B are concatenated points, encoded and checked as described in `ec_add`. A - Opcode: 0xe4 {uint8 curve} - Stack: ..., A: []byte → ..., uint64 - whether point A is in the main prime-order subgroup of G => {0 or 1} -- **Cost**: BN254_G1=50 BN254_G2=11500 BLS12_381_G1=5600 BLS12_381_G2=7100 +- **Cost**: BN254g1=50 BN254g2=11500 BLS12_381g1=5600 BLS12_381g2=7100 - Availability: v9 ## ec_map_to g @@ -1622,5 +1622,5 @@ A and B are concatenated points, encoded and checked as described in `ec_add`. A - Opcode: 0xe5 {uint8 curve} - Stack: ..., A: []byte → ..., []byte - maps field element A to group G -- **Cost**: BN254_G1=1700 BN254_G2=11000 BLS12_381_G1=5600 BLS12_381_G2=43000 +- **Cost**: BN254g1=1700 BN254g2=11000 BLS12_381g1=5600 BLS12_381g2=43000 - Availability: v9 diff --git a/data/transactions/logic/fields.go b/data/transactions/logic/fields.go index 0abf44e653..e3b3db53a8 100644 --- a/data/transactions/logic/fields.go +++ b/data/transactions/logic/fields.go @@ -680,14 +680,14 @@ var EcdsaCurves = FieldGroup{ type EcGroup int const ( - // BN254_G1 is the G1 group of BN254 - BN254_G1 EcGroup = iota - // BN254_G2 is the G2 group of BN254 - BN254_G2 - // BL12_381_G1 specifies the G1 group of BLS 12-381 - BLS12_381_G1 - // BL12_381_G2 specifies the G2 group of BLS 12-381 - BLS12_381_G2 + // BN254g1 is the G1 group of BN254 + BN254g1 EcGroup = iota + // BN254g2 is the G2 group of BN254 + BN254g2 + // BLS12_381g1 specifies the G1 group of BLS 12-381 + BLS12_381g1 + // BLS12_381g2 specifies the G2 group of BLS 12-381 + BLS12_381g2 invalidEcGroup // compile-time constant for number of fields ) @@ -715,10 +715,10 @@ func (fs ecGroupSpec) Note() string { } var ecGroupSpecs = [...]ecGroupSpec{ - {BN254_G1, "G1 of the BN254 curve. Points encoded as 32 byte X following by 32 byte Y"}, - {BN254_G2, "G2 of the BN254 curve. Points encoded as 64 byte X following by 64 byte Y"}, - {BLS12_381_G1, "G1 of the BLS 12-381 curve. Points encoded as 48 byte X following by 48 byte Y"}, - {BLS12_381_G2, "G2 of the BLS 12-381 curve. Points encoded as 96 byte X following by 48 byte Y"}, + {BN254g1, "G1 of the BN254 curve. Points encoded as 32 byte X following by 32 byte Y"}, + {BN254g2, "G2 of the BN254 curve. Points encoded as 64 byte X following by 64 byte Y"}, + {BLS12_381g1, "G1 of the BLS 12-381 curve. Points encoded as 48 byte X following by 48 byte Y"}, + {BLS12_381g2, "G2 of the BLS 12-381 curve. Points encoded as 96 byte X following by 48 byte Y"}, } func ecGroupSpecByField(c EcGroup) (ecGroupSpec, bool) { diff --git a/data/transactions/logic/fields_string.go b/data/transactions/logic/fields_string.go index 9b7b78b764..49f05bbb50 100644 --- a/data/transactions/logic/fields_string.go +++ b/data/transactions/logic/fields_string.go @@ -269,16 +269,16 @@ func _() { // An "invalid array index" compiler error signifies that the constant values have changed. // Re-run the stringer command to generate them again. var x [1]struct{} - _ = x[BN254_G1-0] - _ = x[BN254_G2-1] - _ = x[BLS12_381_G1-2] - _ = x[BLS12_381_G2-3] + _ = x[BN254g1-0] + _ = x[BN254g2-1] + _ = x[BLS12_381g1-2] + _ = x[BLS12_381g2-3] _ = x[invalidEcGroup-4] } -const _EcGroup_name = "BN254_G1BN254_G2BLS12_381_G1BLS12_381_G2invalidEcGroup" +const _EcGroup_name = "BN254g1BN254g2BLS12_381g1BLS12_381g2invalidEcGroup" -var _EcGroup_index = [...]uint8{0, 8, 16, 28, 40, 54} +var _EcGroup_index = [...]uint8{0, 7, 14, 25, 36, 50} func (i EcGroup) String() string { if i < 0 || i >= EcGroup(len(_EcGroup_index)-1) { diff --git a/data/transactions/logic/opcodes.go b/data/transactions/logic/opcodes.go index 54e32d27ea..28c4022bf2 100644 --- a/data/transactions/logic/opcodes.go +++ b/data/transactions/logic/opcodes.go @@ -637,12 +637,12 @@ var OpSpecs = []OpSpec{ {0xe0, "ec_add", opEcAdd, proto("bb:b"), pairingVersion, costByField("g", &EcGroups, []int{ - BN254_G1: 310, BN254_G2: 430, - BLS12_381_G1: 540, BLS12_381_G2: 750})}, // eip: 500, 800 + BN254g1: 310, BN254g2: 430, + BLS12_381g1: 540, BLS12_381g2: 750})}, // eip: 500, 800 {0xe1, "ec_scalar_mul", opEcScalarMul, proto("bb:b"), pairingVersion, costByField("g", &EcGroups, []int{ - BN254_G1: 2200, BN254_G2: 4460, - BLS12_381_G1: 3640, BLS12_381_G2: 8530})}, // eip: 12000, 45000 + BN254g1: 2200, BN254g2: 4460, + BLS12_381g1: 3640, BLS12_381g2: 8530})}, // eip: 12000, 45000 // BN cost is 18k per elt, BLS is 45k + 40k per elt. Not putting those // costs in yet because 1) that is bigger than allowed in logicsigs, so @@ -650,8 +650,8 @@ var OpSpecs = []OpSpec{ // that _also_ depend on input sizes. {0xe2, "ec_pairing_check", opEcPairingCheck, proto("bb:i"), pairingVersion, costByField("g", &EcGroups, []int{ - BN254_G1: 18_000, BN254_G2: 18_000, - BLS12_381_G1: 15_000, BLS12_381_G2: 15_000})}, // eip: 43000*k + 65000 + BN254g1: 18_000, BN254g2: 18_000, + BLS12_381g1: 15_000, BLS12_381g2: 15_000})}, // eip: 43000*k + 65000 // This cost must be based on number of points. EIP proposes a complicated // "discount" scheme. At any rate, as noted above, we don't yet have @@ -662,17 +662,17 @@ var OpSpecs = []OpSpec{ // blsG2 seems to be 35000 + 1800 /elt {0xe3, "ec_multi_exp", opEcMultiExp, proto("bb:b"), pairingVersion, costByField("g", &EcGroups, []int{ - BN254_G1: 800, BN254_G2: 1800, // LIES - BLS12_381_G1: 1400, BLS12_381_G2: 3500})}, // LIES + BN254g1: 800, BN254g2: 1800, // LIES + BLS12_381g1: 1400, BLS12_381g2: 3500})}, // LIES {0xe4, "ec_subgroup_check", opEcSubgroupCheck, proto("b:i"), pairingVersion, costByField("g", &EcGroups, []int{ - BN254_G1: 50, BN254_G2: 11500, // How is the g1 subgroup check so much faster? - BLS12_381_G1: 5600, BLS12_381_G2: 7100})}, + BN254g1: 50, BN254g2: 11500, // How is the g1 subgroup check so much faster? + BLS12_381g1: 5600, BLS12_381g2: 7100})}, {0xe5, "ec_map_to", opEcMapTo, proto("b:b"), pairingVersion, costByField("g", &EcGroups, []int{ - BN254_G1: 1700, BN254_G2: 11000, - BLS12_381_G1: 5600, BLS12_381_G2: 43000})}, // eip: 5500, 75000 + BN254g1: 1700, BN254g2: 11000, + BLS12_381g1: 5600, BLS12_381g2: 43000})}, // eip: 5500, 75000 } type sortByOpcode []OpSpec diff --git a/data/transactions/logic/pairing.go b/data/transactions/logic/pairing.go index 0a0dc64ca0..c835674286 100644 --- a/data/transactions/logic/pairing.go +++ b/data/transactions/logic/pairing.go @@ -55,13 +55,13 @@ func opEcAdd(cx *EvalContext) error { var res []byte var err error switch fs.field { - case BN254_G1: + case BN254g1: res, err = bn254G1Add(a, b) - case BN254_G2: + case BN254g2: res, err = bn254G2Add(a, b) - case BLS12_381_G1: + case BLS12_381g1: res, err = bls12381G1Add(a, b) - case BLS12_381_G2: + case BLS12_381g2: res, err = bls12381G2Add(a, b) default: err = fmt.Errorf("invalid ec_add group %s", group) @@ -91,13 +91,13 @@ func opEcScalarMul(cx *EvalContext) error { var res []byte var err error switch fs.field { - case BN254_G1: + case BN254g1: res, err = bn254G1ScalarMul(aBytes, k) - case BN254_G2: + case BN254g2: res, err = bn254G2ScalarMul(aBytes, k) - case BLS12_381_G1: + case BLS12_381g1: res, err = bls12381G1ScalarMul(aBytes, k) - case BLS12_381_G2: + case BLS12_381g2: res, err = bls12381G2ScalarMul(aBytes, k) default: err = fmt.Errorf("invalid ec_scalar_mul group %s", group) @@ -125,15 +125,15 @@ func opEcPairingCheck(cx *EvalContext) error { var err error ok = false switch fs.field { - case BN254_G2: + case BN254g2: g1Bytes, g2Bytes = g2Bytes, g1Bytes fallthrough - case BN254_G1: + case BN254g1: ok, err = bn254PairingCheck(g1Bytes, g2Bytes) - case BLS12_381_G2: + case BLS12_381g2: g1Bytes, g2Bytes = g2Bytes, g1Bytes fallthrough - case BLS12_381_G1: + case BLS12_381g1: ok, err = bls12381PairingCheck(g1Bytes, g2Bytes) default: err = fmt.Errorf("invalid ec_pairing_check group %s", group) @@ -161,13 +161,13 @@ func opEcMultiExp(cx *EvalContext) error { var res []byte var err error switch fs.field { - case BN254_G1: + case BN254g1: res, err = bn254G1MultiExp(g1Bytes, scalarBytes) - case BN254_G2: + case BN254g2: res, err = bn254G2MultiExp(g1Bytes, scalarBytes) - case BLS12_381_G1: + case BLS12_381g1: res, err = bls12381G1MultiExp(g1Bytes, scalarBytes) - case BLS12_381_G2: + case BLS12_381g2: res, err = bls12381G2MultiExp(g1Bytes, scalarBytes) default: err = fmt.Errorf("invalid ec_multiexp group %s", group) @@ -193,13 +193,13 @@ func opEcSubgroupCheck(cx *EvalContext) error { var err error ok = false switch fs.field { - case BN254_G1: + case BN254g1: ok, err = bn254G1SubgroupCheck(pointBytes) - case BN254_G2: + case BN254g2: ok, err = bn254G2SubgroupCheck(pointBytes) - case BLS12_381_G1: + case BLS12_381g1: ok, err = bls12381G1SubgroupCheck(pointBytes) - case BLS12_381_G2: + case BLS12_381g2: ok, err = bls12381G2SubgroupCheck(pointBytes) default: err = fmt.Errorf("invalid ec_pairing_check group %s", group) @@ -225,13 +225,13 @@ func opEcMapTo(cx *EvalContext) error { var res []byte var err error switch fs.field { - case BN254_G1: + case BN254g1: res, err = bn254MapToG1(fpBytes) - case BN254_G2: + case BN254g2: res, err = bn254MapToG2(fpBytes) - case BLS12_381_G1: + case BLS12_381g1: res, err = bls12381MapToG1(fpBytes) - case BLS12_381_G2: + case BLS12_381g2: res, err = bls12381MapToG2(fpBytes) default: err = fmt.Errorf("invalid ec_pairing_check group %s", group) diff --git a/data/transactions/logic/pairing_test.go b/data/transactions/logic/pairing_test.go index 5e7a5dcf7b..78186ced5f 100644 --- a/data/transactions/logic/pairing_test.go +++ b/data/transactions/logic/pairing_test.go @@ -33,14 +33,14 @@ import ( const pairingNonsense = ` pushbytes 0x012345 dup - ec_add BN254_G1 + ec_add BN254g1 dup - ec_scalar_mul BLS12_381_G2 + ec_scalar_mul BLS12_381g2 dup - ec_pairing_check BN254_G1 - ec_multi_exp BLS12_381_G2 - ec_subgroup_check BLS12_381_G1 - ec_map_to BN254_G2 + ec_pairing_check BN254g1 + ec_multi_exp BLS12_381g2 + ec_subgroup_check BLS12_381g1 + ec_map_to BN254g2 ` const pairingCompiled = "800301234549e00049e10349e200e303e402e501" @@ -87,8 +87,8 @@ func TestEcAdd(t *testing.T) { g1bytes1 := fmt.Sprintf("byte 0x%s\n", hex.EncodeToString(bn254G1ToBytes(&g1point))) g1point = bn254RandomG1() g1bytes2 := fmt.Sprintf("byte 0x%s\n", hex.EncodeToString(bn254G1ToBytes(&g1point))) - testAccepts(t, g1bytes1+g1bytes2+"ec_add BN254_G1; len", pairingVersion) - testAccepts(t, g1bytes1+"int 64; bzero; ec_add BN254_G1;"+g1bytes1+"==", pairingVersion) + testAccepts(t, g1bytes1+g1bytes2+"ec_add BN254g1; len", pairingVersion) + testAccepts(t, g1bytes1+"int 64; bzero; ec_add BN254g1;"+g1bytes1+"==", pairingVersion) } func TestEcScalarMul(t *testing.T) { @@ -99,8 +99,8 @@ func TestEcScalarMul(t *testing.T) { g1point := bn254RandomG1() g1bytes1 := fmt.Sprintf("byte 0x%s\n", hex.EncodeToString(bn254G1ToBytes(&g1point))) - testAccepts(t, g1bytes1+"int 0; itob; ec_scalar_mul BN254_G1; int 64; bzero; ==", pairingVersion) - testAccepts(t, g1bytes1+"int 1; itob; ec_scalar_mul BN254_G1;"+g1bytes1+"==", pairingVersion) + testAccepts(t, g1bytes1+"int 0; itob; ec_scalar_mul BN254g1; int 64; bzero; ==", pairingVersion) + testAccepts(t, g1bytes1+"int 1; itob; ec_scalar_mul BN254g1;"+g1bytes1+"==", pairingVersion) } func TestPairCheck(t *testing.T) { @@ -116,8 +116,8 @@ func TestPairCheck(t *testing.T) { g1bytes := fmt.Sprintf("byte 0x%s\n", hex.EncodeToString(bn254G1sToBytes(g1points))) g2bytes := fmt.Sprintf("byte 0x%s\n", hex.EncodeToString(bn254G2sToBytes(g2points))) - testAccepts(t, g1bytes+g2bytes+`ec_pairing_check BN254_G1`, pairingVersion) - testAccepts(t, g2bytes+g1bytes+`ec_pairing_check BN254_G2`, pairingVersion) + testAccepts(t, g1bytes+g2bytes+`ec_pairing_check BN254g1`, pairingVersion) + testAccepts(t, g2bytes+g1bytes+`ec_pairing_check BN254g2`, pairingVersion) }) t.Run("bls12-381", func(t *testing.T) { @@ -129,8 +129,8 @@ func TestPairCheck(t *testing.T) { g1bytes := fmt.Sprintf("byte 0x%s\n", hex.EncodeToString(bls12381G1sToBytes(g1points))) g2bytes := fmt.Sprintf("byte 0x%s\n", hex.EncodeToString(bls12381G2sToBytes(g2points))) - testAccepts(t, g1bytes+g2bytes+`ec_pairing_check BLS12_381_G1`, pairingVersion) - testAccepts(t, g2bytes+g1bytes+`ec_pairing_check BLS12_381_G2`, pairingVersion) + testAccepts(t, g1bytes+g2bytes+`ec_pairing_check BLS12_381g1`, pairingVersion) + testAccepts(t, g2bytes+g1bytes+`ec_pairing_check BLS12_381g2`, pairingVersion) }) } @@ -142,8 +142,8 @@ func TestEcMultiExp(t *testing.T) { g1point := bn254RandomG1() g1bytes1 := fmt.Sprintf("byte 0x%s\n", hex.EncodeToString(bn254G1ToBytes(&g1point))) - testAccepts(t, g1bytes1+"int 32; bzero; ec_multi_exp BN254_G1; int 64; bzero; ==", pairingVersion) - testAccepts(t, g1bytes1+"int 32; bzero; int 1; itob; b|; ec_multi_exp BN254_G1;"+g1bytes1+"==", pairingVersion) + testAccepts(t, g1bytes1+"int 32; bzero; ec_multi_exp BN254g1; int 64; bzero; ==", pairingVersion) + testAccepts(t, g1bytes1+"int 32; bzero; int 1; itob; b|; ec_multi_exp BN254g1;"+g1bytes1+"==", pairingVersion) } func TestSubgroupCheck(t *testing.T) { @@ -154,16 +154,16 @@ func TestSubgroupCheck(t *testing.T) { g1point := bn254RandomG1() g1bytes1 := fmt.Sprintf("byte 0x%s\n", hex.EncodeToString(bn254G1ToBytes(&g1point))) - testAccepts(t, g1bytes1+"ec_subgroup_check BN254_G1;", pairingVersion) + testAccepts(t, g1bytes1+"ec_subgroup_check BN254g1;", pairingVersion) /* On BN curve, subgroup == on curve, we can't create a g1bytes that makes this Accept g1bytes1 = ??? - testAccepts(t, g1bytes1+"ec_subgroup_check BN254_G1; !", pairingVersion) + testAccepts(t, g1bytes1+"ec_subgroup_check BN254g1; !", pairingVersion) */ g1point.X[0]++ // surely now out of subgroup, but also out of main curve, so panics g1bytes1 = fmt.Sprintf("byte 0x%s\n", hex.EncodeToString(bn254G1ToBytes(&g1point))) - testPanics(t, g1bytes1+"ec_subgroup_check BN254_G1; !", pairingVersion) + testPanics(t, g1bytes1+"ec_subgroup_check BN254g1; !", pairingVersion) } func TestMapTo(t *testing.T) { @@ -172,7 +172,7 @@ func TestMapTo(t *testing.T) { // Parameterize this to check all curves - testAccepts(t, "int 27; itob; ec_map_to BN254_G1; ec_subgroup_check BN254_G1", pairingVersion) + testAccepts(t, "int 27; itob; ec_map_to BN254g1; ec_subgroup_check BN254g1", pairingVersion) } func BenchmarkBn254(b *testing.B) { @@ -201,25 +201,25 @@ func BenchmarkBn254(b *testing.B) { byteG2 := fmt.Sprintf("byte 0x%s\n", hex.EncodeToString(g2bytes)) b.Run("g1 add", func(b *testing.B) { - benchmarkOperation(b, byteG1, "dup; ec_add BN254_G1", "pop; int 1") + benchmarkOperation(b, byteG1, "dup; ec_add BN254g1", "pop; int 1") }) b.Run("g2 add", func(b *testing.B) { - benchmarkOperation(b, byteG2, "dup; ec_add BN254_G2", "pop; int 1") + benchmarkOperation(b, byteG2, "dup; ec_add BN254g2", "pop; int 1") }) b.Run("g1 scalar_mul", func(b *testing.B) { - benchmarkOperation(b, byteG1, byteK+"ec_scalar_mul BN254_G1", "pop; int 1") + benchmarkOperation(b, byteG1, byteK+"ec_scalar_mul BN254g1", "pop; int 1") }) b.Run("g2 scalar_mul", func(b *testing.B) { - benchmarkOperation(b, byteG2, byteK+"ec_scalar_mul BN254_G2", "pop; int 1") + benchmarkOperation(b, byteG2, byteK+"ec_scalar_mul BN254g2", "pop; int 1") }) b.Run("g1 pairing f", func(b *testing.B) { - benchmarkOperation(b, "", byteG1+byteG2+"ec_pairing_check BN254_G1; !; assert", "int 1") + benchmarkOperation(b, "", byteG1+byteG2+"ec_pairing_check BN254g1; !; assert", "int 1") }) b.Run("g2 pairing f", func(b *testing.B) { - benchmarkOperation(b, "", byteG2+byteG1+"ec_pairing_check BN254_G2; !; assert", "int 1") + benchmarkOperation(b, "", byteG2+byteG1+"ec_pairing_check BN254g2; !; assert", "int 1") }) var g1GenNeg bn254.G1Affine @@ -231,47 +231,47 @@ func BenchmarkBn254(b *testing.B) { g2pbytes := fmt.Sprintf("byte 0x%s\n", hex.EncodeToString(bn254G2sToBytes(g2points))) b.Run("g1 pairing t2", func(b *testing.B) { - benchmarkOperation(b, "", g1pbytes+g2pbytes+"ec_pairing_check BN254_G1; assert", "int 1") + benchmarkOperation(b, "", g1pbytes+g2pbytes+"ec_pairing_check BN254g1; assert", "int 1") }) b.Run("g2 pairing t2", func(b *testing.B) { - benchmarkOperation(b, "", g2pbytes+g1pbytes+"ec_pairing_check BN254_G2; assert", "int 1") + benchmarkOperation(b, "", g2pbytes+g1pbytes+"ec_pairing_check BN254g2; assert", "int 1") }) b.Run("g1 pairing t4", func(b *testing.B) { benchmarkOperation(b, "", - g1pbytes+g1pbytes+"concat;"+g2pbytes+g2pbytes+"concat; ec_pairing_check BN254_G1; assert", "int 1") + g1pbytes+g1pbytes+"concat;"+g2pbytes+g2pbytes+"concat; ec_pairing_check BN254g1; assert", "int 1") }) b.Run("g2 pairing t4", func(b *testing.B) { benchmarkOperation(b, "", - g2pbytes+g2pbytes+"concat;"+g1pbytes+g1pbytes+"concat; ec_pairing_check BN254_G2; assert", "int 1") + g2pbytes+g2pbytes+"concat;"+g1pbytes+g1pbytes+"concat; ec_pairing_check BN254g2; assert", "int 1") }) for _, size := range []int{1, 10, 20, 30, 40, 50} { g1s := byteRepeat(g1bytes, size) ks := byteRepeat(kbytes, size) b.Run(fmt.Sprintf("g1 multi_exp %d", size), func(b *testing.B) { - benchmarkOperation(b, "", g1s+ks+"ec_multi_exp BN254_G1; pop", "int 1") + benchmarkOperation(b, "", g1s+ks+"ec_multi_exp BN254g1; pop", "int 1") }) } for _, size := range []int{1, 5, 10, 15, 20, 25} { g2s := byteRepeat(g2bytes, size) ks := byteRepeat(kbytes, size) b.Run(fmt.Sprintf("g2 multi_exp %d", size), func(b *testing.B) { - benchmarkOperation(b, "", g2s+ks+"ec_multi_exp BN254_G2; pop", "int 1") + benchmarkOperation(b, "", g2s+ks+"ec_multi_exp BN254g2; pop", "int 1") }) } b.Run("g1 subgroup", func(b *testing.B) { - benchmarkOperation(b, "", byteG1+"ec_subgroup_check BN254_G1; pop", "int 1") + benchmarkOperation(b, "", byteG1+"ec_subgroup_check BN254g1; pop", "int 1") }) b.Run("g2 subgroup", func(b *testing.B) { - benchmarkOperation(b, "", byteG2+"ec_subgroup_check BN254_G2; pop", "int 1") + benchmarkOperation(b, "", byteG2+"ec_subgroup_check BN254g2; pop", "int 1") }) b.Run("g1 map to", func(b *testing.B) { - benchmarkOperation(b, "", fpbytes+"ec_map_to BN254_G1; pop", "int 1") + benchmarkOperation(b, "", fpbytes+"ec_map_to BN254g1; pop", "int 1") }) b.Run("g2 map to", func(b *testing.B) { - benchmarkOperation(b, "", fp2bytes+"ec_map_to BN254_G2; pop", "int 1") + benchmarkOperation(b, "", fp2bytes+"ec_map_to BN254g2; pop", "int 1") }) } @@ -318,24 +318,24 @@ func BenchmarkBls12381(b *testing.B) { byteG2 := byteRepeat(g2bytes, 1) b.Run("g1 add", func(b *testing.B) { - benchmarkOperation(b, byteG1, "dup; ec_add BLS12_381_G1", "pop; int 1") + benchmarkOperation(b, byteG1, "dup; ec_add BLS12_381g1", "pop; int 1") }) b.Run("g2 add", func(b *testing.B) { - benchmarkOperation(b, byteG2, "dup; ec_add BLS12_381_G2", "pop; int 1") + benchmarkOperation(b, byteG2, "dup; ec_add BLS12_381g2", "pop; int 1") }) b.Run("g1 scalar_mul", func(b *testing.B) { - benchmarkOperation(b, byteG1, byteK+"ec_scalar_mul BLS12_381_G1", "pop; int 1") + benchmarkOperation(b, byteG1, byteK+"ec_scalar_mul BLS12_381g1", "pop; int 1") }) b.Run("g2 scalar_mul", func(b *testing.B) { - benchmarkOperation(b, byteG2, byteK+"ec_scalar_mul BLS12_381_G2", "pop; int 1") + benchmarkOperation(b, byteG2, byteK+"ec_scalar_mul BLS12_381g2", "pop; int 1") }) b.Run("g1 pairing f", func(b *testing.B) { - benchmarkOperation(b, "", byteG1+byteG2+"ec_pairing_check BLS12_381_G1; pop", "int 1") + benchmarkOperation(b, "", byteG1+byteG2+"ec_pairing_check BLS12_381g1; pop", "int 1") }) b.Run("g2 pairing f", func(b *testing.B) { - benchmarkOperation(b, "", byteG2+byteG1+"ec_pairing_check BLS12_381_G2; pop", "int 1") + benchmarkOperation(b, "", byteG2+byteG1+"ec_pairing_check BLS12_381g2; pop", "int 1") }) var g1GenNeg bls12381.G1Affine @@ -347,47 +347,47 @@ func BenchmarkBls12381(b *testing.B) { g2pbytes := fmt.Sprintf("byte 0x%s\n", hex.EncodeToString(bls12381G2sToBytes(g2points))) b.Run("g1 pairing t2", func(b *testing.B) { - benchmarkOperation(b, "", g1pbytes+g2pbytes+"ec_pairing_check BLS12_381_G1; assert", "int 1") + benchmarkOperation(b, "", g1pbytes+g2pbytes+"ec_pairing_check BLS12_381g1; assert", "int 1") }) b.Run("g2 pairing t2", func(b *testing.B) { - benchmarkOperation(b, "", g2pbytes+g1pbytes+"ec_pairing_check BLS12_381_G2; assert", "int 1") + benchmarkOperation(b, "", g2pbytes+g1pbytes+"ec_pairing_check BLS12_381g2; assert", "int 1") }) b.Run("g1 pairing t4", func(b *testing.B) { benchmarkOperation(b, "", - g1pbytes+g1pbytes+"concat;"+g2pbytes+g2pbytes+"concat; ec_pairing_check BLS12_381_G1; assert", "int 1") + g1pbytes+g1pbytes+"concat;"+g2pbytes+g2pbytes+"concat; ec_pairing_check BLS12_381g1; assert", "int 1") }) b.Run("g2 pairing t4", func(b *testing.B) { benchmarkOperation(b, "", - g2pbytes+g2pbytes+"concat;"+g1pbytes+g1pbytes+"concat; ec_pairing_check BLS12_381_G2; assert", "int 1") + g2pbytes+g2pbytes+"concat;"+g1pbytes+g1pbytes+"concat; ec_pairing_check BLS12_381g2; assert", "int 1") }) for _, size := range []int{1, 5, 10, 15, 20, 25} { g1s := byteRepeat(g1bytes, size) ks := byteRepeat(kbytes, size) b.Run(fmt.Sprintf("g1 multi_exp %d", size), func(b *testing.B) { - benchmarkOperation(b, "", g1s+ks+"ec_multi_exp BLS12_381_G1; pop", "int 1") + benchmarkOperation(b, "", g1s+ks+"ec_multi_exp BLS12_381g1; pop", "int 1") }) } for _, size := range []int{1, 3, 5, 7, 9, 11} { g2s := byteRepeat(g2bytes, size) ks := byteRepeat(kbytes, size) b.Run(fmt.Sprintf("g2 multi_exp %d", size), func(b *testing.B) { - benchmarkOperation(b, "", g2s+ks+"ec_multi_exp BLS12_381_G2; pop", "int 1") + benchmarkOperation(b, "", g2s+ks+"ec_multi_exp BLS12_381g2; pop", "int 1") }) } b.Run("g1 subgroup", func(b *testing.B) { - benchmarkOperation(b, "", byteG1+"ec_subgroup_check BLS12_381_G1; pop", "int 1") + benchmarkOperation(b, "", byteG1+"ec_subgroup_check BLS12_381g1; pop", "int 1") }) b.Run("g2 subgroup", func(b *testing.B) { - benchmarkOperation(b, "", byteG2+"ec_subgroup_check BLS12_381_G2; pop", "int 1") + benchmarkOperation(b, "", byteG2+"ec_subgroup_check BLS12_381g2; pop", "int 1") }) b.Run("g1 map to", func(b *testing.B) { - benchmarkOperation(b, "", fpbytes+"ec_map_to BLS12_381_G1; pop", "int 1") + benchmarkOperation(b, "", fpbytes+"ec_map_to BLS12_381g1; pop", "int 1") }) b.Run("g2 map to", func(b *testing.B) { - benchmarkOperation(b, "", fp2bytes+"ec_map_to BLS12_381_G2; pop", "int 1") + benchmarkOperation(b, "", fp2bytes+"ec_map_to BLS12_381g2; pop", "int 1") }) } diff --git a/data/transactions/logic/teal.tmLanguage.json b/data/transactions/logic/teal.tmLanguage.json index 12f8ecf91f..3a31b38e73 100644 --- a/data/transactions/logic/teal.tmLanguage.json +++ b/data/transactions/logic/teal.tmLanguage.json @@ -112,7 +112,7 @@ }, { "name": "variable.parameter.teal", - "match": "\\b(unknown|pay|keyreg|acfg|axfer|afrz|appl|NoOp|OptIn|CloseOut|ClearState|UpdateApplication|DeleteApplication|Secp256k1|Secp256r1|Sender|Fee|FirstValid|FirstValidTime|LastValid|Note|Lease|Receiver|Amount|CloseRemainderTo|VotePK|SelectionPK|VoteFirst|VoteLast|VoteKeyDilution|Type|TypeEnum|XferAsset|AssetAmount|AssetSender|AssetReceiver|AssetCloseTo|GroupIndex|TxID|ApplicationID|OnCompletion|NumAppArgs|NumAccounts|ApprovalProgram|ClearStateProgram|RekeyTo|ConfigAsset|ConfigAssetTotal|ConfigAssetDecimals|ConfigAssetDefaultFrozen|ConfigAssetUnitName|ConfigAssetName|ConfigAssetURL|ConfigAssetMetadataHash|ConfigAssetManager|ConfigAssetReserve|ConfigAssetFreeze|ConfigAssetClawback|FreezeAsset|FreezeAssetAccount|FreezeAssetFrozen|NumAssets|NumApplications|GlobalNumUint|GlobalNumByteSlice|LocalNumUint|LocalNumByteSlice|ExtraProgramPages|Nonparticipation|NumLogs|CreatedAssetID|CreatedApplicationID|LastLog|StateProofPK|NumApprovalProgramPages|NumClearStateProgramPages|MinTxnFee|MinBalance|MaxTxnLife|ZeroAddress|GroupSize|LogicSigVersion|Round|LatestTimestamp|CurrentApplicationID|CreatorAddress|CurrentApplicationAddress|GroupID|OpcodeBudget|CallerApplicationID|CallerApplicationAddress|ApplicationArgs|Accounts|Assets|Applications|Logs|ApprovalProgramPages|ClearStateProgramPages|URLEncoding|StdEncoding|JSONString|JSONUint64|JSONObject|AssetBalance|AssetFrozen|AssetTotal|AssetDecimals|AssetDefaultFrozen|AssetUnitName|AssetName|AssetURL|AssetMetadataHash|AssetManager|AssetReserve|AssetFreeze|AssetClawback|AssetCreator|AppApprovalProgram|AppClearStateProgram|AppGlobalNumUint|AppGlobalNumByteSlice|AppLocalNumUint|AppLocalNumByteSlice|AppExtraProgramPages|AppCreator|AppAddress|AcctBalance|AcctMinBalance|AcctAuthAddr|AcctTotalNumUint|AcctTotalNumByteSlice|AcctTotalExtraAppPages|AcctTotalAppsCreated|AcctTotalAppsOptedIn|AcctTotalAssetsCreated|AcctTotalAssets|AcctTotalBoxes|AcctTotalBoxBytes|VrfAlgorand|BlkSeed|BlkTimestamp|BN254_G1|BN254_G2|BLS12_381_G1|BLS12_381_G2)\\b" + "match": "\\b(unknown|pay|keyreg|acfg|axfer|afrz|appl|NoOp|OptIn|CloseOut|ClearState|UpdateApplication|DeleteApplication|Secp256k1|Secp256r1|Sender|Fee|FirstValid|FirstValidTime|LastValid|Note|Lease|Receiver|Amount|CloseRemainderTo|VotePK|SelectionPK|VoteFirst|VoteLast|VoteKeyDilution|Type|TypeEnum|XferAsset|AssetAmount|AssetSender|AssetReceiver|AssetCloseTo|GroupIndex|TxID|ApplicationID|OnCompletion|NumAppArgs|NumAccounts|ApprovalProgram|ClearStateProgram|RekeyTo|ConfigAsset|ConfigAssetTotal|ConfigAssetDecimals|ConfigAssetDefaultFrozen|ConfigAssetUnitName|ConfigAssetName|ConfigAssetURL|ConfigAssetMetadataHash|ConfigAssetManager|ConfigAssetReserve|ConfigAssetFreeze|ConfigAssetClawback|FreezeAsset|FreezeAssetAccount|FreezeAssetFrozen|NumAssets|NumApplications|GlobalNumUint|GlobalNumByteSlice|LocalNumUint|LocalNumByteSlice|ExtraProgramPages|Nonparticipation|NumLogs|CreatedAssetID|CreatedApplicationID|LastLog|StateProofPK|NumApprovalProgramPages|NumClearStateProgramPages|MinTxnFee|MinBalance|MaxTxnLife|ZeroAddress|GroupSize|LogicSigVersion|Round|LatestTimestamp|CurrentApplicationID|CreatorAddress|CurrentApplicationAddress|GroupID|OpcodeBudget|CallerApplicationID|CallerApplicationAddress|ApplicationArgs|Accounts|Assets|Applications|Logs|ApprovalProgramPages|ClearStateProgramPages|URLEncoding|StdEncoding|JSONString|JSONUint64|JSONObject|AssetBalance|AssetFrozen|AssetTotal|AssetDecimals|AssetDefaultFrozen|AssetUnitName|AssetName|AssetURL|AssetMetadataHash|AssetManager|AssetReserve|AssetFreeze|AssetClawback|AssetCreator|AppApprovalProgram|AppClearStateProgram|AppGlobalNumUint|AppGlobalNumByteSlice|AppLocalNumUint|AppLocalNumByteSlice|AppExtraProgramPages|AppCreator|AppAddress|AcctBalance|AcctMinBalance|AcctAuthAddr|AcctTotalNumUint|AcctTotalNumByteSlice|AcctTotalExtraAppPages|AcctTotalAppsCreated|AcctTotalAppsOptedIn|AcctTotalAssetsCreated|AcctTotalAssets|AcctTotalBoxes|AcctTotalBoxBytes|VrfAlgorand|BlkSeed|BlkTimestamp|BN254g1|BN254g2|BLS12_381g1|BLS12_381g2)\\b" } ] },