aboutsummaryrefslogtreecommitdiffstats
path: root/ffi/cs/readme.md
blob: 456dc0cec15e6bed630e0b01e19884ebc7ec5985 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
# C# binding of BLS threshold signature library

# Installation Requirements

* Visual Studio 2017 or later
* C# 7.2 or later
* .NET Framework 4.5.2 or later

# How to build

```
md work
cd work
git clone https://github.com/herumi/cybozulib_ext
git clone https://github.com/herumi/mcl
git clone https://github.com/herumi/bls
cd bls
mklib dll
```

# How to build a sample

Open bls/ffi/cs/bls.sln and exec it.

* Remark. bls256 is obsolete. Please use bls.sln.

# class and API

## API

* `Init(int curveType = BN254);`
    * initialize this library with a curve `curveType`.
    * curveType = BN254 or BLS12_381
* `SecretKey ShareSecretKey(in SecretKey[] msk, in Id id);`
    * generate the shared secret key from a sequence of master secret keys msk and Id.
* `SecretKey RecoverSecretKey(in SecretKey[] secVec, in Id[] idVec);`
    * recover the secret key from a sequence of secret keys secVec and idVec.
* `PublicKey SharePublicKey(in PublicKey[] mpk, in Id id);`
    * generate the shared public key from a sequence of master public keys mpk and Id.
* `PublicKey RecoverPublicKey(in PublicKey[] pubVec, in Id[] idVec);`
    * recover the public key from a sequence of public keys pubVec and idVec.
* `Signature RecoverSign(in Signature[] sigVec, in Id[] idVec);`
    * recover the signature from a sequence of signatures siVec and idVec.

## Id

Identifier class

* `byte[] Serialize();`
    * serialize Id
* `void Deserialize(byte[] buf);`
    * deserialize from byte[] buf
* `bool IsEqual(in Id rhs);`
    * equality
* `void SetDecStr(string s);`
    * set by a decimal string s
* `void SetHexStr(string s);`
    * set by a hexadecimal string s
* `void SetInt(int x);`
    * set an integer x
* `string GetDecStr();`
    * get a decimal string
* `string GetHexStr();`
    * get a hexadecimal string

## SecretKey

* `byte[] Serialize();`
    * serialize SecretKey
* `void Deserialize(byte[] buf);`
    * deserialize from byte[] buf
* `bool IsEqual(in SecretKey rhs);`
    * equality
* `string GetDecStr();`
    * get a decimal string
* `string GetHexStr();`
    * get a hexadecimal string
* `void Add(in SecretKey rhs);`
    * add a secret key rhs
* `void SetByCSPRNG();`
    * set a secret key by cryptographically secure pseudo random number generator
* `void SetHashOf(string s);`
    * set a secret key by a hash of string s
* `PublicKey GetPublicKey();`
    * get the corresponding public key to a secret key
* `Signature Sign(string m);`
    * sign a string m
* `Signature GetPop();`
    * get a PoP (Proof Of Posession) for a secret key

## PublicKey

* `byte[] Serialize();`
    * serialize PublicKey
* `void Deserialize(byte[] buf);`
    * deserialize from byte[] buf
* `bool IsEqual(in PublicKey rhs);`
    * equality
* `void Add(in PublicKey rhs);`
    * add a public key rhs
* `string GetDecStr();`
    * get a decimal string
* `string GetHexStr();`
    * get a hexadecimal string
* `bool Verify(in Signature sig, string m);`
    * verify the validness of the sig with m
* `bool VerifyPop(in Signature pop);`
    * verify the validness of PoP

## Signature

* `byte[] Serialize();`
    * serialize Signature
* `void Deserialize(byte[] buf);`
    * deserialize from byte[] buf
* `bool IsEqual(in Signature rhs);`
    * equality
* `void Add(in Signature rhs);`
    * add a signature key rhs
* `string GetDecStr();`
    * get a decimal string
* `string GetHexStr();`
    * get a hexadecimal string

# License

modified new BSD License
http://opensource.org/licenses/BSD-3-Clause

# Author

MITSUNARI Shigeo(herumi@nifty.com)