forked from ethereum/EIPs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add PQClean falcon512 implementation
Signed-off-by: eum602 <[email protected]>
- Loading branch information
Showing
17 changed files
with
11,729 additions
and
5 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
*.o | ||
libfalcon-512_clean.a |
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,22 @@ | ||
# Based on PQClean https://github.com/PQClean/PQClean/tree/master/crypto_sign/falcon-512/clean | ||
# This Makefile can be used with GNU Make or BSD Make | ||
|
||
LIB=libfalcon-512_clean.a | ||
|
||
SOURCES = codec.c common.c fft.c fpr.c keygen.c pqclean.c rng.c sign.c verify-signature.c | ||
OBJECTS = codec.o common.o fft.o fpr.o keygen.o pqclean.o rng.o sign.o verify-signature.o | ||
HEADERS = api.h fpr.h inner.h | ||
|
||
CFLAGS=-std=c99 -O2 -W -Wall -Wconversion -Wextra -Wpedantic -Wvla -Werror -Wmissing-prototypes -Wredundant-decls -I../../../common $(EXTRAFLAGS) | ||
|
||
all: $(LIB) | ||
|
||
%.o: %.c $(HEADERS) | ||
$(CC) $(CFLAGS) -c -o $@ $< | ||
|
||
$(LIB): $(OBJECTS) | ||
$(AR) -r $@ $(OBJECTS) | ||
|
||
clean: | ||
$(RM) $(OBJECTS) | ||
$(RM) $(LIB) |
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,83 @@ | ||
// Based on PQClean https://github.com/PQClean/PQClean/tree/master/crypto_sign/falcon-512/clean | ||
#ifndef PQCLEAN_FALCON512_CLEAN_API_H | ||
#define PQCLEAN_FALCON512_CLEAN_API_H | ||
|
||
#include <stddef.h> | ||
#include <stdint.h> | ||
|
||
#define PQCLEAN_FALCON512_CLEAN_CRYPTO_SECRETKEYBYTES 1281 | ||
#define PQCLEAN_FALCON512_CLEAN_CRYPTO_PUBLICKEYBYTES 897 | ||
#define PQCLEAN_FALCON512_CLEAN_CRYPTO_BYTES 752 | ||
|
||
#define PQCLEAN_FALCON512_CLEAN_CRYPTO_ALGNAME "Falcon-512" | ||
|
||
#define PQCLEAN_FALCONPADDED512_CLEAN_CRYPTO_BYTES 666 // used in signature verification | ||
|
||
/* | ||
* Generate a new key pair. Public key goes into pk[], private key in sk[]. | ||
* Key sizes are exact (in bytes): | ||
* public (pk): PQCLEAN_FALCON512_CLEAN_CRYPTO_PUBLICKEYBYTES | ||
* private (sk): PQCLEAN_FALCON512_CLEAN_CRYPTO_SECRETKEYBYTES | ||
* | ||
* Return value: 0 on success, -1 on error. | ||
*/ | ||
int PQCLEAN_FALCON512_CLEAN_crypto_sign_keypair( | ||
uint8_t *pk, uint8_t *sk); | ||
|
||
/* | ||
* Compute a signature on a provided message (m, mlen), with a given | ||
* private key (sk). Signature is written in sig[], with length written | ||
* into *siglen. Signature length is variable; maximum signature length | ||
* (in bytes) is PQCLEAN_FALCON512_CLEAN_CRYPTO_BYTES. | ||
* | ||
* sig[], m[] and sk[] may overlap each other arbitrarily. | ||
* | ||
* Return value: 0 on success, -1 on error. | ||
*/ | ||
int PQCLEAN_FALCON512_CLEAN_crypto_sign_signature( | ||
uint8_t *sig, size_t *siglen, | ||
const uint8_t *m, size_t mlen, const uint8_t *sk); | ||
|
||
/* | ||
* Verify a signature (sig, siglen) on a message (m, mlen) with a given | ||
* public key (pk). | ||
* | ||
* sig[], m[] and pk[] may overlap each other arbitrarily. | ||
* | ||
* Return value: 0 on success, -1 on error. | ||
*/ | ||
int PQCLEAN_FALCON512_CLEAN_crypto_sign_verify( | ||
const uint8_t *sig, size_t siglen, | ||
const uint8_t *m, size_t mlen, const uint8_t *pk); | ||
|
||
/* | ||
* Compute a signature on a message and pack the signature and message | ||
* into a single object, written into sm[]. The length of that output is | ||
* written in *smlen; that length may be larger than the message length | ||
* (mlen) by up to PQCLEAN_FALCON512_CLEAN_CRYPTO_BYTES. | ||
* | ||
* sm[] and m[] may overlap each other arbitrarily; however, sm[] shall | ||
* not overlap with sk[]. | ||
* | ||
* Return value: 0 on success, -1 on error. | ||
*/ | ||
int PQCLEAN_FALCON512_CLEAN_crypto_sign( | ||
uint8_t *sm, size_t *smlen, | ||
const uint8_t *m, size_t mlen, const uint8_t *sk); | ||
|
||
/* | ||
* Open a signed message object (sm, smlen) and verify the signature; | ||
* on success, the message itself is written into m[] and its length | ||
* into *mlen. The message is shorter than the signed message object, | ||
* but the size difference depends on the signature value; the difference | ||
* may range up to PQCLEAN_FALCON512_CLEAN_CRYPTO_BYTES. | ||
* | ||
* m[], sm[] and pk[] may overlap each other arbitrarily. | ||
* | ||
* Return value: 0 on success, -1 on error. | ||
*/ | ||
int PQCLEAN_FALCON512_CLEAN_crypto_sign_open( | ||
uint8_t *m, size_t *mlen, | ||
const uint8_t *sm, size_t smlen, const uint8_t *pk); | ||
|
||
#endif |
Oops, something went wrong.