weixin_39884412
2020-12-09 05:05 阅读 1

Add AVX2 implementations of NTRU

Adds the AVX2 implementations of ntruhps{2048509, 2048677, 4096821} and ntruhrss701 which are in SUPERCOP.

The ntruhps* implementations (and, eventually, NTRU Prime) would benefit from an AVX2 implementation of crypto_sort, but this probably shouldn't be duplicated across implementations. I'll look into putting some crypto_sort implementations into PQClean/common.

该提问来源于开源项目:PQClean/PQClean

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享

6条回答 默认 最新

  • weixin_39884412 weixin_39884412 2020-12-09 05:05

    The AVX2 implementation of NTRU declares its polynomial type with __attribute__((aligned(32))) and uses vmovdqa instructions. This is failing in test_char.py because pycparser chokes on the __attribute__.

    One solution: define __attribute__(x) away in test_char.py, e.g. cpp_args=[ '-D__attribute__(x)=', '-E', ... ]

    That said, I don't see any other uses of __attribute__ in the code. So maybe there is an alternative way to enforce alignment?

    点赞 评论 复制链接分享
  • weixin_39831503 weixin_39831503 2020-12-09 05:05

    __attribute__ is not portable. The "correct" way to enfore alignment is to create a union with a correctly aligned type. This can have the upside that your casts become more clear, but it definitely is a bit of work.

    For an example, see https://github.com/PQClean/PQClean/blob/4ea4b478baa436465fbf890e385f46d432d9a337/crypto_sign/dilithium2/avx2/alignment.h

    点赞 评论 复制链接分享
  • weixin_39884412 weixin_39884412 2020-12-09 05:05

    Thanks, Thom. That did the trick.

    点赞 评论 复制链接分享
  • weixin_39808893 weixin_39808893 2020-12-09 05:05

    Need to delete ntruhps2048509/avx2/.Makefile.swp.

    点赞 评论 复制链接分享
  • weixin_39808893 weixin_39808893 2020-12-09 05:05

    Are any of the files the same, or meant to be the same (modulo namespacing), as files in the clean versions, or across the avx2 implementations of the different variants? We have the duplicate consistency mechanism which can be used to track that and diffs the intended-same files to ease code review.

    点赞 评论 复制链接分享
  • weixin_39884412 weixin_39884412 2020-12-09 05:05

    There were some upstream changes to the NTRU code. No point in reviewing this PR, so I'm going to close and resubmit.

    点赞 评论 复制链接分享

相关推荐