-
Notifications
You must be signed in to change notification settings - Fork 77
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revisiting Keccak and Dilithium Implementations on ARMv7-M (#338)
* Use Plantard arithmetic for NTT_769 in Dilithium * rm old smallntt.S * update benchmarks --------- Co-authored-by: Matthias J. Kannwischer <[email protected]>
- Loading branch information
1 parent
2c48508
commit 9c2bc41
Showing
7 changed files
with
829 additions
and
893 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
/** | ||
* Copyright (c) 2023 Junhao Huang ([email protected]) | ||
* | ||
* Licensed under the Apache License, Version 2.0(the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
#ifndef MACROS_SMALLNTT_I | ||
#define MACROS_SMALLNTT_I | ||
|
||
// general macros | ||
.macro load a, a0, a1, a2, a3, mem0, mem1, mem2, mem3 | ||
ldr.w \a0, [\a, \mem0] | ||
ldr.w \a1, [\a, \mem1] | ||
ldr.w \a2, [\a, \mem2] | ||
ldr.w \a3, [\a, \mem3] | ||
.endm | ||
|
||
.macro store a, a0, a1, a2, a3, mem0, mem1, mem2, mem3 | ||
str.w \a0, [\a, \mem0] | ||
str.w \a1, [\a, \mem1] | ||
str.w \a2, [\a, \mem2] | ||
str.w \a3, [\a, \mem3] | ||
.endm | ||
|
||
.macro doubleplant a, tmp, q, qa, plantconst | ||
smulwb \tmp, \plantconst, \a | ||
smulwt \a, \plantconst, \a | ||
smlabt \tmp, \tmp, \q, \qa | ||
smlabt \a, \a, \q, \qa | ||
pkhtb \a, \a, \tmp, asr#16 | ||
.endm | ||
|
||
.macro doublebarrett a, tmp, tmp2, q, barrettconst | ||
smulbb \tmp, \a, \barrettconst | ||
smultb \tmp2, \a, \barrettconst | ||
asr \tmp, \tmp, #26 | ||
asr \tmp2, \tmp2, #26 | ||
smulbb \tmp, \tmp, \q | ||
smulbb \tmp2, \tmp2, \q | ||
pkhbt \tmp, \tmp, \tmp2, lsl#16 | ||
usub16 \a, \a, \tmp | ||
.endm | ||
|
||
// q locate in the top half of the register | ||
.macro plant_red q, qa, qinv, tmp | ||
mul \tmp, \tmp, \qinv | ||
//tmp*qinv mod 2^2n/ 2^n; in high half | ||
smlatt \tmp, \tmp, \q, \qa | ||
// result in high half | ||
.endm | ||
|
||
.macro mul_twiddle_plant a, twiddle, tmp, q, qa | ||
smulwb \tmp, \twiddle, \a | ||
smulwt \a, \twiddle, \a | ||
smlabt \tmp, \tmp, \q, \qa | ||
smlabt \a, \a, \q, \qa | ||
pkhtb \a, \a, \tmp, asr#16 | ||
.endm | ||
|
||
.macro doublebutterfly_plant a0, a1, twiddle, tmp, q, qa | ||
smulwb \tmp, \twiddle, \a1 | ||
smulwt \a1, \twiddle, \a1 | ||
smlabt \tmp, \tmp, \q, \qa | ||
smlabt \a1, \a1, \q, \qa | ||
pkhtb \tmp, \a1, \tmp, asr#16 | ||
usub16 \a1, \a0, \tmp | ||
uadd16 \a0, \a0, \tmp | ||
.endm | ||
|
||
.macro two_doublebutterfly_plant a0, a1, a2, a3, twiddle0, twiddle1, tmp, q, qa | ||
doublebutterfly_plant \a0, \a1, \twiddle0, \tmp, \q, \qa | ||
doublebutterfly_plant \a2, \a3, \twiddle1, \tmp, \q, \qa | ||
.endm | ||
|
||
//For 3329 | ||
.macro fullplant a0, a1, a2, a3, a4, a5, a6, a7, tmp, q, qa, plantconst | ||
movw \plantconst, #44984 | ||
movt \plantconst, #19 | ||
doubleplant \a0, \tmp, \q, \qa, \plantconst | ||
doubleplant \a1, \tmp, \q, \qa, \plantconst | ||
doubleplant \a2, \tmp, \q, \qa, \plantconst | ||
doubleplant \a3, \tmp, \q, \qa, \plantconst | ||
doubleplant \a4, \tmp, \q, \qa, \plantconst | ||
doubleplant \a5, \tmp, \q, \qa, \plantconst | ||
doubleplant \a6, \tmp, \q, \qa, \plantconst | ||
doubleplant \a7, \tmp, \q, \qa, \plantconst | ||
.endm | ||
|
||
#endif |
Oops, something went wrong.