Skip to content

Commit

Permalink
fix bug
Browse files Browse the repository at this point in the history
  • Loading branch information
kyscott18 committed Dec 1, 2023
1 parent c58fa0d commit 576caf6
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 4 deletions.
53 changes: 53 additions & 0 deletions src/keccakf.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,60 @@ test("_KeccakF", () => {
// ^?
assertType<Tuple<Word, 50>>([] as unknown as t);

assertType<t[0]>([] as unknown as Word1);
assertType<t[1]>([] as unknown as Word1);
assertType<t[2]>([] as unknown as Word0);
assertType<t[3]>([] as unknown as Call<Convert32bitHexToWord, "0x00400000">);
assertType<t[4]>([] as unknown as Word0);
assertType<t[5]>([] as unknown as Call<Convert32bitHexToWord, "0x00004000">);
assertType<t[6]>([] as unknown as Word0);
assertType<t[7]>([] as unknown as Call<Convert32bitHexToWord, "0x00400001">);
assertType<t[8]>([] as unknown as Word0);
assertType<t[9]>([] as unknown as Call<Convert32bitHexToWord, "0x00004000">);

assertType<t[10]>([] as unknown as Word0);
assertType<t[11]>([] as unknown as Call<Convert32bitHexToWord, "0x20000008">);
assertType<t[12]>([] as unknown as Word0);
assertType<t[13]>([] as unknown as Word0);
assertType<t[14]>([] as unknown as Word0);
assertType<t[15]>([] as unknown as Call<Convert32bitHexToWord, "0x00000008">);
assertType<t[16]>([] as unknown as Word0);
assertType<t[17]>([] as unknown as Call<Convert32bitHexToWord, "0x20000000">);
assertType<t[18]>([] as unknown as Word0);
assertType<t[19]>([] as unknown as Word0);

assertType<t[20]>([] as unknown as Word0);
assertType<t[21]>([] as unknown as Call<Convert32bitHexToWord, "0x04000000">);
assertType<t[22]>([] as unknown as Word0);
assertType<t[23]>([] as unknown as Word0);
assertType<t[24]>([] as unknown as Word0);
assertType<t[25]>([] as unknown as Call<Convert32bitHexToWord, "0x04040000">);
assertType<t[26]>([] as unknown as Word0);
assertType<t[27]>([] as unknown as Word0);
assertType<t[28]>([] as unknown as Word0);
assertType<t[29]>([] as unknown as Call<Convert32bitHexToWord, "0x00040000">);

assertType<t[30]>([] as unknown as Word0);
assertType<t[31]>([] as unknown as Word0);
assertType<t[32]>([] as unknown as Call<Convert32bitHexToWord, "0x00000010">);
assertType<t[33]>([] as unknown as Word0);
assertType<t[34]>([] as unknown as Call<Convert32bitHexToWord, "0x02000000">);
assertType<t[35]>([] as unknown as Word0);
assertType<t[36]>([] as unknown as Word0);
assertType<t[37]>([] as unknown as Word0);
assertType<t[38]>([] as unknown as Call<Convert32bitHexToWord, "0x02000010">);
assertType<t[39]>([] as unknown as Word0);

assertType<t[40]>([] as unknown as Word0);
assertType<t[41]>([] as unknown as Word0);
assertType<t[42]>([] as unknown as Call<Convert32bitHexToWord, "0x01000200">);
assertType<t[43]>([] as unknown as Word0);
assertType<t[44]>([] as unknown as Word0);
assertType<t[45]>([] as unknown as Word0);
assertType<t[46]>([] as unknown as Call<Convert32bitHexToWord, "0x00000200">);
assertType<t[47]>([] as unknown as Word0);
assertType<t[48]>([] as unknown as Call<Convert32bitHexToWord, "0x01000000">);
assertType<t[49]>([] as unknown as Word0);
});

test("KeccakF", () => {
Expand Down
8 changes: 4 additions & 4 deletions src/keccakf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ export interface RhoAndPi extends Fn {
Call<WordRotlH, s[34], s[35], 15>,
Call<WordRotlL, s[34], s[35], 15>,
Call<WordRotlH, s[46], s[47], 56>,
Call<WordRotlL, s[47], s[47], 56>,
Call<WordRotlL, s[46], s[47], 56>,
Call<WordRotlH, s[4], s[5], 62>,
Call<WordRotlL, s[4], s[5], 62>,
Call<WordRotlH, s[16], s[17], 55>,
Expand Down Expand Up @@ -397,9 +397,9 @@ export interface Iota extends Fn {
*/
export interface _KeccakF extends Fn {
return: this["args"] extends [infer s extends S, infer round extends Round[number]]
? Call<Theta, s> extends infer a extends S
? Call<RhoAndPi, a> extends infer b extends S
? Call<Chi, b> extends infer c extends S
? Call<Theta, s> extends infer a
? Call<RhoAndPi, a> extends infer b
? Call<Chi, b> extends infer c
? Call<Iota, c, round>
: never
: never
Expand Down

0 comments on commit 576caf6

Please sign in to comment.