Skip to content

Commit

Permalink
draft mulmod
Browse files Browse the repository at this point in the history
  • Loading branch information
vincentvbh committed May 17, 2024
1 parent e969435 commit ced3901
Show file tree
Hide file tree
Showing 17 changed files with 103 additions and 14 deletions.
16 changes: 15 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
A repository with examples for several tricks used in software polynomial multiplication works.

## Structure of this repository
- `examples_basic`: Examples of basic ideas of homomorphisms.
- `examples_hom`: Examples of basic ideas of homomorphisms.
- `DWT.c`: This file demonstrates Cooley--Tukey FFT for discrete weighted transform.
- Assumed knowledge: Chinese remainder theorem for polynomial rings.
- References: [CT65], [CF94].
Expand Down Expand Up @@ -57,6 +57,20 @@ A repository with examples for several tricks used in software polynomial multip
- References: [BGM93].
- Additional references: [Bru78].

- `examples_mulmod`: Examples of modular multiplications.
- `Montgomery_acc`: Accumulative variant of Montgomery multiplication.
- Assumed knowledge:
- References:
- Additional references:
- `Montgomery_sub`: Subtractive variant of Montgomery multiplication.
- Assumed knowledge:
- References:
- Additional references:
- `Barrett`: Barrett multiplication.
- Assumed knowledge:
- References:
- Additional references:

- `examples_advanced`: Examples of advanced constructions built upon the basic ideas.
- `BigIntMul.c`: This file demonstrates how to multiply integers via polynomial multiplications.
- Assumed knowledge: Integer and polynomial multiplications.
Expand Down
5 changes: 2 additions & 3 deletions examples_basic/DWT.c → examples_hom/DWT.c
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@

#include <stdint.h>
#include <stdio.h>
#include <stdint.h>
#include <stddef.h>
#include <stdlib.h>
#include <string.h>

#include <memory.h>
#include <assert.h>

#include "tools.h"
Expand Down
5 changes: 2 additions & 3 deletions examples_basic/FNT.c → examples_hom/FNT.c
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@

#include <stdint.h>
#include <stdio.h>
#include <stdint.h>
#include <stddef.h>
#include <stdlib.h>
#include <string.h>

#include <memory.h>
#include <assert.h>

#include "tools.h"
Expand Down
5 changes: 2 additions & 3 deletions examples_basic/GT.c → examples_hom/GT.c
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@

#include <stdint.h>
#include <stdio.h>
#include <stdint.h>
#include <stddef.h>
#include <stdlib.h>
#include <string.h>

#include <memory.h>
#include <assert.h>

#include "tools.h"
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion examples_basic/Karatsuba.c → examples_hom/Karatsuba.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

#include <stdio.h>
#include <stddef.h>
#include <stdint.h>
#include <stddef.h>
#include <stdlib.h>
#include <memory.h>
#include <assert.h>
Expand Down
File renamed without changes.
3 changes: 2 additions & 1 deletion examples_basic/Nussbaumer.c → examples_hom/Nussbaumer.c
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@

#include <stdio.h>
#include <stdint.h>
#include <stddef.h>
#include <stdlib.h>
#include <stdbool.h>
#include <memory.h>
#include <assert.h>

#include "tools.h"
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions examples_basic/Schoenhage.c → examples_hom/Schoenhage.c
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@

#include <stdio.h>
#include <stdint.h>
#include <stddef.h>
#include <stdlib.h>
#include <stdbool.h>
#include <memory.h>
#include <assert.h>

#include "tools.h"
#include "naive_mult.h"
#include "gen_table.h"
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
12 changes: 12 additions & 0 deletions examples_mulmod/Barrett.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@

#include <stdio.h>
#include <stdint.h>
#include <stddef.h>
#include <stdlib.h>
#include <memory.h>
#include <assert.h>

int main(void){


}
40 changes: 40 additions & 0 deletions examples_mulmod/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@

CC = gcc

CFLAGS += -O0 -Wall -Wunused -Wpedantic -Wno-pointer-arith

COMMON_PATH = ../common

CFLAGS += -I$(COMMON_PATH)

COMMON_SOURCE = $(COMMON_PATH)/tools.c $(COMMON_PATH)/naive_mult.c $(COMMON_PATH)/gen_table.c $(COMMON_PATH)/ntt_c.c

ASM_HEADERs =
ASM_SOURCEs =
C_HEADERs =
C_SOURCEs =

SOURCEs = $(ASM_SOURCEs) $(C_SOURCEs) $(COMMON_SOURCE)
HEADERs = $(ASM_HEADERs) $(C_HEADERs)

all: Montgomery_acc Montgomery_sub Barrett

Montgomery_acc: Montgomery_acc.c $(SOURCEs) $(HEADERs)
$(CC) $(CFLAGS) $(SOURCEs) $< -o $@

Montgomery_sub: Montgomery_sub.c $(SOURCEs) $(HEADERs)
$(CC) $(CFLAGS) $(SOURCEs) $< -o $@

Barrett: Barrett.c $(SOURCEs) $(HEADERs)
$(CC) $(CFLAGS) $(SOURCEs) $< -o $@


.PHONY: clean
clean:
rm -f Montgomery_acc
rm -f Montgomery_sub
rm -f Barrett




12 changes: 12 additions & 0 deletions examples_mulmod/Montgomery_acc.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@

#include <stdio.h>
#include <stdint.h>
#include <stddef.h>
#include <stdlib.h>
#include <memory.h>
#include <assert.h>

int main(void){


}
13 changes: 13 additions & 0 deletions examples_mulmod/Montgomery_sub.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@

#include <stdio.h>
#include <stdint.h>
#include <stddef.h>
#include <stdlib.h>
#include <memory.h>
#include <assert.h>

int main(void){



}

0 comments on commit ced3901

Please sign in to comment.