林微
林微,一个年轻的博主。
展开
-
[9th of series ABE] Programming Attribute Based Encryption
Previously, from the Advanced Crypto Software Collection tool, we ran several high-level ciphertext-policy attribute-based encryption (CP-ABE) examples.This blog is going to introduce how to implement CP-ABE using a low-level Python library named Charm.Ana原创 2022-10-04 16:44:02 · 802 阅读 · 0 评论 -
[8th of series ABE] Charm
【代码】[8th of series ABE] Charm。原创 2022-10-04 16:41:27 · 589 阅读 · 0 评论 -
[7th of series ABE] CP-ABE Usage
This blog is going to make use of the CP-ABE toolkit.This part is going to create a test project.First, we create a new folder for the test project.**Second, **we run the “cpabe-setup” command to set up the public key and master keys.**Third, **we are go原创 2022-10-04 16:37:48 · 1109 阅读 · 0 评论 -
[6th of series ABE] Coding Attribute-Based Encryption
This blog is going to do code the attribute-based encryption.This part is going to install the Ciphertext-Policy Attribute-Based Encryption Toolkit.First, we go to the official website, download the source code “cpabe-0.11.tar.gz” and unzip the source code原创 2022-10-04 16:30:34 · 181 阅读 · 0 评论 -
[5th of series ABE] Generator in Cyclic Group
给定有限域GF(x, q),有限域的阶为2^q有限域中的元素分别从0到(2^q)-1有限域中GF(x, q)的生成元可能有多个。原创 2022-10-03 12:01:19 · 607 阅读 · 0 评论 -
[4th of series ABE] Finite Field Operations
This blog is going to install pyfinite in order to support finite field operations. We will also have a comparison with Python finite field operation with Matlab.First, 192.168.0.101 install pyfinite.2. Finite FieldA valid finite field satisfies the fol原创 2022-10-03 11:58:33 · 265 阅读 · 0 评论 -
[3th of series ABE] Shamir‘s Secret Sharing
This blog is going to discuss Shamir’s Secret Sharing Scheme.给定n个不同的节点,问经过所有点的最高阶的多项式函数的形式如何获得?平面上任意两个不同的点(x1, y1)和(x2, y2),能唯一地确定一个关于x的一次多项式, i.e., y=ax+b.平面上任意三个不同的点(x1, y2), (x2, y2), 和(x3, y3),能唯一地确定一个关于x的二次多项式,i.e., y=ax²+bx+c以此类推,平面上任意n个不同的点,能唯一地确定一个原创 2022-10-03 11:56:04 · 343 阅读 · 0 评论 -
[2nd of series ABE] Installation of “GoFE“ and Usage of ABE
This blog is going to install the Golang encryption library named “GoFE”.First, download and build the library by running the following command,**Second, **to make sure the library works as expected, we have a double-check,2. Usage of “GoFE”Our project原创 2022-10-03 11:50:21 · 385 阅读 · 0 评论 -
[1st of series ABE] Installation of “libopenabe-1.0.0“
This blog is going to install “libopenabe-1.0.0”.First, we download and unzip the installation package.Second, to compile OpenABE on Ubuntu Linux-based distro, first run deps/install_pkgs.sh script from the source directory to install the OpenABE system-s原创 2022-10-03 11:45:11 · 414 阅读 · 0 评论 -
2022-1-14 C++语言的虚函数实现运行时多态
例子一:Base.h#ifndef BASE_H#define BASE_Hclass Base{public: Base(); ~Base();public: void Printer_Compile_Static_Binding(); virtual void Printer_Runtime_Dynamic_Binding();};#endifBase.cpp#include <iostream>#include "Base.h"原创 2022-01-14 20:33:48 · 235 阅读 · 0 评论 -
2022-1-11 C++语言之自行实现/重载标准化STL的vector容器
例子一: 简单的C++ STL之vector的使用例子,如下,#include <iostream>#include <vector>using namespace std;int main(){ vector<int> vec_a; // push items to the vector for(int i=0; i<5; i++){ vec_a.push_back(i); }原创 2022-01-11 21:10:01 · 320 阅读 · 0 评论 -
2022-1-7 C++语言重载赋值运算符实现静态数组
C++编译器规则: C++重载的赋值运算符必须是类成员函数,不能是静态函数/非类成员函数。这意味着,赋值运算符的重载必须通过类成员函数进行,无法通过友元函数进行。例子:StaticArray.h#ifndef STATICARRAY_H#define STATICARRAY_Hclass StaticArray{private: int* pointer_of_static_array; int size_of_static_array;public: Static原创 2022-01-07 16:45:15 · 381 阅读 · 0 评论 -
2022-1-1 C++语言的结构体的两种不同初始化方式
例子一: 通常的struct初始化Library.h#ifndef LIBRARY_H#define LIBRARY_H#include <iostream>struct book{ std::string book_id; std::string book_name;};class Library{public: Library(int); ~Library();public: void AddBook(struct book);原创 2022-01-01 21:55:57 · 381 阅读 · 0 评论 -
2021-12-29 C++语言的Templates链接问题
例子一 (链接错误): C++编译规则要求模板类的声明部分和实现部分在同一个文件中可被找到。否则会抛出链接错误如下:“TemplateX.h”#ifndef TEMPLATEX_H#define TEMPLATEX_Htemplate<class T>class TemplateX{public: TemplateX(T); ~TemplateX();public: void SetX(T); T GetX();private: T X;原创 2021-12-29 15:14:42 · 634 阅读 · 0 评论 -
2021-12-25 C++语言的异常处理
例子一: 如果无法预期异常会发生但又无法保证异常不会发生,那么可以直接调用C++异常处理的父类 exception 自动进行异常的捕获和识别。#include <iostream>using namespace std; double division(int a, int b){ return a/b;} int main(){ int x = 50; int y = 0; try { cout << division(x,原创 2021-12-25 21:47:17 · 363 阅读 · 0 评论 -
2021-12-23 C++语言的父类构造函数继承及多继承
例子1: 父类构造函数的继承和多继承“BaseA.h”#ifndef BASEA_H#define BASEA_Hclass BaseA{public: BaseA(int, int); ~BaseA();protected: int val_a; int val_b;};#endif“BaseA.cpp”#include <iostream>#include "BaseA.h"BaseA::BaseA(int a_, int b_原创 2021-12-23 11:17:54 · 416 阅读 · 0 评论 -
2021-12-22 C++语言的堆内存分配回收之以单链表为例
“SingleLinkedList.h”#ifndef SINGLELINKEDLIST_H#define SINGLELINKEDLIST_Hstruct node{ int data; node* next;};class SingleLinkedList{private: node* head;public: SingleLinkedList(); ~SingleLinkedList(); void AppendNode(int);原创 2021-12-22 10:47:35 · 1495 阅读 · 0 评论 -
2021-12-17 C++语言的动态内存使用方法
C++ 动态内存分配通常指的是在堆空间中给除静态,局部变量之外的变量分配的内存。动态内存分配的语法主要是: new() 和 delete() 方法。下面我们用例子讨论C++中动态内存如何使用。例子一: 该例主要讨论C++中利用new()和delete()方法实现动态内存分配,如下,“darray.h”#ifndef DARRAY_H#define DARRAY_Hclass DArray{public: int Size; int *DArrayPointer; DA原创 2021-12-17 21:24:37 · 1010 阅读 · 0 评论 -
2021-12-14 C++语言的静态函数成员例子
例子一: 不需要通过类的实例,而是直接调用Static Member Function。“a.h”#ifndef A_H#define A_H#include <iostream>class A{public: A(); ~A(); static void Info(){ std::cout << "The static member function is called" << std::endl; }};原创 2021-12-14 20:45:46 · 889 阅读 · 0 评论 -
2021-12-10 C++语言的存储类型说明符
1. Extern关键字Extern大部分情况是缺省的关键字。但有例外情况,比如变量的声明需要Extern关键字,否则变量就被默认定义了。例子1.1: C++变量的定义“source1.cpp”#include <iostream>using namespace std;int main(){ int i; // define variable i, with default value 0 cout << i << endl;}编原创 2021-12-10 22:22:43 · 558 阅读 · 0 评论 -
2021-12-5 C++语言的静/动态编译过程
1. 编译过程代码层面,区分头文件和源文件是为了编程人员的代码规范和编程方便。对于编译器而言,头文件和源文件两者并没有差别。编译层面,编译器主要负责将编程人员的程序编译成二进制的目标代码 (object code)。在程序文件较多的情况下,编译器会将这些程序编译成多个目标代码 (object codes)。链接层面,链接器主要负责链接之前编译器生成的目标代码 (object codes),并生成一个可执行文件 (executable code)。链接的方法有两种:静态链接 (static linkin原创 2021-12-05 17:19:59 · 897 阅读 · 0 评论 -
2021-12-2 C++语言实现函数成员的封装
数据成员的封装方法通常是将数据声明为Private,然后通过类的函数成员对类的数据成员进行访问——这避免了用户直接访问类的数据成员对对象进行的潜在破坏。类似的思路,我们可以实现对C++语言中函数成员的封装,即,用户无法直接访问类的某些函数成员。1. 例子一这个例子中我们提供身份验证的功能,该功能verifyID()是由可信第三方使用的,而不是由用户使用的。同时,用户在显示信息的时候需要确保该用户ID是被验证过的。我们的类函数成员封装实现如下:people.h#ifndef PEOPLE_H#def原创 2021-12-02 20:13:48 · 545 阅读 · 0 评论 -
2021-11-28 C++语言实现数据成员的封装
1. 例子一头文件是需要交付给用户的,源文件可以以二进制的形式进行交付。如果,我们将类的数据成员错误地封装为公开属性,这不满足用户个人信息的保护,如下,People.h 文件如下:#ifndef PEOPLE_H#define PEOPLE_H#include <string>class People{public: std::string name; std::string id; int age; People(std::string, std原创 2021-11-28 18:00:17 · 168 阅读 · 0 评论 -
2021-11-23 C++语言实现运算符重载
Question1: C++如何实现输入输出运算符的重载?方法是将操作符定义为类的友元 (目的是访问类的私有变量),然后,重载父类iostream的运算符操作。如下,例子一: 重载输出运算符的例子如下,#include <iostream>using namespace std;class Point{ private: int x, y; public: Point(int, int); friend ostream &operator &原创 2021-11-23 11:54:23 · 400 阅读 · 0 评论 -
2021-11-21 C++语言实现函数重载
1. 重载(overloading)重载不关心返回值类型,因为返回值类型并不包含在函数的签名中。重载主要有以下四种情况:情况一: 参数类型不同的重载#include <iostream>using namespace std;int Func(int a, int b){ cout << "Decorated function name: " << __FUNCDNAME__ << endl; return 0;}int Func(int原创 2021-11-21 16:47:03 · 519 阅读 · 0 评论 -
2021-11-19 C++语言实现Makefile的使用
1. 源代码第一部分整个项目源代码的目录树如下,├── main.c├── mytool1.c├── mytool1.h├── mytool2.c├── mytool2.h└── (makefile)其中,main.c源代码 (依赖mytool1.h和mytool2.h两个头文件) 如下,#include "mytool1.h" #include "mytool2.h" void main(int argc, char **argv) { mytool1_print("hi")原创 2021-11-19 14:54:56 · 865 阅读 · 0 评论 -
2021-11-17 C语言实现异步
C语言异步实现的一个简单实验如下,#include <stdio.h>#include <unistd.h>#include <pthread.h>#include <time.h>void *ChildThread(){ printf("Child thread gains the resource, timestamp at %d\n", (int)time(NULL)); // Do something sleep(原创 2021-11-17 17:45:27 · 2648 阅读 · 1 评论 -
2021-11-15 C语言实现同步
这里是线程同步原创 2021-11-15 15:17:57 · 1020 阅读 · 0 评论 -
2021-11-12 C语言实现泛型 (即面向对象泛型)
C语言实现泛型主要有两种方式:其一是void类型的指针,其二是宏。**例子一: ** void类型的指针可以指向任何数据类型的指针,而非void类型的指针则不行。#include <stdio.h>int main(){ // variables int a = 1; double b = 1.2; // pointers void *void_p; int *int_p; // integer pointer pointing原创 2021-11-12 17:23:29 · 702 阅读 · 0 评论 -
2021-11-8 C语言实现继承 (即面向对象继承)
继承只需要把目标头文件包含进来即可,我们关心的是:子类能从父类继承哪些成员?哪些成员不能被继承?为什么能继承这些成员?为什么不能继承另一些成员?例子一: 子类无法继承父类的私有成员。换句话说,如果父类的结构体的定义部分放在main函数不能直接访问的源文件,即父类的数据成员私有化,那么子类将无法继承该父类的私有结构体。因为该结构体被封装(参考之前博客C封装性),导致编译器无法访问该结构体,因而无法给该结构体分配多少内存空间以及初始化。shape.h#ifndef SHAPE_H#define SHAP原创 2021-11-08 21:57:11 · 870 阅读 · 0 评论 -
2021-11-5 C语言实现函数的封装 (即面向对象的函数成员封装)
C语言的函数默认缺省extern关键字,即默认情况下只要其他文件包含当前头文件,就能使用该头文件的函数——因为默认的extern关键字将该函数的可见程度拓宽到整个程序的所有文件,而不仅仅是当前文件。C语言可以使用static关键字限制函数仅仅在其所在文件中全局可视,而当前文件之外的其他文件 (比如main函数) 对该函数不可见,从而实现C语言对函数成员的封装。例子一 (没有采用关键字则默认采用extern关键字): 如果C函数没有使用其他的关键字,则该函数默认采用extern关键字,即该函数在整个程序的原创 2021-11-05 17:10:02 · 481 阅读 · 0 评论 -
2021-11-3 C语言实现数据的封装 (即面向对象的数据成员封装)
C语言中函数和数据在编译层面默认都是Public,但是我们可以通过利用C编译器的基本编译规则,实现C编译器对数据成员的封装 (即面向对象的数据成员封装)。基本的原理是:把数据结构的声明部分让main函数可见,然后把数据结构的定义部分让main函数不可见(即定义部分放到main函数之外的其他源文件中)。例子一 (变量的定义部分放在main函数能直接访问的头文件/源文件,无法实现数据的封装): 举例而言,如果将结构体变量的声明和定义都放在main函数能直接访问的头文件/源文件,那么该结构体的内部数据成员是ma原创 2021-11-03 11:53:56 · 496 阅读 · 0 评论 -
2021-10-30 C语言通过函数指针实现动态绑定 (即面向对象的多态)
动态绑定通常和面向对象概念绑在一起。在面向对象编程中,动态绑定指的是通过父类指针调用子类实现的函数。这意味着,动态绑定实现了面向对象的多态性。但是,动态绑定也可以和面向过程概念绑在一起。本文,我们用标准C语言的函数指针,实现动态绑定,如下:#include <stdio.h>typedef double (*function_pointer)(double, double);double add(double a, double b){ return a+b;}doub原创 2021-10-30 16:08:40 · 386 阅读 · 0 评论 -
2021-10-27 C语言的ADT实现Set集合操作
1. 集合集合是一个数学概念,通常被定义为一个或多个确定元素所组成的一个整体。下列例子都是未经排序的集合,其时间复杂度都是O(n^2)。更优的操作是对集合进行排序,其时间复杂度是O(nlogn)。例子1该例使用int基本数据类型实现集合的定义及相关操作。具体地,集合的定义采用全局array数组实现;集合的相关操作包括集合交,集合并的操作,这些操作均采用c语言直接操作全局array数组实现。#include <stdio.h>int A_[20];int B_[20];// X:原创 2021-10-27 16:49:03 · 593 阅读 · 0 评论 -
2021-10-24 C语言的抽象数据类型ADT(二)
C语言抽象数据类型ADT的定义和实现例子:一个简单的C语言抽象数据类型ADT的定义和实现如下,#include <stdio.h>#include <math.h>typedef struct { double a; double b; double c;} Triangle;double Triangle_Perimeter(const Triangle *tri) { return tri->a + tri->b + t原创 2021-10-24 18:50:34 · 1915 阅读 · 0 评论 -
2021-10-21 C语言assert宏
1. assertAssert作为宏定义,其作用是用于测试条件是否成立。如果条件成立,程序正常执行;如果条件不成立,不同于if语句,assert会向stderr打印错误信息并调用abort导致程序终止。这意味着,assert主要用于程序调试,程序一旦发生错误就会立即结束退出,而不是将错误的返回值继续执行下去。例子1: 在debug模式下,我们写一个读文件的程序如下。我们尝试通过assert找出程序的潜在错误。#include <stdio.h>#include <assert.h&原创 2021-10-21 21:00:35 · 146 阅读 · 0 评论 -
2021-10-18 C语言增大原指针的内存空间
1. malloc(n)函数ANSI C语言的 malloc() 函数目的是向系统申请n字节的堆空间,使用方法如下,#include <stdio.h>#include <stdlib.h>int main(){ int *p = (int *)malloc(sizeof(int)*10); for(int i=0; i<10; i++){ p[i]=i; } for(int i=0; i<10; i+原创 2021-10-18 21:46:50 · 139 阅读 · 0 评论 -
2021-10-15 C语言的抽象数据类型ADT
C语言的基本数据包括有char, int, float, double等,下列程序显示如何使用这些数据类型,#include <stdio.h>int main(){ char c1 = 'a'; printf("The value of c1 is: %c\n", c1); // printf a char int c2 = 1; printf("The value of c2 is: %d\n", c2); // printf an int原创 2021-10-16 21:01:00 · 241 阅读 · 0 评论 -
多线程多进程编程 --【2/4】麦克劳林展开的例子
1. 问题描述给定 sin(x)sin(x)sin(x) 函数的 nnn 阶麦克劳林展开公式如下,sin(x)=x−x33!+x55!−x77!+⋯+(−1)n⋅x2n+1(2n+1)!=∑i=0nx2i+1(2i+1)!sin(x)=x - \frac{x^{3}}{3!} + \frac{x^{5}}{5!} - \frac{x^{7}}{7!} + \cdots + (-1)^n \cd...原创 2019-03-07 15:35:40 · 514 阅读 · 0 评论 -
多线程多进程编程 --【1/4】关于Win7下Java之JDK的安装配置,编译执行测试
1. JDK8 (包含JRE) 下载和安装Step1: 下载JDK本文64位Win7操作系统,下载jdk-8u201-windows-x64.exe。JDK的官方下载地址:https://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html, 如下,注:32位操作系统选择x86,64位操作系...原创 2019-02-19 23:05:12 · 281 阅读 · 0 评论