Skip to content

Commit 06fe6fa

Browse files
authored
feat: GF251 example (#1119)
This provides an implementation of additions and multiplications on the field GF251 for u8 elements. U8 have been chosen to be able to test all cases, even if only sampled in the final unit tests for performance reasons. * addition The function sums two u8s and returns the result modulo 251. It uses register splitting and carries to wrap around 251. * multiplication This function multiplies two u8s and returns the result modulo 251. For the multiplication function, we have implemented the Montgomery algorithm using R=256, co-prime with 251, and a reduce function. This algorithm shifts the modulo to the R chosen, here 256, where arithmetic can be achieved by register splitting and bit shifting. The reduce function then projects the result back to the 251 modulo.
1 parent ad261e2 commit 06fe6fa

File tree

4 files changed

+7104
-0
lines changed

4 files changed

+7104
-0
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,7 @@ go.work
2020
bin
2121
*.lt
2222
*.bin
23+
24+
tmp
25+
26+

pkg/test/assembly_unit_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,3 +90,7 @@ func Test_Asm_SimpleOnCurve(t *testing.T) {
9090
func Test_Asm_RecPow(t *testing.T) {
9191
test_util.CheckWithFields(t, false, "asm/unit/rec_pow", ASM_MAX_PADDING, sc.BLS12_377)
9292
}
93+
94+
func Test_Asm_Gf251(t *testing.T) {
95+
test_util.Check(t, false, "asm/unit/gf251")
96+
}

0 commit comments

Comments
 (0)