Skip to content

Commit 46eb1f3

Browse files
committed
uint512 -> uint256 for ecdsa opcodes
1 parent 73f71d3 commit 46eb1f3

File tree

6 files changed

+26
-26
lines changed

6 files changed

+26
-26
lines changed

src/lib/compiler.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -776,16 +776,16 @@ export default class Compiler {
776776

777777
this.pushLines(
778778
node,
779-
`byte 0x${'FF'.repeat(64)}`,
779+
`byte 0x${'FF'.repeat(32)}`,
780780
'b&',
781781
'swap',
782-
`byte 0x${'FF'.repeat(64)}`,
782+
`byte 0x${'FF'.repeat(32)}`,
783783
'b&',
784784
'swap',
785785
'concat'
786786
);
787787

788-
this.lastType = '[uint512,uint512]';
788+
this.lastType = '[uint256,uint256]';
789789
},
790790
},
791791
ecdsa_pk_recover: {
@@ -824,16 +824,16 @@ export default class Compiler {
824824

825825
this.pushLines(
826826
node,
827-
`byte 0x${'FF'.repeat(64)}`,
827+
`byte 0x${'FF'.repeat(32)}`,
828828
'b&',
829829
'swap',
830-
`byte 0x${'FF'.repeat(64)}`,
830+
`byte 0x${'FF'.repeat(32)}`,
831831
'b&',
832832
'swap',
833833
'concat'
834834
);
835835

836-
this.lastType = '[uint512,uint512]';
836+
this.lastType = '[uint256,uint256]';
837837
},
838838
},
839839
// Global methods

tests/contracts/artifacts/GeneralTest.approval.teal

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -732,9 +732,9 @@ scratchSlot:
732732
assert
733733
retsub
734734

735-
// ecdsa()(uint512,uint512)
735+
// ecdsa()(uint256,uint256)
736736
abi_route_ecdsa:
737-
// execute ecdsa()(uint512,uint512)
737+
// execute ecdsa()(uint256,uint256)
738738
callsub ecdsa
739739
int 1
740740
return
@@ -755,10 +755,10 @@ ecdsa:
755755
// ecdsa_pk_decompress('Secp256k1', '' as StaticArray<byte, 33>)
756756
byte 0x000000000000000000000000000000000000000000000000000000000000000000 // ""
757757
ecdsa_pk_decompress Secp256k1
758-
byte 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
758+
byte 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
759759
b&
760760
swap
761-
byte 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
761+
byte 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
762762
b&
763763
swap
764764
concat
@@ -770,10 +770,10 @@ ecdsa:
770770
byte 0x02
771771
byte 0x03
772772
ecdsa_pk_recover Secp256k1
773-
byte 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
773+
byte 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
774774
b&
775775
swap
776-
byte 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
776+
byte 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
777777
b&
778778
swap
779779
concat
@@ -816,7 +816,7 @@ call_NoOp:
816816
method "stringSubstring()void"
817817
method "idProperty()void"
818818
method "scratchSlot()void"
819-
method "ecdsa()(uint512,uint512)"
819+
method "ecdsa()(uint256,uint256)"
820820
txna ApplicationArgs 0
821821
match abi_route_txnTypeEnum abi_route_txnGroupLength abi_route_asserts abi_route_verifyTxnFromArg abi_route_verifyTxnFromTxnGroup abi_route_verifyTxnCondition abi_route_verifyTxnIncludedIn abi_route_verifyTxnNotIncludedIn abi_route_submitPendingGroup abi_route_methodWithTxnArgs abi_route_shift abi_route_fromBytes abi_route_fromID abi_route_bzeroFunction abi_route_events abi_route_letOptimization abi_route_staticContractProperties abi_route_numberToString abi_route_methodOnParens abi_route_stringSubstring abi_route_idProperty abi_route_scratchSlot abi_route_ecdsa
822822
err

tests/contracts/artifacts/GeneralTest.arc32.json

Lines changed: 3 additions & 3 deletions
Large diffs are not rendered by default.

tests/contracts/artifacts/GeneralTest.arc4.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@
228228
"args": [],
229229
"desc": "",
230230
"returns": {
231-
"type": "(uint512,uint512)",
231+
"type": "(uint256,uint256)",
232232
"desc": ""
233233
}
234234
},

tests/contracts/general.algo.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ class GeneralTest extends Contract {
147147
assert(this.scratch.value === 1337);
148148
}
149149

150-
ecdsa(): [uint<512>, uint<512>] {
150+
ecdsa(): [uint<256>, uint<256>] {
151151
ecdsa_verify('Secp256k1', '' as StaticArray<byte, 32>, 1, 2, 3, 4);
152152
ecdsa_pk_decompress('Secp256k1', '' as StaticArray<byte, 33>);
153153
return ecdsa_pk_recover('Secp256k1', '' as StaticArray<byte, 32>, 1, 2, 3);

types/global.d.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -857,10 +857,10 @@ declare function sha3_256(data: BytesLike): StaticArray<byte, 32>;
857857
declare function ecdsa_verify(
858858
curve: 'Secp256k1' | 'Secp256r1',
859859
data: StaticArray<byte, 32>,
860-
sSignatureComponent: uint<512>,
861-
rSignatureComponent: uint<512>,
862-
xPubkeyComponent: uint<512>,
863-
yPubkeyComponent: uint<512>
860+
sSignatureComponent: uint<256>,
861+
rSignatureComponent: uint<256>,
862+
xPubkeyComponent: uint<256>,
863+
yPubkeyComponent: uint<256>
864864
): boolean;
865865

866866
/**
@@ -873,7 +873,7 @@ declare function ecdsa_verify(
873873
declare function ecdsa_pk_decompress(
874874
curve: 'Secp256k1' | 'Secp256r1',
875875
pubKey: StaticArray<byte, 33>
876-
): [uint<512>, uint<512>];
876+
): [uint<256>, uint<256>];
877877

878878
/**
879879
*
@@ -889,9 +889,9 @@ declare function ecdsa_pk_recover(
889889
curve: 'Secp256k1' | 'Secp256r1',
890890
data: StaticArray<byte, 32>,
891891
recoveryID: uint64,
892-
sSignatureComponent: uint<512>,
893-
rSignatureComponent: uint<512>
894-
): [uint<512>, uint<512>];
892+
sSignatureComponent: uint<256>,
893+
rSignatureComponent: uint<256>
894+
): [uint<256>, uint<256>];
895895

896896
/**
897897
* Returns zero bytes of the given size.

0 commit comments

Comments
 (0)