Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add sig api with picnic #120

Merged

Conversation

christianpaquin
Copy link
Contributor

@christianpaquin christianpaquin commented May 11, 2017

This pull request proposes a new signature API modeled after the kex api, and adds the Picnic signature scheme.

Picnic must currently be downloaded and set up (to generate parameters) using a script (download-and-setup-picnic.sh). We can migrate to a git submodule at a later time, after this PR is reviewed.

The Visual Studio build has not yet been modified to support Picnic; this will be done after this PR is reviewed.

@smashra
Copy link
Contributor

smashra commented Jun 26, 2017

I'm getting following error, please fix:
external/Picnic-master/LowMC.c: In function 'getAllRandomness':
external/Picnic-master/LowMC.c:209:20: error: storage size of 'ctx' isn't known
EVP_CIPHER_CTX ctx;
^~~
external/Picnic-master/LowMC.c:209:20: error: unused variable 'ctx' [-Werror=unused-variable]
external/Picnic-master/LowMC.c: In function 'cleanup_EVP':
external/Picnic-master/LowMC.c:245:5: error: 'ERR_remove_state' is deprecated [-Werror=deprecated-declarations]
ERR_remove_state(0);
^~~~~~~~~~~~~~~~
In file included from /usr/local/include/openssl/bn.h:31:0,
from /usr/local/include/openssl/asn1.h:24,
from /usr/local/include/openssl/objects.h:15,
from /usr/local/include/openssl/evp.h:28,
from external/Picnic-master/LowMC.c:32:
/usr/local/include/openssl/err.h:249:1: note: declared here
DEPRECATEDIN_1_0_0(void ERR_remove_state(unsigned long pid))
^
cc1: all warnings being treated as errors

@tlepoint
Copy link
Contributor

tlepoint commented Jun 28, 2017

Apparently, picnic is in master? (but without test_sig?)

@dstebila
Copy link
Member

Yeah there's been a bit of confusion about this PR and what should be added. I'm working with @smashra to try to sort it out and will update you on here in the next few days.

@smashra
Copy link
Contributor

smashra commented Jun 29, 2017

Removing make and build steps from download-and-setup-picnic.sh as they are being taken care of from the main Makefile with configure options in configure.ac.

@smashra
Copy link
Contributor

smashra commented Jun 29, 2017

Made
#include <graycode.h>
to
#include <m4ri/graycode.h>
in preprocessmatrices.c

for making --with-m4ri-dir option consistent with others.

Please update your branch.

@smashra
Copy link
Contributor

smashra commented Jun 29, 2017

Can you please create another pull request to fix this:

Made
#include <graycode.h>
to
#include <m4ri/graycode.h>
in preprocessmatrices.c

for making --with-m4ri-dir option consistent with others.

Such that I can check in picnic code.

@smashra
Copy link
Contributor

smashra commented Jun 29, 2017

Sorry, the bold and caps was a mistake, totally unintentional.

@smashra
Copy link
Contributor

smashra commented Jun 30, 2017

Please fix these warning:

src/sig_picnic/external/Picnic-master/preprocessMatrices.c:70:23: error: comparison between signed and unsigned integer expressions [-Werror=sign-compare]
for (int i = 0; i < numRounds; i++) {
^
src/sig_picnic/external/Picnic-master/preprocessMatrices.c:72:27: error: comparison between signed and unsigned integer expressions [-Werror=sign-compare]
for (int j = 0; j < stateBits / t; j++) {
^
src/sig_picnic/external/Picnic-master/preprocessMatrices.c:80:23: error: comparison between signed and unsigned integer expressions [-Werror=sign-compare]
for (int i = 0; i < numRounds; i++) {
^
src/sig_picnic/external/Picnic-master/preprocessMatrices.c:82:27: error: comparison between signed and unsigned integer expressions [-Werror=sign-compare]
for (int j = 0; j < stateBits / t; j++) {
^
src/sig_picnic/external/Picnic-master/preprocessMatrices.c:93:23: error: comparison between signed and unsigned integer expressions [-Werror=sign-compare]
for (int i = 0; i < numRounds; i++) {
^
src/sig_picnic/external/Picnic-master/preprocessMatrices.c:94:27: error: comparison between signed and unsigned integer expressions [-Werror=sign-compare]
for (int j = 0; j < stateBits / t; j++) {
^
src/sig_picnic/external/Picnic-master/preprocessMatrices.c:105:19: error: comparison between signed and unsigned integer expressions [-Werror=sign-compare]
for (i = 0; i < numRounds; i++) {
^
src/sig_picnic/external/Picnic-master/preprocessMatrices.c:107:23: error: comparison between signed and unsigned integer expressions [-Werror=sign-compare]
for (j = 0; j < stateBits / t; j++) {
^
src/sig_picnic/external/Picnic-master/preprocessMatrices.c:111:31: error: comparison between signed and unsigned integer expressions [-Werror=sign-compare]
for (l = 0; l < stateWords; l++) {
^
src/sig_picnic/external/Picnic-master/preprocessMatrices.c:113:27: error: comparison between signed and unsigned integer expressions [-Werror=sign-compare]
if (l != stateWords - 1) {
^~
src/sig_picnic/external/Picnic-master/preprocessMatrices.c:126:19: error: comparison between signed and unsigned integer expressions [-Werror=sign-compare]
if (j != (stateBits / t) - 1) {
^~
src/sig_picnic/external/Picnic-master/preprocessMatrices.c:132:15: error: comparison between signed and unsigned integer expressions [-Werror=sign-compare]
if (i != numRounds - 1) {
^~
src/sig_picnic/external/Picnic-master/preprocessMatrices.c:138:23: error: comparison between signed and unsigned integer expressions [-Werror=sign-compare]
for (int i = 0; i < numRounds; i++) {
^
src/sig_picnic/external/Picnic-master/preprocessMatrices.c:139:27: error: comparison between signed and unsigned integer expressions [-Werror=sign-compare]
for (int j = 0; j < stateBits / t; j++) {
^
src/sig_picnic/external/Picnic-master/preprocessMatrices.c: In function ‘writeRoundConstants’:
src/sig_picnic/external/Picnic-master/preprocessMatrices.c:152:23: error: comparison between signed and unsigned integer expressions [-Werror=sign-compare]
for (int i = 0; i < numRounds; i++) {
^
src/sig_picnic/external/Picnic-master/preprocessMatrices.c: In function ‘generatelookupTables’:
src/sig_picnic/external/Picnic-master/preprocessMatrices.c:180:5: error: enumeration value ‘PARAMETER_SET_INVALID’ not handled in switch [-Werror=switch]
switch (picnic_params) {
^~~~~~
src/sig_picnic/external/Picnic-master/preprocessMatrices.c:180:5: error: enumeration value ‘PARAMETER_SET_MAX_INDEX’ not handled in switch [-Werror=switch]

@dstebila
Copy link
Member

Since Picnic-master is an external dependency, can we compile that directory without -Werror while the upstream provider considers whether to adopt the changes or not?

@smashra
Copy link
Contributor

smashra commented Jun 30, 2017 via email

@smashra
Copy link
Contributor

smashra commented Jul 4, 2017

I'm already getting name collision error:

./.libs/liboqs.a(libpicnic_la-LowMC.o): In function verify': /home/shravan/workspace/delete_picnic/liboqs/src/sig_picnic/external/Picnic-master/LowMC.c:1050: multiple definition of verify'
./.libs/liboqs.a(libkyber_la-kex_mlwe_kyber.o):/home/shravan/workspace/delete_picnic/liboqs/src/kex_mlwe_kyber/verify.c:10: first defined here
collect2: error: ld returned 1 exit status
make[2]: *** [Makefile:732: test_sig] Error 1

Douglas, we discussed to not enable picnic by default but why does
src/kex_mlwe_kyber/verify.c
has a global function verify() and still it has been accepted in master and enabled by default.

@dstebila
Copy link
Member

dstebila commented Jul 4, 2017

@smashra Apparently there were non-namespaced names added in the merge of Kyber (#131) and these weren't caught by Travis since Travis isn't correctly catching all failures (open issue #130). So I think the sequence of operations would be:

  1. Prepare a pull request that fixes Non-namespaced global symbols: Travis should fail even more... #130, which will mean current builds fail.
  2. Prepare a pull request that builds on the pull request in 1. and that fixes the non-namespaced symbols in Kyber.
  3. Merge both of those to master.
  4. Update this pull request.

@christianpaquin
Copy link
Contributor Author

@smashra, the last commit #6153022 removed the Picnic matrices preprocessing in the download-and-setup-picnic.sh script. How do you propose we setup Picnic after downloading it?

@smashra
Copy link
Contributor

smashra commented Jul 18, 2017 via email

@christianpaquin
Copy link
Contributor Author

OK, works for me. Is there a reason why the matrices preprocessing is not part of the make (vs. make test)? I updated the README to include "make test" as a step when building Picnic. When are you planning to merge this with master? I'm working on fixing the Windows build; if this is going in soon, I'll wait to also include the sig api and Picnic.

@smashra
Copy link
Contributor

smashra commented Jul 18, 2017 via email

@smashra
Copy link
Contributor

smashra commented Jul 18, 2017 via email

@christianpaquin
Copy link
Contributor Author

I tested the build with your commits @smashra; looks good.

@smashra
Copy link
Contributor

smashra commented Jul 18, 2017 via email

@tlepoint
Copy link
Contributor

I get a warning during compilation on macOS

  CC       src/sig_picnic/external/Picnic-master/pp_matrices-preprocessMatrices.o
src/sig_picnic/external/Picnic-master/preprocessMatrices.c:180:13: warning: enumeration values
      'PARAMETER_SET_INVALID' and 'PARAMETER_SET_MAX_INDEX' not handled in switch [-Wswitch]
    switch (picnic_params) {
            ^
1 warning generated.

@dstebila
Copy link
Member

@smashra There's still a failure in one of the macOS builds due to a header not being in the right location. Can you look into that?

@smashra
Copy link
Contributor

smashra commented Jul 25, 2017 via email

@smashra
Copy link
Contributor

smashra commented Jul 25, 2017 via email

Copy link
Member

@dstebila dstebila left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are a bunch of changes that seem unrelated to Picnic, and I think might be artifacts of merges with master. Shravan, can you please check to see what the code actually should be, as in some cases it doesn't reflect what's in master now?

configure.ac Outdated
ARG_ENABL_SET([kex-sidh-iqc-ref], [enable KEX-SIDH-IQC-REF.])
AM_CONDITIONAL([kex_sidh_iqc_ref], [test "x$kex_sidh_iqc_ref" = xtrue])
AM_CONDITIONAL([USE_SIDH_IQC], [test "x$kex_sidh_iqc_ref" = xtrue])


AM_CPPFLAGS="-g -std=gnu11 -Wno-unused-function -Werror -Wpedantic -Wall -Wextra -DCONSTANT_TIME"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this line changing?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a duplicate, there is another AM_CPPFLAGS below. Needs to be removed. Merge artifact.

configure.ac Outdated
@@ -120,6 +126,35 @@ case $host_os in
;;
esac

AC_ARG_WITH(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are lines 129-149 changing? Doesn't seem related to the Picnic commit.

configure.ac Outdated
@@ -129,6 +164,8 @@ SRCDIR=${SRCDIR}" src/crypto/aes src/crypto/rand src/crypto/sha3 src/crypto/rand

# KEX
SRCDIR=${SRCDIR}" src/kex"
SRCDIR=" src/common src/crypto/aes src/kex src/sig src/crypto/rand src/crypto/sha3"
SRCDIR=${SRCDIR}" src/crypto/rand_urandom_aesctr src/crypto/rand_urandom_chacha20"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this line changing? Doesn't seem related to the Picnic commit.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again this whole block is duplicated. Merge didn't go well.

configure.ac Outdated
AM_CPPFLAGS=${AM_CPPFLAGS}" -DENABLE_NTRU"
SRCDIR=${SRCDIR}" src/kex_ntru"
fi

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are these lines changing? Doesn't seem related to the Picnic commit.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if test x"$kex_ntru" = x"true"; then
AM_CPPFLAGS=${AM_CPPFLAGS}" -DENABLE_NTRU"
SRCDIR=${SRCDIR}" src/kex_ntru"
fi

should not be there because its enabled by default.

@@ -158,6 +200,12 @@ if test x"$kex_code_mcbits" = x"true"; then
fi
if test x"$kex_sidh_iqc_ref" = x"true"; then
AM_CPPFLAGS=${AM_CPPFLAGS}" -DENABLE_SIDH_IQC_REF"
SRCDIR=${SRCDIR}" src/kex_sidh_iqc_ref"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this line changing? Doesn't seem related to the Picnic commit.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Its more like bringing the am_cppflags and srcdir under one if conditional.

#!/bin/sh
export PICNIC_PARAMS_PATH=$PWD/src/sig_picnic/external/Picnic-master/precomputed_data/
echo $PICNIC_PARAMS_PATH

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the purpose of this script? There's no explanation in the README of its role.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not using it anywhere. Because precomputed data is created by Makefile.am there is no additional setup required.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, so can we delete it?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, we can delete it.

@@ -20,7 +20,7 @@ typedef struct OQS_RAND OQS_RAND;
/**
* OQS PRNG object
*/
typedef struct OQS_RAND {
struct OQS_RAND {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this changing?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang was giving error on doing
typedef struct OQS_RAND {

}OQS_RAND;

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be

typedef struct OQS_RAND OQS_RAND;
struct OQS_RAND { ... };

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The above change already exists in rand.h.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I see, thanks.

@dstebila dstebila merged commit 4987563 into open-quantum-safe:master Aug 1, 2017
vlad-sensei pushed a commit to vlad-sensei/liboqs that referenced this pull request Aug 3, 2017
* master:
  Enable or disable each algorithm (open-quantum-safe#158)
  Add sig api with picnic (open-quantum-safe#120)
  AppVeyor badge should point to master branch.
  copy header files instead of link (open-quantum-safe#157)
  Windows continuous integration (open-quantum-safe#155)
  Bring macOS build config closer to original.
  Try a few changes to see if we can narrow down the bug.
  Switch to a different version of Xcode and set travis-tests to fail on error.
  Fix windows build july2017 (open-quantum-safe#151)
  Fix unknown pseudo-op: .global under macOS (open-quantum-safe#152)
@christianpaquin christianpaquin deleted the add-sig-api-with-picnic branch October 10, 2018 17:55
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants