首页 > 其他分享 >BIKE test

BIKE test

时间:2024-05-10 15:57:43浏览次数:8  
标签:start duration raw MSG BIKE key test dec

/******************************************************************************

  • BIKE -- Bit Flipping Key Encapsulation
  • Copyright (c) 2017 Nir Drucker, Shay Gueron, Rafael Misoczki
  • ([email protected], [email protected], [email protected])
  • Permission to use this code for BIKE is granted.
  • Redistribution and use in source and binary forms, with or without
  • modification, are permitted provided that the following conditions are met:
    • Redistributions of source code must retain the above copyright notice,
  • this list of conditions and the following disclaimer.
    • Redistributions in binary form must reproduce the above copyright
  • notice, this list of conditions and the following disclaimer in the
  • documentation and/or other materials provided with the distribution.
    • The names of the contributors may not be used to endorse or promote
  • products derived from this software without specific prior written
  • permission.
  • THIS SOFTWARE IS PROVIDED BY THE AUTHORS ""AS IS"" AND ANY
  • EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  • IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  • PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS CORPORATION OR
  • CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
  • EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  • PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  • PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  • LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  • NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  • SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    ******************************************************************************/

include "stdio.h"

include "kem.h"

include "utilities.h"

include "measurements.h"

include <time.h>

////////////////////////////////////////////////////////////////
// Main function for testing
////////////////////////////////////////////////////////////////
int main(void)
{
sk_t sk = {0}; // private-key: (h0, h1)
pk_t pk = {0}; // public-key: (g0, g1)
ct_t ct = {0}; // ciphertext: (c0, c1)
ss_t k_enc = {0}; // shared secret after encapsulate
ss_t k_dec = {0}; // shared secret after decapsulate

clock_t start,end,start_2,start_3,end_2,end_3;
double duration,duration_2,duration_3;
uint32_t mismatch_count = 0; // 初始化密钥不匹配计数为0
uint32_t total_operations = NUM_OF_ENCRYPTION_TESTS * NUM_OF_CODE_TESTS; // 总封装解封装次数

MSG("BIKE Demo Test:\n");

for (uint32_t i=1; i <= NUM_OF_CODE_TESTS; ++i)
{
    status_t res = SUCCESS;

    MSG("r: %d Code test: %d \n", (int) R_BITS, i);

start=clock();

   //Key generation.
    MEASURE("  keygen", res = static_cast<status_t>(crypto_kem_keypair(pk.raw, sk.raw)););

end = clock();
duration = (double)(end-start) / CLOCKS_PER_SEC;
MSG("%f seconds\n" , duration);
if(res != SUCCESS)
{
MSG("Keypair failed with error: %d\n", res);
continue;
}

    for (uint32_t j=1; j <= NUM_OF_ENCRYPTION_TESTS; ++j)
    {
    //    MSG("Enc/Dec test: %d\n", j);
        uint32_t dec_rc = 0;

start_2 = clock();
//Encapsulate
MEASURE(" encaps", res = static_cast<status_t>(crypto_kem_enc(ct.raw, k_enc.raw, pk.raw))

标签:start,duration,raw,MSG,BIKE,key,test,dec
From: https://www.cnblogs.com/1314liyang/p/18184529

相关文章

  • BIKE decode.c
    /******************************************************************************BIKE--BitFlippingKeyEncapsulationCopyright(c)2021NirDrucker,ShayGueron,RafaelMisoczki,TobiasOder,TimGueneysu,JanRichter-Brockmann.Contact:drucker.nir@g......
  • BIKE def.h
    /******************************************************************************BIKE--BitFlippingKeyEncapsulationCopyright(c)2021NirDrucker,ShayGueron,RafaelMisoczki,TobiasOder,TimGueneysu,JanRichter-Brockmann.Contact:drucker.nir@g......
  • BIKE decode.h
    /******************************************************************************BIKE--BitFlippingKeyEncapsulationCopyright(c)2021NirDrucker,ShayGueron,RafaelMisoczki,TobiasOder,TimGueneysu,JanRichter-Brockmann.Contact:drucker.nir@g......
  • springboot JunitTest
    junit测试参考官方文档:https://docs.spring.io/spring-boot/docs/2.0.4.RELEASE/reference/html/boot-features-testing.html1.对springboot框架的项目进行测试,需要引入测试包<dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boo......
  • AtCoder Beginner Contest 318 Ex Count Strong Test Cases
    洛谷传送门AtCoder传送门首先做一些初步的观察:A和B的解法是对称的,所以A对的方案数等于B对的方案数。同时若A和B同时对则每个置换环环长为\(1\),方案数为\(n!\)。所以,若设A对的方案数为\(x\),那么答案为\(n!^2-(x-n!)-(x-n!)-n!=n!^2+n!-x\)。......
  • 2022 Benelux Algorithm Programming Contest (BAPC 22) A 、I、J、L
    A.AdjustedAverage(暴力枚举+二分查找)分析读完题目可以发现k很小,那么考虑暴力做法的时间复杂度为\(O(C_n^k)\),对于\(k\leq3\)的其实可以直接暴力创过去,但对于\(k=4\)的情况显然不适用。那么对应\(k=4\)的情况考虑优化,可以选择将数分为两个集合,先用一个set存下其中一个集合的所......
  • ZGRPC - A Unit Test Failure
     functestUpdateTasksUnavailableDb(t*testing.T){//Arrangeconn,c:=newClient(t)deferconn.Close()newDb:=NewFakeDb(IsAvailable(false))*fakeDb=*newDb//ClearallthefieldsinfakeDb.d.tasksexceptId.requests......
  • TestMarkdown
    VSCode实时预览还需要执行Markdown:OpenPreviewtotheSide命令来实现。在命令窗口输入Markdown:OpenPreviewtotheSide命令---#一级标题##二级标题###三级标题####四级标题#####五级标题######六级标题====创建脚注格式类似这样[^RUNOOB]。......
  • TestMarkdown1
    VSCode实时预览还需要执行Markdown:OpenPreviewtotheSide命令来实现。在命令窗口输入Markdown:OpenPreviewtotheSide命令一级标题二级标题三级标题四级标题五级标题六级标题====创建脚注格式类似这样[^RUNOOB]。斜体文本斜体文本粗体文本粗体文本......
  • pytest + yaml 框架 -69.新增depend 关键字,导入其它yaml用例
    前言有小伙伴提到,test_a.yml中已经写了几个流程,test_b.yml中希望能接着test_a.yml去写用例,于是就需要先导入test_a.yml用例。为了满足此需求,v1.6.3版本在config中新增depend关键字。需求场景test_a.yml中已经写了一些用例config:variables:x:helloy:wo......