Skip to content

Commit

Permalink
uint512 -> uint256 for ecdsa opcodes
Browse files Browse the repository at this point in the history
  • Loading branch information
joe-p committed Nov 13, 2023
1 parent 73f71d3 commit 29caead
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 18 deletions.
4 changes: 2 additions & 2 deletions src/lib/compiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -785,7 +785,7 @@ export default class Compiler {
'concat'
);

this.lastType = '[uint512,uint512]';
this.lastType = '[uint256,uint256]';
},
},
ecdsa_pk_recover: {
Expand Down Expand Up @@ -833,7 +833,7 @@ export default class Compiler {
'concat'
);

this.lastType = '[uint512,uint512]';
this.lastType = '[uint256,uint256]';
},
},
// Global methods
Expand Down
6 changes: 3 additions & 3 deletions tests/contracts/artifacts/GeneralTest.approval.teal
Original file line number Diff line number Diff line change
Expand Up @@ -732,9 +732,9 @@ scratchSlot:
assert
retsub

// ecdsa()(uint512,uint512)
// ecdsa()(uint256,uint256)
abi_route_ecdsa:
// execute ecdsa()(uint512,uint512)
// execute ecdsa()(uint256,uint256)
callsub ecdsa
int 1
return
Expand Down Expand Up @@ -816,7 +816,7 @@ call_NoOp:
method "stringSubstring()void"
method "idProperty()void"
method "scratchSlot()void"
method "ecdsa()(uint512,uint512)"
method "ecdsa()(uint256,uint256)"
txna ApplicationArgs 0
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
err
Expand Down
6 changes: 3 additions & 3 deletions tests/contracts/artifacts/GeneralTest.arc32.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion tests/contracts/artifacts/GeneralTest.arc4.json
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@
"args": [],
"desc": "",
"returns": {
"type": "(uint512,uint512)",
"type": "(uint256,uint256)",
"desc": ""
}
},
Expand Down
2 changes: 1 addition & 1 deletion tests/contracts/general.algo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ class GeneralTest extends Contract {
assert(this.scratch.value === 1337);
}

ecdsa(): [uint<512>, uint<512>] {
ecdsa(): [uint<256>, uint<256>] {
ecdsa_verify('Secp256k1', '' as StaticArray<byte, 32>, 1, 2, 3, 4);
ecdsa_pk_decompress('Secp256k1', '' as StaticArray<byte, 33>);
return ecdsa_pk_recover('Secp256k1', '' as StaticArray<byte, 32>, 1, 2, 3);
Expand Down
16 changes: 8 additions & 8 deletions types/global.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -857,10 +857,10 @@ declare function sha3_256(data: BytesLike): StaticArray<byte, 32>;
declare function ecdsa_verify(
curve: 'Secp256k1' | 'Secp256r1',
data: StaticArray<byte, 32>,
sSignatureComponent: uint<512>,
rSignatureComponent: uint<512>,
xPubkeyComponent: uint<512>,
yPubkeyComponent: uint<512>
sSignatureComponent: uint<256>,
rSignatureComponent: uint<256>,
xPubkeyComponent: uint<256>,
yPubkeyComponent: uint<256>
): boolean;

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

/**
*
Expand All @@ -889,9 +889,9 @@ declare function ecdsa_pk_recover(
curve: 'Secp256k1' | 'Secp256r1',
data: StaticArray<byte, 32>,
recoveryID: uint64,
sSignatureComponent: uint<512>,
rSignatureComponent: uint<512>
): [uint<512>, uint<512>];
sSignatureComponent: uint<256>,
rSignatureComponent: uint<256>
): [uint<256>, uint<256>];

/**
* Returns zero bytes of the given size.
Expand Down

0 comments on commit 29caead

Please sign in to comment.