aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/github.com/byzantine-lab/bls/ffi
diff options
context:
space:
mode:
authorWei-Ning Huang <w@byzantine-lab.io>2019-06-23 15:39:23 +0800
committerWei-Ning Huang <w@byzantine-lab.io>2019-09-17 16:57:30 +0800
commite6f5201b178f40b516ffe7b98757df25f8aee028 (patch)
tree982d6281ac9670d0ad451ca6bbd0677488b52344 /vendor/github.com/byzantine-lab/bls/ffi
parentf6e06ac35033f9e52b6b2e3ebfe623c23a39c338 (diff)
downloadgo-tangerine-e6f5201b178f40b516ffe7b98757df25f8aee028.tar
go-tangerine-e6f5201b178f40b516ffe7b98757df25f8aee028.tar.gz
go-tangerine-e6f5201b178f40b516ffe7b98757df25f8aee028.tar.bz2
go-tangerine-e6f5201b178f40b516ffe7b98757df25f8aee028.tar.lz
go-tangerine-e6f5201b178f40b516ffe7b98757df25f8aee028.tar.xz
go-tangerine-e6f5201b178f40b516ffe7b98757df25f8aee028.tar.zst
go-tangerine-e6f5201b178f40b516ffe7b98757df25f8aee028.zip
import: switch consensus core to gitlab.com/tangerine-network/tangerine-consensus
Diffstat (limited to 'vendor/github.com/byzantine-lab/bls/ffi')
-rw-r--r--vendor/github.com/byzantine-lab/bls/ffi/cs/App.config6
-rw-r--r--vendor/github.com/byzantine-lab/bls/ffi/cs/Properties/AssemblyInfo.cs36
-rw-r--r--vendor/github.com/byzantine-lab/bls/ffi/cs/bls.cs351
-rw-r--r--vendor/github.com/byzantine-lab/bls/ffi/cs/bls.csproj97
-rw-r--r--vendor/github.com/byzantine-lab/bls/ffi/cs/bls.sln25
-rw-r--r--vendor/github.com/byzantine-lab/bls/ffi/cs/bls256.cs298
-rw-r--r--vendor/github.com/byzantine-lab/bls/ffi/cs/bls256.csproj62
-rw-r--r--vendor/github.com/byzantine-lab/bls/ffi/cs/bls256.sln22
-rw-r--r--vendor/github.com/byzantine-lab/bls/ffi/cs/bls256_test.cs126
-rw-r--r--vendor/github.com/byzantine-lab/bls/ffi/cs/bls_test.cs176
-rw-r--r--vendor/github.com/byzantine-lab/bls/ffi/cs/readme-ja.md188
-rw-r--r--vendor/github.com/byzantine-lab/bls/ffi/cs/readme.md185
-rw-r--r--vendor/github.com/byzantine-lab/bls/ffi/go/bls/bls.go539
-rw-r--r--vendor/github.com/byzantine-lab/bls/ffi/go/bls/callback.go12
-rw-r--r--vendor/github.com/byzantine-lab/bls/ffi/go/bls/dummy.cpp3
-rw-r--r--vendor/github.com/byzantine-lab/bls/ffi/go/bls/mcl.go646
16 files changed, 0 insertions, 2772 deletions
diff --git a/vendor/github.com/byzantine-lab/bls/ffi/cs/App.config b/vendor/github.com/byzantine-lab/bls/ffi/cs/App.config
deleted file mode 100644
index 8d234373a..000000000
--- a/vendor/github.com/byzantine-lab/bls/ffi/cs/App.config
+++ /dev/null
@@ -1,6 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<configuration>
- <startup>
- <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.2"/>
- </startup>
-</configuration>
diff --git a/vendor/github.com/byzantine-lab/bls/ffi/cs/Properties/AssemblyInfo.cs b/vendor/github.com/byzantine-lab/bls/ffi/cs/Properties/AssemblyInfo.cs
deleted file mode 100644
index 201222c55..000000000
--- a/vendor/github.com/byzantine-lab/bls/ffi/cs/Properties/AssemblyInfo.cs
+++ /dev/null
@@ -1,36 +0,0 @@
-using System.Reflection;
-using System.Runtime.CompilerServices;
-using System.Runtime.InteropServices;
-
-// アセンブリに関する一般情報は以下の属性セットをとおして制御されます。
-// アセンブリに関連付けられている情報を変更するには、
-// これらの属性値を変更してください。
-[assembly: AssemblyTitle("bls256")]
-[assembly: AssemblyDescription("")]
-[assembly: AssemblyConfiguration("")]
-[assembly: AssemblyCompany("")]
-[assembly: AssemblyProduct("bls256")]
-[assembly: AssemblyCopyright("Copyright © 2017")]
-[assembly: AssemblyTrademark("")]
-[assembly: AssemblyCulture("")]
-
-// ComVisible を false に設定すると、その型はこのアセンブリ内で COM コンポーネントから
-// 参照不可能になります。COM からこのアセンブリ内の型にアクセスする場合は、
-// その型の ComVisible 属性を true に設定してください。
-[assembly: ComVisible(false)]
-
-// このプロジェクトが COM に公開される場合、次の GUID が typelib の ID になります
-[assembly: Guid("e9d06b1b-ea22-4ef4-ba4b-422f7625966c")]
-
-// アセンブリのバージョン情報は次の 4 つの値で構成されています:
-//
-// メジャー バージョン
-// マイナー バージョン
-// ビルド番号
-// Revision
-//
-// すべての値を指定するか、下のように '*' を使ってビルドおよびリビジョン番号を
-// 既定値にすることができます:
-// [assembly: AssemblyVersion("1.0.*")]
-[assembly: AssemblyVersion("1.0.0.0")]
-[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/vendor/github.com/byzantine-lab/bls/ffi/cs/bls.cs b/vendor/github.com/byzantine-lab/bls/ffi/cs/bls.cs
deleted file mode 100644
index 6bcaf07fb..000000000
--- a/vendor/github.com/byzantine-lab/bls/ffi/cs/bls.cs
+++ /dev/null
@@ -1,351 +0,0 @@
-using System;
-using System.Text;
-using System.Runtime.InteropServices;
-
-namespace mcl
-{
- class BLS
- {
- public const int BN254 = 0;
- public const int BLS12_381 = 5;
-
- const int IoEcComp = 512; // fixed byte representation
- public const int FR_UNIT_SIZE = 4;
- public const int FP_UNIT_SIZE = 6; // 4 if bls256.dll is used
- public const int COMPILED_TIME_VAR = FR_UNIT_SIZE * 10 + FP_UNIT_SIZE;
-
- public const int ID_UNIT_SIZE = FR_UNIT_SIZE;
- public const int SECRETKEY_UNIT_SIZE = FR_UNIT_SIZE;
- public const int PUBLICKEY_UNIT_SIZE = FP_UNIT_SIZE * 3 * 2;
- public const int SIGNATURE_UNIT_SIZE = FP_UNIT_SIZE * 3;
-
- public const int ID_SERIALIZE_SIZE = FR_UNIT_SIZE * 8;
- public const int SECRETKEY_SERIALIZE_SIZE = FR_UNIT_SIZE * 8;
- public const int PUBLICKEY_SERIALIZE_SIZE = FP_UNIT_SIZE * 8 * 2;
- public const int SIGNATURE_SERIALIZE_SIZE = FP_UNIT_SIZE * 8;
-
- public const string dllName = FP_UNIT_SIZE == 4 ? "bls256.dll" : "bls384_256.dll";
- [DllImport(dllName)]
- public static extern int blsInit(int curveType, int compiledTimeVar);
-
- [DllImport(dllName)] public static extern void blsIdSetInt(ref Id id, int x);
- [DllImport(dllName)] public static extern int blsIdSetDecStr(ref Id id, [In][MarshalAs(UnmanagedType.LPStr)] string buf, ulong bufSize);
- [DllImport(dllName)] public static extern int blsIdSetHexStr(ref Id id, [In][MarshalAs(UnmanagedType.LPStr)] string buf, ulong bufSize);
- [DllImport(dllName)] public static extern ulong blsIdGetDecStr([Out]StringBuilder buf, ulong maxBufSize, in Id id);
- [DllImport(dllName)] public static extern ulong blsIdGetHexStr([Out]StringBuilder buf, ulong maxBufSize, in Id id);
-
- [DllImport(dllName)] public static extern ulong blsIdSerialize([Out]byte[] buf, ulong maxBufSize, in Id id);
- [DllImport(dllName)] public static extern ulong blsSecretKeySerialize([Out]byte[] buf, ulong maxBufSize, in SecretKey sec);
- [DllImport(dllName)] public static extern ulong blsPublicKeySerialize([Out]byte[] buf, ulong maxBufSize, in PublicKey pub);
- [DllImport(dllName)] public static extern ulong blsSignatureSerialize([Out]byte[] buf, ulong maxBufSize, in Signature sig);
- [DllImport(dllName)] public static extern ulong blsIdDeserialize(ref Id id, [In]byte[] buf, ulong bufSize);
- [DllImport(dllName)] public static extern ulong blsSecretKeyDeserialize(ref SecretKey sec, [In]byte[] buf, ulong bufSize);
- [DllImport(dllName)] public static extern ulong blsPublicKeyDeserialize(ref PublicKey pub, [In]byte[] buf, ulong bufSize);
- [DllImport(dllName)] public static extern ulong blsSignatureDeserialize(ref Signature sig, [In]byte[] buf, ulong bufSize);
-
- [DllImport(dllName)] public static extern int blsIdIsEqual(in Id lhs, in Id rhs);
- [DllImport(dllName)] public static extern int blsSecretKeyIsEqual(in SecretKey lhs, in SecretKey rhs);
- [DllImport(dllName)] public static extern int blsPublicKeyIsEqual(in PublicKey lhs, in PublicKey rhs);
- [DllImport(dllName)] public static extern int blsSignatureIsEqual(in Signature lhs, in Signature rhs);
- // add
- [DllImport(dllName)] public static extern void blsSecretKeyAdd(ref SecretKey sec, in SecretKey rhs);
- [DllImport(dllName)] public static extern void blsPublicKeyAdd(ref PublicKey pub, in PublicKey rhs);
- [DllImport(dllName)] public static extern void blsSignatureAdd(ref Signature sig, in Signature rhs);
- // hash buf and set
- [DllImport(dllName)] public static extern int blsHashToSecretKey(ref SecretKey sec, [In][MarshalAs(UnmanagedType.LPStr)] string buf, ulong bufSize);
- /*
- set secretKey if system has /dev/urandom or CryptGenRandom
- return 0 if success else -1
- */
- [DllImport(dllName)] public static extern int blsSecretKeySetByCSPRNG(ref SecretKey sec);
-
- [DllImport(dllName)] public static extern void blsGetPublicKey(ref PublicKey pub, in SecretKey sec);
- [DllImport(dllName)] public static extern void blsGetPop(ref Signature sig, in SecretKey sec);
-
- // return 0 if success
- [DllImport(dllName)] public static extern int blsSecretKeyShare(ref SecretKey sec, in SecretKey msk, ulong k, in Id id);
- [DllImport(dllName)] public static extern int blsPublicKeyShare(ref PublicKey pub, in PublicKey mpk, ulong k, in Id id);
-
-
- [DllImport(dllName)] public static extern int blsSecretKeyRecover(ref SecretKey sec, in SecretKey secVec, in Id idVec, ulong n);
- [DllImport(dllName)] public static extern int blsPublicKeyRecover(ref PublicKey pub, in PublicKey pubVec, in Id idVec, ulong n);
- [DllImport(dllName)] public static extern int blsSignatureRecover(ref Signature sig, in Signature sigVec, in Id idVec, ulong n);
-
- [DllImport(dllName)] public static extern void blsSign(ref Signature sig, in SecretKey sec, [In][MarshalAs(UnmanagedType.LPStr)] string m, ulong size);
-
- // return 1 if valid
- [DllImport(dllName)] public static extern int blsVerify(in Signature sig, in PublicKey pub, [In][MarshalAs(UnmanagedType.LPStr)] string m, ulong size);
- [DllImport(dllName)] public static extern int blsVerifyPop(in Signature sig, in PublicKey pub);
-
- //////////////////////////////////////////////////////////////////////////
- // the following apis will be removed
-
- // mask buf with (1 << (bitLen(r) - 1)) - 1 if buf >= r
- [DllImport(dllName)] public static extern int blsIdSetLittleEndian(ref Id id, [In][MarshalAs(UnmanagedType.LPStr)] string buf, ulong bufSize);
- /*
- return written byte size if success else 0
- */
- [DllImport(dllName)] public static extern ulong blsIdGetLittleEndian([Out]StringBuilder buf, ulong maxBufSize, in Id id);
-
- // return 0 if success
- // mask buf with (1 << (bitLen(r) - 1)) - 1 if buf >= r
- [DllImport(dllName)] public static extern int blsSecretKeySetLittleEndian(ref SecretKey sec, [In]byte[] buf, ulong bufSize);
- [DllImport(dllName)] public static extern int blsSecretKeySetDecStr(ref SecretKey sec, [In][MarshalAs(UnmanagedType.LPStr)] string buf, ulong bufSize);
- [DllImport(dllName)] public static extern int blsSecretKeySetHexStr(ref SecretKey sec, [In][MarshalAs(UnmanagedType.LPStr)] string buf, ulong bufSize);
- /*
- return written byte size if success else 0
- */
- [DllImport(dllName)] public static extern ulong blsSecretKeyGetLittleEndian([Out]byte[] buf, ulong maxBufSize, in SecretKey sec);
- /*
- return strlen(buf) if success else 0
- buf is '\0' terminated
- */
- [DllImport(dllName)] public static extern ulong blsSecretKeyGetDecStr([Out]StringBuilder buf, ulong maxBufSize, in SecretKey sec);
- [DllImport(dllName)] public static extern ulong blsSecretKeyGetHexStr([Out]StringBuilder buf, ulong maxBufSize, in SecretKey sec);
- [DllImport(dllName)] public static extern int blsPublicKeySetHexStr(ref PublicKey pub, [In][MarshalAs(UnmanagedType.LPStr)] string buf, ulong bufSize);
- [DllImport(dllName)] public static extern ulong blsPublicKeyGetHexStr([Out]StringBuilder buf, ulong maxBufSize, in PublicKey pub);
- [DllImport(dllName)] public static extern int blsSignatureSetHexStr(ref Signature sig, [In][MarshalAs(UnmanagedType.LPStr)] string buf, ulong bufSize);
- [DllImport(dllName)] public static extern ulong blsSignatureGetHexStr([Out]StringBuilder buf, ulong maxBufSize, in Signature sig);
-
- public static void Init(int curveType = BN254) {
- if (!System.Environment.Is64BitProcess) {
- throw new PlatformNotSupportedException("not 64-bit system");
- }
- int err = blsInit(curveType, COMPILED_TIME_VAR);
- if (err != 0) {
- throw new ArgumentException("blsInit");
- }
- }
- [StructLayout(LayoutKind.Sequential)]
- public unsafe struct Id
- {
- private fixed ulong v[ID_UNIT_SIZE];
- public byte[] Serialize() {
- byte[] buf = new byte[ID_SERIALIZE_SIZE];
- ulong n = blsIdSerialize(buf, (ulong)buf.Length, this);
- if (n == 0) {
- throw new ArithmeticException("blsIdSerialize");
- }
- return buf;
- }
- public void Deserialize(byte[] buf) {
- ulong n = blsIdDeserialize(ref this, buf, (ulong)buf.Length);
- if (n == 0) {
- throw new ArithmeticException("blsIdDeserialize");
- }
- }
- public bool IsEqual(in Id rhs) {
- return blsIdIsEqual(this, rhs) != 0;
- }
- public void SetDecStr(string s) {
- if (blsIdSetDecStr(ref this, s, (ulong)s.Length) != 0) {
- throw new ArgumentException("blsIdSetDecSt:" + s);
- }
- }
- public void SetHexStr(string s) {
- if (blsIdSetHexStr(ref this, s, (ulong)s.Length) != 0) {
- throw new ArgumentException("blsIdSetHexStr:" + s);
- }
- }
- public void SetInt(int x) {
- blsIdSetInt(ref this, x);
- }
- public string GetDecStr() {
- StringBuilder sb = new StringBuilder(1024);
- ulong size = blsIdGetDecStr(sb, (ulong)sb.Capacity, this);
- if (size == 0) {
- throw new ArgumentException("blsIdGetDecStr");
- }
- return sb.ToString(0, (int)size);
- }
- public string GetHexStr() {
- StringBuilder sb = new StringBuilder(1024);
- ulong size = blsIdGetHexStr(sb, (ulong)sb.Capacity, this);
- if (size == 0) {
- throw new ArgumentException("blsIdGetHexStr");
- }
- return sb.ToString(0, (int)size);
- }
- }
- [StructLayout(LayoutKind.Sequential)]
- public unsafe struct SecretKey
- {
- private fixed ulong v[SECRETKEY_UNIT_SIZE];
- public byte[] Serialize() {
- byte[] buf = new byte[SECRETKEY_SERIALIZE_SIZE];
- ulong n = blsSecretKeySerialize(buf, (ulong)buf.Length, this);
- if (n == 0) {
- throw new ArithmeticException("blsSecretKeySerialize");
- }
- return buf;
- }
- public void Deserialize(byte[] buf) {
- ulong n = blsSecretKeyDeserialize(ref this, buf, (ulong)buf.Length);
- if (n == 0) {
- throw new ArithmeticException("blsSecretKeyDeserialize");
- }
- }
- public bool IsEqual(in SecretKey rhs) {
- return blsSecretKeyIsEqual(this, rhs) != 0;
- }
- public void SetHexStr(string s) {
- if (blsSecretKeySetHexStr(ref this, s, (ulong)s.Length) != 0) {
- throw new ArgumentException("blsSecretKeySetHexStr:" + s);
- }
- }
- public string GetHexStr() {
- StringBuilder sb = new StringBuilder(1024);
- ulong size = blsSecretKeyGetHexStr(sb, (ulong)sb.Capacity, this);
- if (size == 0) {
- throw new ArgumentException("mclBnFr_getStr");
- }
- return sb.ToString(0, (int)size);
- }
- public void Add(in SecretKey rhs) {
- blsSecretKeyAdd(ref this, rhs);
- }
- public void SetByCSPRNG() {
- blsSecretKeySetByCSPRNG(ref this);
- }
- public void SetHashOf(string s) {
- if (blsHashToSecretKey(ref this, s, (ulong)s.Length) != 0) {
- throw new ArgumentException("blsHashToSecretKey");
- }
- }
- public PublicKey GetPublicKey() {
- PublicKey pub;
- blsGetPublicKey(ref pub, this);
- return pub;
- }
- public Signature Sign(string m) {
- Signature sig;
- blsSign(ref sig, this, m, (ulong)m.Length);
- return sig;
- }
- public Signature GetPop() {
- Signature sig;
- blsGetPop(ref sig, this);
- return sig;
- }
- }
- // secretKey = sum_{i=0}^{msk.Length - 1} msk[i] * id^i
- public static SecretKey ShareSecretKey(in SecretKey[] msk, in Id id) {
- SecretKey sec;
- if (blsSecretKeyShare(ref sec, msk[0], (ulong)msk.Length, id) != 0) {
- throw new ArgumentException("GetSecretKeyForId:" + id.ToString());
- }
- return sec;
- }
- public static SecretKey RecoverSecretKey(in SecretKey[] secVec, in Id[] idVec) {
- SecretKey sec;
- if (blsSecretKeyRecover(ref sec, secVec[0], idVec[0], (ulong)secVec.Length) != 0) {
- throw new ArgumentException("Recover");
- }
- return sec;
- }
- [StructLayout(LayoutKind.Sequential)]
- public unsafe struct PublicKey
- {
- private fixed ulong v[PUBLICKEY_UNIT_SIZE];
- public byte[] Serialize() {
- byte[] buf = new byte[PUBLICKEY_SERIALIZE_SIZE];
- ulong n = blsPublicKeySerialize(buf, (ulong)buf.Length, this);
- if (n == 0) {
- throw new ArithmeticException("blsPublicKeySerialize");
- }
- return buf;
- }
- public void Deserialize(byte[] buf) {
- ulong n = blsPublicKeyDeserialize(ref this, buf, (ulong)buf.Length);
- if (n == 0) {
- throw new ArithmeticException("blsPublicKeyDeserialize");
- }
- }
- public bool IsEqual(in PublicKey rhs) {
- return blsPublicKeyIsEqual(this, rhs) != 0;
- }
- public void SetStr(string s) {
- if (blsPublicKeySetHexStr(ref this, s, (ulong)s.Length) != 0) {
- throw new ArgumentException("blsPublicKeySetStr:" + s);
- }
- }
- public string GetHexStr() {
- StringBuilder sb = new StringBuilder(1024);
- ulong size = blsPublicKeyGetHexStr(sb, (ulong)sb.Capacity, this);
- if (size == 0) {
- throw new ArgumentException("blsPublicKeyGetStr");
- }
- return sb.ToString(0, (int)size);
- }
- public void Add(in PublicKey rhs) {
- blsPublicKeyAdd(ref this, rhs);
- }
- public bool Verify(in Signature sig, string m) {
- return blsVerify(sig, this, m, (ulong)m.Length) == 1;
- }
- public bool VerifyPop(in Signature pop) {
- return blsVerifyPop(pop, this) == 1;
- }
- }
- // publicKey = sum_{i=0}^{mpk.Length - 1} mpk[i] * id^i
- public static PublicKey SharePublicKey(in PublicKey[] mpk, in Id id) {
- PublicKey pub;
- if (blsPublicKeyShare(ref pub, mpk[0], (ulong)mpk.Length, id) != 0) {
- throw new ArgumentException("GetPublicKeyForId:" + id.ToString());
- }
- return pub;
- }
- public static PublicKey RecoverPublicKey(in PublicKey[] pubVec, in Id[] idVec) {
- PublicKey pub;
- if (blsPublicKeyRecover(ref pub, pubVec[0], idVec[0], (ulong)pubVec.Length) != 0) {
- throw new ArgumentException("Recover");
- }
- return pub;
- }
- [StructLayout(LayoutKind.Sequential)]
- public unsafe struct Signature
- {
- private fixed ulong v[SIGNATURE_UNIT_SIZE];
- public byte[] Serialize() {
- byte[] buf = new byte[SIGNATURE_SERIALIZE_SIZE];
- ulong n = blsSignatureSerialize(buf, (ulong)buf.Length, this);
- if (n == 0) {
- throw new ArithmeticException("blsSignatureSerialize");
- }
- return buf;
- }
- public void Deserialize(byte[] buf) {
- ulong n = blsSignatureDeserialize(ref this, buf, (ulong)buf.Length);
- if (n == 0) {
- throw new ArithmeticException("blsSignatureDeserialize");
- }
- }
- public bool IsEqual(in Signature rhs) {
- return blsSignatureIsEqual(this, rhs) != 0;
- }
- public void SetStr(string s) {
- if (blsSignatureSetHexStr(ref this, s, (ulong)s.Length) != 0) {
- throw new ArgumentException("blsSignatureSetStr:" + s);
- }
- }
- public string GetHexStr() {
- StringBuilder sb = new StringBuilder(1024);
- ulong size = blsSignatureGetHexStr(sb, (ulong)sb.Capacity, this);
- if (size == 0) {
- throw new ArgumentException("blsSignatureGetStr");
- }
- return sb.ToString(0, (int)size);
- }
- public void Add(in Signature rhs) {
- blsSignatureAdd(ref this, rhs);
- }
- }
- public static Signature RecoverSign(in Signature[] sigVec, in Id[] idVec) {
- Signature sig;
- if (blsSignatureRecover(ref sig, sigVec[0], idVec[0], (ulong)sigVec.Length) != 0) {
- throw new ArgumentException("Recover");
- }
- return sig;
- }
- }
-}
diff --git a/vendor/github.com/byzantine-lab/bls/ffi/cs/bls.csproj b/vendor/github.com/byzantine-lab/bls/ffi/cs/bls.csproj
deleted file mode 100644
index c03afa436..000000000
--- a/vendor/github.com/byzantine-lab/bls/ffi/cs/bls.csproj
+++ /dev/null
@@ -1,97 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
- <PropertyGroup>
- <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
- <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
- <ProjectGuid>{E9D06B1B-EA22-4EF4-BA4B-422F7625966D}</ProjectGuid>
- <OutputType>Exe</OutputType>
- <AppDesignerFolder>Properties</AppDesignerFolder>
- <RootNamespace>bls</RootNamespace>
- <AssemblyName>bls</AssemblyName>
- <TargetFrameworkVersion>v4.6.2</TargetFrameworkVersion>
- <FileAlignment>512</FileAlignment>
- <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
- <PublishUrl>publish\</PublishUrl>
- <Install>true</Install>
- <InstallFrom>Disk</InstallFrom>
- <UpdateEnabled>false</UpdateEnabled>
- <UpdateMode>Foreground</UpdateMode>
- <UpdateInterval>7</UpdateInterval>
- <UpdateIntervalUnits>Days</UpdateIntervalUnits>
- <UpdatePeriodically>false</UpdatePeriodically>
- <UpdateRequired>false</UpdateRequired>
- <MapFileExtensions>true</MapFileExtensions>
- <ApplicationRevision>0</ApplicationRevision>
- <ApplicationVersion>1.0.0.%2a</ApplicationVersion>
- <IsWebBootstrapper>false</IsWebBootstrapper>
- <UseApplicationTrust>false</UseApplicationTrust>
- <BootstrapperEnabled>true</BootstrapperEnabled>
- <TargetFrameworkProfile />
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
- <DebugSymbols>true</DebugSymbols>
- <OutputPath>..\..\bin\</OutputPath>
- <DefineConstants>DEBUG;TRACE</DefineConstants>
- <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
- <DebugType>full</DebugType>
- <PlatformTarget>x64</PlatformTarget>
- <ErrorReport>prompt</ErrorReport>
- <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
- <LangVersion>7.2</LangVersion>
- <Prefer32Bit>false</Prefer32Bit>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
- <OutputPath>..\..\bin\</OutputPath>
- <DefineConstants>TRACE</DefineConstants>
- <Optimize>true</Optimize>
- <DebugType>pdbonly</DebugType>
- <PlatformTarget>x64</PlatformTarget>
- <ErrorReport>prompt</ErrorReport>
- <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
- <Prefer32Bit>false</Prefer32Bit>
- <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
- <LangVersion>7.2</LangVersion>
- </PropertyGroup>
- <PropertyGroup>
- <NoWin32Manifest>true</NoWin32Manifest>
- </PropertyGroup>
- <ItemGroup>
- <Reference Include="System" />
- <Reference Include="System.Core" />
- <Reference Include="System.Xml.Linq" />
- <Reference Include="System.Data.DataSetExtensions" />
- <Reference Include="Microsoft.CSharp" />
- <Reference Include="System.Data" />
- <Reference Include="System.Net.Http" />
- <Reference Include="System.Xml" />
- </ItemGroup>
- <ItemGroup>
- <Compile Include="bls.cs" />
- <Compile Include="bls_test.cs" />
- <Compile Include="Properties\AssemblyInfo.cs" />
- </ItemGroup>
- <ItemGroup>
- <None Include="App.config" />
- </ItemGroup>
- <ItemGroup>
- <BootstrapperPackage Include=".NETFramework,Version=v4.5.2">
- <Visible>False</Visible>
- <ProductName>Microsoft .NET Framework 4.5.2 %28x86 および x64%29</ProductName>
- <Install>true</Install>
- </BootstrapperPackage>
- <BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
- <Visible>False</Visible>
- <ProductName>.NET Framework 3.5 SP1</ProductName>
- <Install>false</Install>
- </BootstrapperPackage>
- </ItemGroup>
- <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
- <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
- Other similar extension points exist, see Microsoft.Common.targets.
- <Target Name="BeforeBuild">
- </Target>
- <Target Name="AfterBuild">
- </Target>
- -->
-</Project> \ No newline at end of file
diff --git a/vendor/github.com/byzantine-lab/bls/ffi/cs/bls.sln b/vendor/github.com/byzantine-lab/bls/ffi/cs/bls.sln
deleted file mode 100644
index 7c3dfba7b..000000000
--- a/vendor/github.com/byzantine-lab/bls/ffi/cs/bls.sln
+++ /dev/null
@@ -1,25 +0,0 @@
-
-Microsoft Visual Studio Solution File, Format Version 12.00
-# Visual Studio 15
-VisualStudioVersion = 15.0.28307.539
-MinimumVisualStudioVersion = 10.0.40219.1
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "bls", "bls.csproj", "{E9D06B1B-EA22-4EF4-BA4B-422F7625966D}"
-EndProject
-Global
- GlobalSection(SolutionConfigurationPlatforms) = preSolution
- Debug|x64 = Debug|x64
- Release|x64 = Release|x64
- EndGlobalSection
- GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {E9D06B1B-EA22-4EF4-BA4B-422F7625966D}.Debug|x64.ActiveCfg = Debug|x64
- {E9D06B1B-EA22-4EF4-BA4B-422F7625966D}.Debug|x64.Build.0 = Debug|x64
- {E9D06B1B-EA22-4EF4-BA4B-422F7625966D}.Release|x64.ActiveCfg = Release|x64
- {E9D06B1B-EA22-4EF4-BA4B-422F7625966D}.Release|x64.Build.0 = Release|x64
- EndGlobalSection
- GlobalSection(SolutionProperties) = preSolution
- HideSolutionNode = FALSE
- EndGlobalSection
- GlobalSection(ExtensibilityGlobals) = postSolution
- SolutionGuid = {1935C301-6478-4F82-9587-6A66B531E327}
- EndGlobalSection
-EndGlobal
diff --git a/vendor/github.com/byzantine-lab/bls/ffi/cs/bls256.cs b/vendor/github.com/byzantine-lab/bls/ffi/cs/bls256.cs
deleted file mode 100644
index 3ef5fab9a..000000000
--- a/vendor/github.com/byzantine-lab/bls/ffi/cs/bls256.cs
+++ /dev/null
@@ -1,298 +0,0 @@
-using System;
-using System.Text;
-using System.Runtime.InteropServices;
-
-namespace mcl {
- class BLS256 {
- const int IoEcComp = 512; // fixed byte representation
- public const int MCLBN_FR_UNIT_SIZE = 4;
- public const int MCLBN_FP_UNIT_SIZE = 4;
- public const int MCLBN_COMPILED_TIME_VAR = MCLBN_FR_UNIT_SIZE * 10 + MCLBN_FP_UNIT_SIZE;
- [DllImport("bls256.dll")]
- public static extern int blsInit(int curve, int compiledTimeVar);
-
- [DllImport("bls256.dll")] public static extern void blsIdSetInt(ref Id id, int x);
- [DllImport("bls256.dll")] public static extern int blsIdSetDecStr(ref Id id, [In][MarshalAs(UnmanagedType.LPStr)] string buf, ulong bufSize);
- [DllImport("bls256.dll")] public static extern int blsIdSetHexStr(ref Id id, [In][MarshalAs(UnmanagedType.LPStr)] string buf, ulong bufSize);
- [DllImport("bls256.dll")] public static extern ulong blsIdGetDecStr([Out]StringBuilder buf, ulong maxBufSize, ref Id id);
- [DllImport("bls256.dll")] public static extern ulong blsIdGetHexStr([Out]StringBuilder buf, ulong maxBufSize, ref Id id);
-
-
- [DllImport("bls256.dll")] public static extern ulong blsIdSerialize([Out]StringBuilder buf, ulong maxBufSize, ref Id id);
- [DllImport("bls256.dll")] public static extern ulong blsSecretKeySerialize([Out]StringBuilder buf, ulong maxBufSize, ref SecretKey sec);
- [DllImport("bls256.dll")] public static extern ulong blsPublicKeySerialize([Out]StringBuilder buf, ulong maxBufSize, ref PublicKey pub);
- [DllImport("bls256.dll")] public static extern ulong blsSignatureSerialize([Out]StringBuilder buf, ulong maxBufSize, ref Signature sig);
-
- [DllImport("bls256.dll")] public static extern int blsIdDeserialize(ref Id id, [In][MarshalAs(UnmanagedType.LPStr)] string buf, ulong bufSize);
- [DllImport("bls256.dll")] public static extern int blsSecretKeyDeserialize(ref SecretKey sec, [In][MarshalAs(UnmanagedType.LPStr)] string buf, ulong bufSize);
- [DllImport("bls256.dll")] public static extern int blsPublicKeyDeserialize(ref PublicKey pub, [In][MarshalAs(UnmanagedType.LPStr)] string buf, ulong bufSize);
- [DllImport("bls256.dll")] public static extern int blsSignatureDeserialize(ref Signature sig, [In][MarshalAs(UnmanagedType.LPStr)] string buf, ulong bufSize);
-
- [DllImport("bls256.dll")] public static extern int blsIdIsEqual(ref Id lhs, ref Id rhs);
- [DllImport("bls256.dll")] public static extern int blsSecretKeyIsEqual(ref SecretKey lhs, ref SecretKey rhs);
- [DllImport("bls256.dll")] public static extern int blsPublicKeyIsEqual(ref PublicKey lhs, ref PublicKey rhs);
- [DllImport("bls256.dll")] public static extern int blsSignatureIsEqual(ref Signature lhs, ref Signature rhs);
-
- // add
- [DllImport("bls256.dll")] public static extern void blsSecretKeyAdd(ref SecretKey sec, ref SecretKey rhs);
- [DllImport("bls256.dll")] public static extern void blsPublicKeyAdd(ref PublicKey pub, ref PublicKey rhs);
- [DllImport("bls256.dll")] public static extern void blsSignatureAdd(ref Signature sig, ref Signature rhs);
-
- // hash buf and set
- [DllImport("bls256.dll")] public static extern int blsHashToSecretKey(ref SecretKey sec, [In][MarshalAs(UnmanagedType.LPStr)] string buf, ulong bufSize);
- /*
- set secretKey if system has /dev/urandom or CryptGenRandom
- return 0 if success else -1
- */
- [DllImport("bls256.dll")] public static extern int blsSecretKeySetByCSPRNG(ref SecretKey sec);
-
- [DllImport("bls256.dll")] public static extern void blsGetPublicKey(ref PublicKey pub, ref SecretKey sec);
- [DllImport("bls256.dll")] public static extern void blsGetPop(ref Signature sig, ref SecretKey sec);
-
- // return 0 if success
- [DllImport("bls256.dll")] public static extern int blsSecretKeyShare(ref SecretKey sec, ref SecretKey msk, ulong k, ref Id id);
- [DllImport("bls256.dll")] public static extern int blsPublicKeyShare(ref PublicKey pub, ref PublicKey mpk, ulong k, ref Id id);
-
-
- [DllImport("bls256.dll")] public static extern int blsSecretKeyRecover(ref SecretKey sec, ref SecretKey secVec, ref Id idVec, ulong n);
- [DllImport("bls256.dll")] public static extern int blsPublicKeyRecover(ref PublicKey pub, ref PublicKey pubVec, ref Id idVec, ulong n);
- [DllImport("bls256.dll")] public static extern int blsSignatureRecover(ref Signature sig, ref Signature sigVec, ref Id idVec, ulong n);
-
- [DllImport("bls256.dll")] public static extern void blsSign(ref Signature sig, ref SecretKey sec, [In][MarshalAs(UnmanagedType.LPStr)] string m, ulong size);
-
- // return 1 if valid
- [DllImport("bls256.dll")] public static extern int blsVerify(ref Signature sig, ref PublicKey pub, [In][MarshalAs(UnmanagedType.LPStr)] string m, ulong size);
- [DllImport("bls256.dll")] public static extern int blsVerifyPop(ref Signature sig, ref PublicKey pub);
-
- //////////////////////////////////////////////////////////////////////////
- // the following apis will be removed
-
- // mask buf with (1 << (bitLen(r) - 1)) - 1 if buf >= r
- [DllImport("bls256.dll")] public static extern int blsIdSetLittleEndian(ref Id id, [In][MarshalAs(UnmanagedType.LPStr)] string buf, ulong bufSize);
- /*
- return written byte size if success else 0
- */
- [DllImport("bls256.dll")] public static extern ulong blsIdGetLittleEndian([Out]StringBuilder buf, ulong maxBufSize, ref Id id);
-
- // return 0 if success
- // mask buf with (1 << (bitLen(r) - 1)) - 1 if buf >= r
- [DllImport("bls256.dll")] public static extern int blsSecretKeySetLittleEndian(ref SecretKey sec, [In][MarshalAs(UnmanagedType.LPStr)] string buf, ulong bufSize);
- [DllImport("bls256.dll")] public static extern int blsSecretKeySetDecStr(ref SecretKey sec, [In][MarshalAs(UnmanagedType.LPStr)] string buf, ulong bufSize);
- [DllImport("bls256.dll")] public static extern int blsSecretKeySetHexStr(ref SecretKey sec, [In][MarshalAs(UnmanagedType.LPStr)] string buf, ulong bufSize);
- /*
- return written byte size if success else 0
- */
- [DllImport("bls256.dll")] public static extern ulong blsSecretKeyGetLittleEndian([Out]StringBuilder buf, ulong maxBufSize, ref SecretKey sec);
- /*
- return strlen(buf) if success else 0
- buf is '\0' terminated
- */
- [DllImport("bls256.dll")] public static extern ulong blsSecretKeyGetDecStr([Out]StringBuilder buf, ulong maxBufSize, ref SecretKey sec);
- [DllImport("bls256.dll")] public static extern ulong blsSecretKeyGetHexStr([Out]StringBuilder buf, ulong maxBufSize, ref SecretKey sec);
- [DllImport("bls256.dll")] public static extern int blsPublicKeySetHexStr(ref PublicKey pub, [In][MarshalAs(UnmanagedType.LPStr)] string buf, ulong bufSize);
- [DllImport("bls256.dll")] public static extern ulong blsPublicKeyGetHexStr([Out]StringBuilder buf, ulong maxBufSize, ref PublicKey pub);
- [DllImport("bls256.dll")] public static extern int blsSignatureSetHexStr(ref Signature sig, [In][MarshalAs(UnmanagedType.LPStr)] string buf, ulong bufSize);
- [DllImport("bls256.dll")] public static extern ulong blsSignatureGetHexStr([Out]StringBuilder buf, ulong maxBufSize, ref Signature sig);
-
- public static void Init()
- {
- const int CurveFp254BNb = 0;
- if (!System.Environment.Is64BitProcess) {
- throw new PlatformNotSupportedException("not 64-bit system");
- }
- int err = blsInit(CurveFp254BNb, MCLBN_COMPILED_TIME_VAR);
- if (err != 0) {
- throw new ArgumentException("blsInit");
- }
- }
-
- public struct Id {
- private ulong v0, v1, v2, v3;
- public bool IsEqual(Id rhs)
- {
- return blsIdIsEqual(ref this, ref rhs) != 0;
- }
- public void SetDecStr(String s)
- {
- if (blsIdSetDecStr(ref this, s, (ulong)s.Length) != 0) {
- throw new ArgumentException("blsIdSetDecSt:" + s);
- }
- }
- public void SetHexStr(String s)
- {
- if (blsIdSetHexStr(ref this, s, (ulong)s.Length) != 0) {
- throw new ArgumentException("blsIdSetHexStr:" + s);
- }
- }
- public void SetInt(int x)
- {
- blsIdSetInt(ref this, x);
- }
- public string GetDecStr()
- {
- StringBuilder sb = new StringBuilder(1024);
- ulong size = blsIdGetDecStr(sb, (ulong)sb.Capacity, ref this);
- if (size == 0) {
- throw new ArgumentException("blsIdGetDecStr");
- }
- return sb.ToString(0, (int)size);
- }
- public string GetHexStr()
- {
- StringBuilder sb = new StringBuilder(1024);
- ulong size = blsIdGetHexStr(sb, (ulong)sb.Capacity, ref this);
- if (size == 0) {
- throw new ArgumentException("blsIdGetHexStr");
- }
- return sb.ToString(0, (int)size);
- }
- }
- public struct SecretKey {
- private ulong v0, v1, v2, v3;
- public bool IsEqual(SecretKey rhs)
- {
- return blsSecretKeyIsEqual(ref this, ref rhs) != 0;
- }
- public void SetHexStr(String s)
- {
- if (blsSecretKeySetHexStr(ref this, s, (ulong)s.Length) != 0) {
- throw new ArgumentException("blsSecretKeySetHexStr:" + s);
- }
- }
- public string GetHexStr()
- {
- StringBuilder sb = new StringBuilder(1024);
- ulong size = blsSecretKeyGetHexStr(sb, (ulong)sb.Capacity, ref this);
- if (size == 0) {
- throw new ArgumentException("mclBnFr_getStr");
- }
- return sb.ToString(0, (int)size);
- }
- public void Add(SecretKey rhs)
- {
- blsSecretKeyAdd(ref this, ref rhs);
- }
- public void SetByCSPRNG()
- {
- blsSecretKeySetByCSPRNG(ref this);
- }
- public void SetHashOf(string s)
- {
- if (blsHashToSecretKey(ref this, s, (ulong)s.Length) != 0) {
- throw new ArgumentException("blsHashToSecretKey");
- }
- }
- public PublicKey GetPublicKey()
- {
- PublicKey pub = new PublicKey();
- blsGetPublicKey(ref pub, ref this);
- return pub;
- }
- public Signature Signature(String m)
- {
- Signature Signature = new Signature();
- blsSign(ref Signature, ref this, m, (ulong)m.Length);
- return Signature;
- }
- }
- // secretKey = sum_{i=0}^{msk.Length - 1} msk[i] * id^i
- public static SecretKey ShareSecretKey(SecretKey[] msk, Id id)
- {
- SecretKey sec = new SecretKey();
- if (blsSecretKeyShare(ref sec, ref msk[0], (ulong)msk.Length, ref id) != 0) {
- throw new ArgumentException("GetSecretKeyForId:" + id.ToString());
- }
- return sec;
- }
- public static SecretKey RecoverSecretKey(SecretKey[] secs, Id[] ids)
- {
- SecretKey sec = new SecretKey();
- if (blsSecretKeyRecover(ref sec, ref secs[0], ref ids[0], (ulong)secs.Length) != 0) {
- throw new ArgumentException("Recover");
- }
- return sec;
- }
- public struct PublicKey {
- private ulong v00, v01, v02, v03, v04, v05, v06, v07, v08, v09, v10, v11;
- private ulong v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23;
- public bool IsEqual(PublicKey rhs)
- {
- return blsPublicKeyIsEqual(ref this, ref rhs) != 0;
- }
- public void SetStr(String s)
- {
- if (blsPublicKeySetHexStr(ref this, s, (ulong)s.Length) != 0) {
- throw new ArgumentException("blsPublicKeySetStr:" + s);
- }
- }
- public string GetHexStr()
- {
- StringBuilder sb = new StringBuilder(1024);
- ulong size = blsPublicKeyGetHexStr(sb, (ulong)sb.Capacity, ref this);
- if (size == 0) {
- throw new ArgumentException("blsPublicKeyGetStr");
- }
- return sb.ToString(0, (int)size);
- }
- public void Add(PublicKey rhs)
- {
- blsPublicKeyAdd(ref this, ref rhs);
- }
- public bool Verify(Signature Signature, string m)
- {
- return blsVerify(ref Signature, ref this, m, (ulong)m.Length) == 1;
- }
- }
- // publicKey = sum_{i=0}^{mpk.Length - 1} mpk[i] * id^i
- public static PublicKey SharePublicKey(PublicKey[] mpk, Id id)
- {
- PublicKey pub = new PublicKey();
- if (blsPublicKeyShare(ref pub, ref mpk[0], (ulong)mpk.Length, ref id) != 0) {
- throw new ArgumentException("GetPublicKeyForId:" + id.ToString());
- }
- return pub;
- }
- public static PublicKey RecoverPublicKey(PublicKey[] pubs, Id[] ids)
- {
- PublicKey pub = new PublicKey();
- if (blsPublicKeyRecover(ref pub, ref pubs[0], ref ids[0], (ulong)pubs.Length) != 0) {
- throw new ArgumentException("Recover");
- }
- return pub;
- }
- public struct Signature {
- private ulong v00, v01, v02, v03, v04, v05, v06, v07, v08, v09, v10, v11;
- public bool IsEqual(Signature rhs)
- {
- return blsSignatureIsEqual(ref this, ref rhs) != 0;
- }
- public void SetStr(String s)
- {
- if (blsSignatureSetHexStr(ref this, s, (ulong)s.Length) != 0) {
- throw new ArgumentException("blsSignatureSetStr:" + s);
- }
- }
- public string GetHexStr()
- {
- StringBuilder sb = new StringBuilder(1024);
- ulong size = blsSignatureGetHexStr(sb, (ulong)sb.Capacity, ref this);
- if (size == 0) {
- throw new ArgumentException("blsSignatureGetStr");
- }
- return sb.ToString(0, (int)size);
- }
- public void Add(Signature rhs)
- {
- blsSignatureAdd(ref this, ref rhs);
- }
- }
- public static Signature RecoverSign(Signature[] signs, Id[] ids)
- {
- Signature Signature = new Signature();
- if (blsSignatureRecover(ref Signature, ref signs[0], ref ids[0], (ulong)signs.Length) != 0) {
- throw new ArgumentException("Recover");
- }
- return Signature;
- }
- }
-}
diff --git a/vendor/github.com/byzantine-lab/bls/ffi/cs/bls256.csproj b/vendor/github.com/byzantine-lab/bls/ffi/cs/bls256.csproj
deleted file mode 100644
index 032a1d347..000000000
--- a/vendor/github.com/byzantine-lab/bls/ffi/cs/bls256.csproj
+++ /dev/null
@@ -1,62 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
- <PropertyGroup>
- <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
- <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
- <ProjectGuid>{E9D06B1B-EA22-4EF4-BA4B-422F7625966C}</ProjectGuid>
- <OutputType>Exe</OutputType>
- <AppDesignerFolder>Properties</AppDesignerFolder>
- <RootNamespace>bls256</RootNamespace>
- <AssemblyName>bls256</AssemblyName>
- <TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
- <FileAlignment>512</FileAlignment>
- <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
- <DebugSymbols>true</DebugSymbols>
- <OutputPath>..\..\bin\</OutputPath>
- <DefineConstants>DEBUG;TRACE</DefineConstants>
- <AllowUnsafeBlocks>false</AllowUnsafeBlocks>
- <DebugType>full</DebugType>
- <PlatformTarget>x64</PlatformTarget>
- <ErrorReport>prompt</ErrorReport>
- <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
- <OutputPath>..\..\bin\</OutputPath>
- <DefineConstants>TRACE</DefineConstants>
- <Optimize>true</Optimize>
- <DebugType>pdbonly</DebugType>
- <PlatformTarget>x64</PlatformTarget>
- <ErrorReport>prompt</ErrorReport>
- <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
- <Prefer32Bit>true</Prefer32Bit>
- </PropertyGroup>
- <ItemGroup>
- <Reference Include="System" />
- <Reference Include="System.Core" />
- <Reference Include="System.Xml.Linq" />
- <Reference Include="System.Data.DataSetExtensions" />
- <Reference Include="Microsoft.CSharp" />
- <Reference Include="System.Data" />
- <Reference Include="System.Net.Http" />
- <Reference Include="System.Xml" />
- </ItemGroup>
- <ItemGroup>
- <Compile Include="bls256.cs" />
- <Compile Include="bls256_test.cs" />
- <Compile Include="Properties\AssemblyInfo.cs" />
- </ItemGroup>
- <ItemGroup>
- <None Include="App.config" />
- </ItemGroup>
- <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
- <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
- Other similar extension points exist, see Microsoft.Common.targets.
- <Target Name="BeforeBuild">
- </Target>
- <Target Name="AfterBuild">
- </Target>
- -->
-</Project> \ No newline at end of file
diff --git a/vendor/github.com/byzantine-lab/bls/ffi/cs/bls256.sln b/vendor/github.com/byzantine-lab/bls/ffi/cs/bls256.sln
deleted file mode 100644
index eb29af97b..000000000
--- a/vendor/github.com/byzantine-lab/bls/ffi/cs/bls256.sln
+++ /dev/null
@@ -1,22 +0,0 @@
-
-Microsoft Visual Studio Solution File, Format Version 12.00
-# Visual Studio 14
-VisualStudioVersion = 14.0.25420.1
-MinimumVisualStudioVersion = 10.0.40219.1
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBD}") = "bls256", "bls256.csproj", "{E9D06B1B-EA22-4EF4-BA4B-422F7625966C}"
-EndProject
-Global
- GlobalSection(SolutionConfigurationPlatforms) = preSolution
- Debug|x64 = Debug|x64
- Release|x64 = Release|x64
- EndGlobalSection
- GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {E9D06B1B-EA22-4EF4-BA4B-422F7625966C}.Debug|x64.ActiveCfg = Debug|x64
- {E9D06B1B-EA22-4EF4-BA4B-422F7625966C}.Debug|x64.Build.0 = Debug|x64
- {E9D06B1B-EA22-4EF4-BA4B-422F7625966C}.Release|x64.ActiveCfg = Release|x64
- {E9D06B1B-EA22-4EF4-BA4B-422F7625966C}.Release|x64.Build.0 = Release|x64
- EndGlobalSection
- GlobalSection(SolutionProperties) = preSolution
- HideSolutionNode = FALSE
- EndGlobalSection
-EndGlobal
diff --git a/vendor/github.com/byzantine-lab/bls/ffi/cs/bls256_test.cs b/vendor/github.com/byzantine-lab/bls/ffi/cs/bls256_test.cs
deleted file mode 100644
index 989993e0f..000000000
--- a/vendor/github.com/byzantine-lab/bls/ffi/cs/bls256_test.cs
+++ /dev/null
@@ -1,126 +0,0 @@
-using System;
-
-namespace mcl {
- using static BLS256;
- class BLS256Test {
- static int err = 0;
- static void assert(string msg, bool b)
- {
- if (b) return;
- Console.WriteLine("ERR {0}", msg);
- err++;
- }
- static void TestId()
- {
- Console.WriteLine("TestId");
- Id id = new Id();
- id.SetDecStr("255");
- assert("GetStr(10)", id.GetDecStr() == "255");
- assert("GetStr(16)", id.GetHexStr() == "ff");
- }
- static void TestSecretKey()
- {
- Console.WriteLine("TestSecretKey");
- SecretKey sec = new SecretKey();
- sec.SetHexStr("ff");
- assert("GetHexStr()", sec.GetHexStr() == "ff");
- {
- SecretKey sec2 = new SecretKey();
- sec.SetHexStr("321");
- sec2.SetHexStr("4000");
- sec.Add(sec2);
- assert("sec.Add", sec.GetHexStr() == "4321");
- sec.SetByCSPRNG();
- Console.WriteLine("sec.Init={0}", sec.GetHexStr());
- }
- }
- static void TestPublicKey()
- {
- Console.WriteLine("TestPublicKey");
- SecretKey sec = new SecretKey();
- sec.SetByCSPRNG();
- PublicKey pub = sec.GetPublicKey();
- String s = pub.GetHexStr();
- Console.WriteLine("pub={0}", s);
- PublicKey pub2 = new PublicKey();
- pub2.SetStr(s);
- assert("pub.SetStr", pub.IsEqual(pub2));
- }
- static void TestSign()
- {
- Console.WriteLine("TestSign");
- SecretKey sec = new SecretKey();
- sec.SetByCSPRNG();
- PublicKey pub = sec.GetPublicKey();
- String m = "abc";
- Signature sig = sec.Signature(m);
- assert("verify", pub.Verify(sig, m));
- assert("not verify", !pub.Verify(sig, m + "a"));
- }
- static void TestSharing()
- {
- Console.WriteLine("TestSharing");
- int k = 5;
- SecretKey[] msk = new SecretKey[k];
- PublicKey[] mpk = new PublicKey[k];
- // make master secretkey
- for (int i = 0; i < k; i++) {
- msk[i].SetByCSPRNG();
- mpk[i] = msk[i].GetPublicKey();
- }
- int n = 30;
- Id[] ids = new Id[n];
- SecretKey[] secs = new SecretKey[n];
- PublicKey[] pubs = new PublicKey[n];
- for (int i = 0; i < n; i++) {
- ids[i].SetInt(i * i + 123);
- secs[i] = ShareSecretKey(msk, ids[i]);
- pubs[i] = SharePublicKey(mpk, ids[i]);
- assert("share publicKey", secs[i].GetPublicKey().IsEqual(pubs[i]));
- }
- string m = "doremi";
- for (int i = 0; i < n; i++) {
- Signature Signature = secs[i].Signature(m);
- assert("Signature.Verify", pubs[i].Verify(Signature, m));
- }
- {
- int[] idxTbl = { 0, 2, 5, 8, 10 };
- assert("idxTbl.Length=k", idxTbl.Length == k);
- Id[] subIds = new Id[k];
- SecretKey[] subSecs = new SecretKey[k];
- PublicKey[] subPubs = new PublicKey[k];
- Signature[] subSigns = new Signature[k];
- for (int i = 0; i < k; i++) {
- int idx = idxTbl[i];
- subIds[i] = ids[idx];
- subSecs[i] = secs[idx];
- subPubs[i] = pubs[idx];
- subSigns[i] = secs[idx].Signature(m);
- }
- SecretKey sec = RecoverSecretKey(subSecs, subIds);
- PublicKey pub = RecoverPublicKey(subPubs, subIds);
- assert("check pub", pub.IsEqual(sec.GetPublicKey()));
- Signature Signature = RecoverSign(subSigns, subIds);
- assert("Signature.verify", pub.Verify(Signature, m));
- }
- }
- static void Main(string[] args)
- {
- try {
- Init();
- TestId();
- TestSecretKey();
- TestPublicKey();
- TestSign();
- TestSharing();
- if (err == 0) {
- Console.WriteLine("all tests succeed");
- } else {
- Console.WriteLine("err={0}", err);
- }
- } catch (Exception e) {
- Console.WriteLine("ERR={0}", e);
- }
- }
- }
-}
diff --git a/vendor/github.com/byzantine-lab/bls/ffi/cs/bls_test.cs b/vendor/github.com/byzantine-lab/bls/ffi/cs/bls_test.cs
deleted file mode 100644
index 2eb451ba9..000000000
--- a/vendor/github.com/byzantine-lab/bls/ffi/cs/bls_test.cs
+++ /dev/null
@@ -1,176 +0,0 @@
-using System;
-
-namespace mcl
-{
- using static BLS;
- class BLSTest
- {
- static int err = 0;
- static void assert(string msg, bool b) {
- if (b) return;
- Console.WriteLine("ERR {0}", msg);
- err++;
- }
- static void TestId() {
- Console.WriteLine("TestId");
- Id id1;
- id1.SetDecStr("255");
- assert("GetStr(10)", id1.GetDecStr() == "255");
- assert("GetStr(16)", id1.GetHexStr() == "ff");
- Id id2;
- id2.SetInt(255);
- assert("IsEqual", id1.IsEqual(id2));
- }
- static void TestSecretKey() {
- Console.WriteLine("TestSecretKey");
- SecretKey sec;
- sec.SetHexStr("ff");
- assert("GetHexStr()", sec.GetHexStr() == "ff");
- {
- SecretKey sec2;
- sec.SetHexStr("321");
- sec2.SetHexStr("4000");
- sec.Add(sec2);
- assert("sec.Add", sec.GetHexStr() == "4321");
- sec.SetByCSPRNG();
- Console.WriteLine("sec.Init={0}", sec.GetHexStr());
- }
- {
- SecretKey sec2;
- byte[] buf = sec.Serialize();
- sec2.Deserialize(buf);
- assert("serialize", sec2.IsEqual(sec));
- }
- }
- static void TestPublicKey() {
- Console.WriteLine("TestPublicKey");
- SecretKey sec;
- sec.SetByCSPRNG();
- PublicKey pub = sec.GetPublicKey();
- string s = pub.GetHexStr();
- Console.WriteLine("pub={0}", s);
- {
- PublicKey pub2;
- pub2.SetStr(s);
- assert("pub.SetStr", pub.IsEqual(pub2));
- }
- {
- PublicKey pub2;
- byte[] buf = pub.Serialize();
- pub2.Deserialize(buf);
- assert("serialize", pub2.IsEqual(pub));
- }
- }
- static void TestSign() {
- Console.WriteLine("TestSign");
- SecretKey sec;
- sec.SetByCSPRNG();
- PublicKey pub = sec.GetPublicKey();
- string m = "abc";
- Signature sig = sec.Sign(m);
- Console.WriteLine("sig={0}", sig.GetHexStr());
- assert("verify", pub.Verify(sig, m));
- assert("not verify", !pub.Verify(sig, m + "a"));
- {
- Signature sig2;
- byte[] buf = sig.Serialize();
- sig2.Deserialize(buf);
- assert("serialize", sig2.IsEqual(sig));
- }
- }
- static void TestSharing() {
- Console.WriteLine("TestSharing");
- int k = 5;
- SecretKey[] msk = new SecretKey[k];
- PublicKey[] mpk = new PublicKey[k];
- // make master secretkey
- for (int i = 0; i < k; i++) {
- msk[i].SetByCSPRNG();
- mpk[i] = msk[i].GetPublicKey();
- }
- int n = 30;
- Id[] ids = new Id[n];
- SecretKey[] secs = new SecretKey[n];
- PublicKey[] pubs = new PublicKey[n];
- for (int i = 0; i < n; i++) {
- ids[i].SetInt(i * i + 123);
- secs[i] = ShareSecretKey(msk, ids[i]);
- pubs[i] = SharePublicKey(mpk, ids[i]);
- assert("share publicKey", secs[i].GetPublicKey().IsEqual(pubs[i]));
- }
- string m = "doremi";
- for (int i = 0; i < n; i++) {
- Signature Signature = secs[i].Sign(m);
- assert("Signature.Verify", pubs[i].Verify(Signature, m));
- }
- {
- int[] idxTbl = { 0, 2, 5, 8, 10 };
- assert("idxTbl.Length=k", idxTbl.Length == k);
- Id[] subIds = new Id[k];
- SecretKey[] subSecs = new SecretKey[k];
- PublicKey[] subPubs = new PublicKey[k];
- Signature[] subSigns = new Signature[k];
- for (int i = 0; i < k; i++) {
- int idx = idxTbl[i];
- subIds[i] = ids[idx];
- subSecs[i] = secs[idx];
- subPubs[i] = pubs[idx];
- subSigns[i] = secs[idx].Sign(m);
- }
- SecretKey sec = RecoverSecretKey(subSecs, subIds);
- PublicKey pub = RecoverPublicKey(subPubs, subIds);
- assert("check pub", pub.IsEqual(sec.GetPublicKey()));
- Signature Signature = RecoverSign(subSigns, subIds);
- assert("Signature.verify", pub.Verify(Signature, m));
- }
- }
- static void TestAggregate() {
- Console.WriteLine("TestAggregate");
- const int n = 10;
- const string m = "abc";
- SecretKey[] secVec = new SecretKey[n];
- PublicKey[] pubVec = new PublicKey[n];
- Signature[] popVec = new Signature[n];
- Signature[] sigVec = new Signature[n];
- for (int i = 0; i < n; i++) {
- secVec[i].SetByCSPRNG();
- pubVec[i] = secVec[i].GetPublicKey();
- popVec[i] = secVec[i].GetPop();
- sigVec[i] = secVec[i].Sign(m);
- }
- SecretKey secAgg;
- PublicKey pubAgg;
- Signature sigAgg;
- for (int i = 0; i < n; i++) {
- secAgg.Add(secVec[i]);
- assert("verify pop", pubVec[i].VerifyPop(popVec[i]));
- pubAgg.Add(pubVec[i]);
- sigAgg.Add(sigVec[i]);
- }
- assert("aggregate sec", secAgg.Sign(m).IsEqual(sigAgg));
- assert("aggregate", pubAgg.Verify(sigAgg, m));
- }
- static void Main(string[] args) {
- try {
- int[] curveTypeTbl = { BN254, BLS12_381 };
- foreach (int curveType in curveTypeTbl) {
- Console.WriteLine("curveType={0}", curveType);
- Init(curveType);
- TestId();
- TestSecretKey();
- TestPublicKey();
- TestSign();
- TestSharing();
- TestAggregate();
- if (err == 0) {
- Console.WriteLine("all tests succeed");
- } else {
- Console.WriteLine("err={0}", err);
- }
- }
- } catch (Exception e) {
- Console.WriteLine("ERR={0}", e);
- }
- }
- }
-}
diff --git a/vendor/github.com/byzantine-lab/bls/ffi/cs/readme-ja.md b/vendor/github.com/byzantine-lab/bls/ffi/cs/readme-ja.md
deleted file mode 100644
index 199135725..000000000
--- a/vendor/github.com/byzantine-lab/bls/ffi/cs/readme-ja.md
+++ /dev/null
@@ -1,188 +0,0 @@
-# BLS署名のC#バインディング
-
-# 必要環境
-
-* Visual Studio 2017(x64) or later
-* C# 7.2 or later
-* .NET Framework 4.5.2 or later
-
-# DLLのビルド方法
-
-Visual Studio 2017の64bit用コマンドプロンプトを開いて
-```
-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
-```
-`bls/bin/*.dll`が作成される。
-
-# サンプルのビルド方法
-
-bls/ffi/cs/bls.slnを開いて実行する。
-
-* 注意 bls256.slnは古いため使わないでください。
-
-# クラスとAPI
-
-## API
-
-* `Init(int curveType = BN254);`
- * ライブラリを曲線curveTypeで初期化する。
- * curveType = BN254 or BLS12_381
-* `SecretKey ShareSecretKey(in SecretKey[] msk, in Id id);`
- * マスター秘密鍵の列mskに対するidの秘密鍵を生成(共有)する。
-* `SecretKey RecoverSecretKey(in SecretKey[] secVec, in Id[] idVec);`
- * 秘密鍵secVecとID idVecのペアから秘密鍵を復元する。
-* `PublicKey SharePublicKey(in PublicKey[] mpk, in Id id);`
- * マスター公開鍵の列mpkに対するidの公開鍵を生成(共有)する。
-* `PublicKey RecoverPublicKey(in PublicKey[] pubVec, in Id[] idVec);`
- * 公開鍵pubVecとID idVecのペアから公開鍵を復元する。
-* `Signature RecoverSign(in Signature[] sigVec, in Id[] idVec);`
- * 署名sigVecとID idVecのペアから署名を復元する。
-
-## Id
-
-識別子クラス
-
-* `byte[] Serialize();`
- * Idをシリアライズする。
-* `void Deserialize(byte[] buf);`
- * バイト列bufからIdをデシリアライズする。
-* `bool IsEqual(in Id rhs);`
- * 同値判定。
-* `void SetDecStr(string s);`
- * 10進数文字列を設定する。
-* `void SetHexStr(string s);`
- * 16進数文字列を設定する。
-* `void SetInt(int x);`
- * 整数xを設定する。
-* `string GetDecStr();`
- * 10進数表記を取得する。
-* `string GetHexStr();`
- * 16進数表記を取得する。
-
-## SecretKey
-
-* `byte[] Serialize();`
- * Idをシリアライズする。
-* `void Deserialize(byte[] buf);`
- * バイト列bufからSecretKeyをデシリアライズする。
-* `bool IsEqual(in SecretKey rhs);`
- * 同値判定。
-* `void SetHexStr(string s);`
- * 16進数文字列を設定する。
-* `string GetHexStr();`
- * 16進数表記を取得する。
-* `void Add(in SecretKey rhs);`
- * 秘密鍵rhsを加算する。
-* `void SetByCSPRNG();`
- * 暗号学的乱数で設定する。
-* `void SetHashOf(string s);`
- * 文字列sのハッシュ値を設定する。
-* `PublicKey GetPublicKey();`
- * 対応する公開鍵を取得する。
-* `Signature Sign(string m);`
- * 文字列mの署名を生成する。
-* `Signature GetPop();`
- * 自身の秘密鍵による署名(Proof Of Posession)を生成する。
-
-## PublicKey
-
-* `byte[] Serialize();`
- * PublicKeyをシリアライズする。
-* `void Deserialize(byte[] buf);`
- * バイト列bufからPublicKeyをデシリアライズする。
-* `bool IsEqual(in PublicKey rhs);`
- * 同値判定。
-* `void Add(in PublicKey rhs);`
- * 公開鍵rhsを加算する。
-* `void SetHexStr(string s);`
- * 16進数文字列を設定する。
-* `string GetHexStr();`
- * 16進数表記を取得する。
-* `bool Verify(in Signature sig, string m);`
- * 文字列mに対する署名sigの正当性を確認する。
-* `bool VerifyPop(in Signature pop);`
- * PoPの正当性を確認する。
-
-## Signature
-
-* `byte[] Serialize();`
- * Signatureをシリアライズする。
-* `void Deserialize(byte[] buf);`
- * バイト列bufからSignatureをデシリアライズする。
-* `bool IsEqual(in Signature rhs);`
- * 同値判定。
-* `void Add(in Signature rhs);`
- * 署名rhsを加算する。
-* `void SetHexStr(string s);`
- * 16進数文字列を設定する。
-* `string GetHexStr();`
- * 16進数表記を取得する。
-
-## 使い方
-
-### 最小サンプル
-
-```
-using static BLS;
-
-Init(BN254); // ライブラリ初期化
-SecretKey sec;
-sec.SetByCSPRNG(); // 秘密鍵の初期化
-PublicKey pub = sec.GetPublicKey(); // 公開鍵の取得
-string m = "abc";
-Signature sig = sec.Sign(m); // 署名の作成
-if (pub.Verify(sig, m))) {
- // 署名の確認
-}
-```
-
-### 集約署名
-```
-Init(BN254); // ライブラリ初期化
-const int n = 10;
-const string m = "abc";
-SecretKey[] secVec = new SecretKey[n];
-PublicKey[] pubVec = new PublicKey[n];
-Signature[] popVec = new Signature[n];
-Signature[] sigVec = new Signature[n];
-
-for (int i = 0; i < n; i++) {
- secVec[i].SetByCSPRNG(); // 秘密鍵の初期化
- pubVec[i] = secVec[i].GetPublicKey(); // 公開鍵の取得
- popVec[i] = secVec[i].GetPop(); // 所有(PoP)の証明
- sigVec[i] = secVec[i].Sign(m); // 署名
-}
-
-SecretKey secAgg;
-PublicKey pubAgg;
-Signature sigAgg;
-for (int i = 0; i < n; i++) {
- // PoPの確認
- if (pubVec[i].VerifyPop(popVec[i]))) {
- // エラー
- return;
- }
- pubAgg.Add(pubVec[i]); // 公開鍵の集約
- sigAgg.Add(sigVec[i]); // 署名の集約
-}
-if (pubAgg.Verify(sigAgg, m)) {
- // 署名の確認
-}
-```
-
-# ライセンス
-
-modified new BSD License
-http://opensource.org/licenses/BSD-3-Clause
-
-# 著者
-
-(C)2019 光成滋生 MITSUNARI Shigeo(herumi@nifty.com) All rights reserved.
-本コンテンツの著作権、および本コンテンツ中に出てくる商標権、団体名、ロゴ、製品、
-サービスなどはそれぞれ、各権利保有者に帰属します
diff --git a/vendor/github.com/byzantine-lab/bls/ffi/cs/readme.md b/vendor/github.com/byzantine-lab/bls/ffi/cs/readme.md
deleted file mode 100644
index 2b7191871..000000000
--- a/vendor/github.com/byzantine-lab/bls/ffi/cs/readme.md
+++ /dev/null
@@ -1,185 +0,0 @@
-# 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
-```
-bls/bin/*.dll are created
-
-# 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
-
-## How to use
-
-### A minimum sample
-
-```
-using static BLS;
-
-Init(BN254); // init library
-SecretKey sec;
-sec.SetByCSPRNG(); // init secret key
-PublicKey pub = sec.GetPublicKey(); // get public key
-string m = "abc";
-Signature sig = sec.Sign(m); // create signature
-if (pub.Verify(sig, m))) {
- // signature is verified
-}
-```
-
-### Aggregate signature
-```
-Init(BN254); // init library
-const int n = 10;
-const string m = "abc";
-SecretKey[] secVec = new SecretKey[n];
-PublicKey[] pubVec = new PublicKey[n];
-Signature[] popVec = new Signature[n];
-Signature[] sigVec = new Signature[n];
-
-for (int i = 0; i < n; i++) {
- secVec[i].SetByCSPRNG(); // init secret key
- pubVec[i] = secVec[i].GetPublicKey(); // get public key
- popVec[i] = secVec[i].GetPop(); // get a proof of Possesion (PoP)
- sigVec[i] = secVec[i].Sign(m); // create signature
-}
-
-SecretKey secAgg;
-PublicKey pubAgg;
-Signature sigAgg;
-for (int i = 0; i < n; i++) {
- // verify PoP
- if (pubVec[i].VerifyPop(popVec[i]))) {
- // error
- return;
- }
- pubAgg.Add(pubVec[i]); // aggregate public key
- sigAgg.Add(sigVec[i]); // aggregate signature
-}
-if (pubAgg.Verify(sigAgg, m)) {
- // aggregated signature is verified
-}
-```
-
-# License
-
-modified new BSD License
-http://opensource.org/licenses/BSD-3-Clause
-
-# Author
-
-(C)2019 MITSUNARI Shigeo(herumi@nifty.com) All rights reserved.
diff --git a/vendor/github.com/byzantine-lab/bls/ffi/go/bls/bls.go b/vendor/github.com/byzantine-lab/bls/ffi/go/bls/bls.go
deleted file mode 100644
index 56bf08039..000000000
--- a/vendor/github.com/byzantine-lab/bls/ffi/go/bls/bls.go
+++ /dev/null
@@ -1,539 +0,0 @@
-package bls
-
-/*
-#cgo bn256 CFLAGS:-DMCLBN_FP_UNIT_SIZE=4
-#cgo bn256 LDFLAGS:${SRCDIR}/../../../lib/libbls256.a
-#cgo bn384 CFLAGS:-DMCLBN_FP_UNIT_SIZE=6
-#cgo bn384 LDFLAGS:${SRCDIR}/../../../lib/libbls384.a
-#cgo bn384_256 CFLAGS:-DMCLBN_FP_UNIT_SIZE=6 -DMCLBN_FR_UNIT_SIZE=4
-#cgo bn384_256 LDFLAGS:${SRCDIR}/../../../lib/libbls384_256.a
-#cgo !bn256,!bn384,!bn384_256 CFLAGS:-DMCLBN_FP_UNIT_SIZE=6
-#cgo !bn256,!bn384,!bn384_256 LDFLAGS:${SRCDIR}/../../../lib/libbls384.a
-#cgo CFLAGS:-I${SRCDIR}/../../../include -I${SRCDIR}/../../../../mcl/include
-#cgo LDFLAGS:${SRCDIR}/../../../../mcl/lib/libmcl.a -lgmpxx -lgmp
-#cgo static LDFLAGS:-static
-typedef unsigned int (*ReadRandFunc)(void *, void *, unsigned int);
-int wrapReadRandCgo(void *self, void *buf, unsigned int n);
-#include <bls/bls.h>
-*/
-import "C"
-import "fmt"
-import "unsafe"
-import "io"
-import "encoding/json"
-
-// Init --
-// call this function before calling all the other operations
-// this function is not thread safe
-func Init(curve int) error {
- err := C.blsInit(C.int(curve), C.MCLBN_COMPILED_TIME_VAR)
- if err != 0 {
- return fmt.Errorf("ERR Init curve=%d", curve)
- }
- return nil
-}
-
-// ID --
-type ID struct {
- v Fr
-}
-
-// getPointer --
-func (id *ID) getPointer() (p *C.blsId) {
- // #nosec
- return (*C.blsId)(unsafe.Pointer(id))
-}
-
-// GetLittleEndian --
-func (id *ID) GetLittleEndian() []byte {
- return id.v.Serialize()
-}
-
-// SetLittleEndian --
-func (id *ID) SetLittleEndian(buf []byte) error {
- return id.v.SetLittleEndian(buf)
-}
-
-// GetHexString --
-func (id *ID) GetHexString() string {
- return id.v.GetString(16)
-}
-
-// GetDecString --
-func (id *ID) GetDecString() string {
- return id.v.GetString(10)
-}
-
-// SetHexString --
-func (id *ID) SetHexString(s string) error {
- return id.v.SetString(s, 16)
-}
-
-// SetDecString --
-func (id *ID) SetDecString(s string) error {
- return id.v.SetString(s, 10)
-}
-
-// IsEqual --
-func (id *ID) IsEqual(rhs *ID) bool {
- if id == nil || rhs == nil {
- return false
- }
- return id.v.IsEqual(&rhs.v)
-}
-
-// MarshalJSON implements json.Marshaller.
-func (id *ID) MarshalJSON() ([]byte, error) {
- return json.Marshal(&struct {
- ID []byte `json:"id"`
- }{
- id.GetLittleEndian(),
- })
-}
-
-// UnmarshalJSON implements json.Unmarshaller.
-func (id *ID) UnmarshalJSON(data []byte) error {
- aux := &struct {
- ID []byte `json:"id"`
- }{}
- if err := json.Unmarshal(data, &aux); err != nil {
- return err
- }
- if err := id.SetLittleEndian(aux.ID); err != nil {
- return err
- }
- return nil
-}
-
-// SecretKey --
-type SecretKey struct {
- v Fr
-}
-
-// getPointer --
-func (sec *SecretKey) getPointer() (p *C.blsSecretKey) {
- // #nosec
- return (*C.blsSecretKey)(unsafe.Pointer(sec))
-}
-
-// GetLittleEndian --
-func (sec *SecretKey) GetLittleEndian() []byte {
- return sec.v.Serialize()
-}
-
-// SetLittleEndian --
-func (sec *SecretKey) SetLittleEndian(buf []byte) error {
- return sec.v.SetLittleEndian(buf)
-}
-
-// SerializeToHexStr --
-func (sec *SecretKey) SerializeToHexStr() string {
- return sec.v.GetString(IoSerializeHexStr)
-}
-
-// DeserializeHexStr --
-func (sec *SecretKey) DeserializeHexStr(s string) error {
- return sec.v.SetString(s, IoSerializeHexStr)
-}
-
-// GetHexString --
-func (sec *SecretKey) GetHexString() string {
- return sec.v.GetString(16)
-}
-
-// GetDecString --
-func (sec *SecretKey) GetDecString() string {
- return sec.v.GetString(10)
-}
-
-// SetHexString --
-func (sec *SecretKey) SetHexString(s string) error {
- return sec.v.SetString(s, 16)
-}
-
-// SetDecString --
-func (sec *SecretKey) SetDecString(s string) error {
- return sec.v.SetString(s, 10)
-}
-
-// IsEqual --
-func (sec *SecretKey) IsEqual(rhs *SecretKey) bool {
- if sec == nil || rhs == nil {
- return false
- }
- return sec.v.IsEqual(&rhs.v)
-}
-
-// SetByCSPRNG --
-func (sec *SecretKey) SetByCSPRNG() {
- sec.v.SetByCSPRNG()
-}
-
-// Add --
-func (sec *SecretKey) Add(rhs *SecretKey) {
- FrAdd(&sec.v, &sec.v, &rhs.v)
-}
-
-// GetMasterSecretKey --
-func (sec *SecretKey) GetMasterSecretKey(k int) (msk []SecretKey) {
- msk = make([]SecretKey, k)
- msk[0] = *sec
- for i := 1; i < k; i++ {
- msk[i].SetByCSPRNG()
- }
- return msk
-}
-
-// MarshalJSON implements json.Marshaller.
-func (sec *SecretKey) MarshalJSON() ([]byte, error) {
- return json.Marshal(&struct {
- SecretKey []byte `json:"secret_key"`
- }{
- sec.GetLittleEndian(),
- })
-}
-
-// UnmarshalJSON implements json.Unmarshaller.
-func (sec *SecretKey) UnmarshalJSON(data []byte) error {
- aux := &struct {
- SecretKey []byte `json:"secret_key"`
- }{}
- if err := json.Unmarshal(data, &aux); err != nil {
- return err
- }
- if err := sec.SetLittleEndian(aux.SecretKey); err != nil {
- return err
- }
- return nil
-}
-
-// GetMasterPublicKey --
-func GetMasterPublicKey(msk []SecretKey) (mpk []PublicKey) {
- n := len(msk)
- mpk = make([]PublicKey, n)
- for i := 0; i < n; i++ {
- mpk[i] = *msk[i].GetPublicKey()
- }
- return mpk
-}
-
-// Set --
-func (sec *SecretKey) Set(msk []SecretKey, id *ID) error {
- // #nosec
- return FrEvaluatePolynomial(&sec.v, *(*[]Fr)(unsafe.Pointer(&msk)), &id.v)
-}
-
-// Recover --
-func (sec *SecretKey) Recover(secVec []SecretKey, idVec []ID) error {
- // #nosec
- return FrLagrangeInterpolation(&sec.v, *(*[]Fr)(unsafe.Pointer(&idVec)), *(*[]Fr)(unsafe.Pointer(&secVec)))
-}
-
-// GetPop --
-func (sec *SecretKey) GetPop() (sign *Sign) {
- sign = new(Sign)
- C.blsGetPop(sign.getPointer(), sec.getPointer())
- return sign
-}
-
-// PublicKey --
-type PublicKey struct {
- v G2
-}
-
-// getPointer --
-func (pub *PublicKey) getPointer() (p *C.blsPublicKey) {
- // #nosec
- return (*C.blsPublicKey)(unsafe.Pointer(pub))
-}
-
-// Serialize --
-func (pub *PublicKey) Serialize() []byte {
- return pub.v.Serialize()
-}
-
-// Deserialize --
-func (pub *PublicKey) Deserialize(buf []byte) error {
- return pub.v.Deserialize(buf)
-}
-
-// SerializeToHexStr --
-func (pub *PublicKey) SerializeToHexStr() string {
- return pub.v.GetString(IoSerializeHexStr)
-}
-
-// DeserializeHexStr --
-func (pub *PublicKey) DeserializeHexStr(s string) error {
- return pub.v.SetString(s, IoSerializeHexStr)
-}
-
-// GetHexString --
-func (pub *PublicKey) GetHexString() string {
- return pub.v.GetString(16)
-}
-
-// SetHexString --
-func (pub *PublicKey) SetHexString(s string) error {
- return pub.v.SetString(s, 16)
-}
-
-// IsEqual --
-func (pub *PublicKey) IsEqual(rhs *PublicKey) bool {
- if pub == nil || rhs == nil {
- return false
- }
- return pub.v.IsEqual(&rhs.v)
-}
-
-// Add --
-func (pub *PublicKey) Add(rhs *PublicKey) {
- G2Add(&pub.v, &pub.v, &rhs.v)
-}
-
-// Set --
-func (pub *PublicKey) Set(mpk []PublicKey, id *ID) error {
- // #nosec
- return G2EvaluatePolynomial(&pub.v, *(*[]G2)(unsafe.Pointer(&mpk)), &id.v)
-}
-
-// Recover --
-func (pub *PublicKey) Recover(pubVec []PublicKey, idVec []ID) error {
- // #nosec
- return G2LagrangeInterpolation(&pub.v, *(*[]Fr)(unsafe.Pointer(&idVec)), *(*[]G2)(unsafe.Pointer(&pubVec)))
-}
-
-// MarshalJSON implements json.Marshaller.
-func (pub *PublicKey) MarshalJSON() ([]byte, error) {
- return json.Marshal(&struct {
- PublicKey []byte `json:"public_key"`
- }{
- pub.Serialize(),
- })
-}
-
-// UnmarshalJSON implements json.Unmarshaller.
-func (pub *PublicKey) UnmarshalJSON(data []byte) error {
- aux := &struct {
- PublicKey []byte `json:"public_key"`
- }{}
- if err := json.Unmarshal(data, &aux); err != nil {
- return err
- }
- if err := pub.Deserialize(aux.PublicKey); err != nil {
- return err
- }
- return nil
-}
-
-// Sign --
-type Sign struct {
- v G1
-}
-
-// getPointer --
-func (sign *Sign) getPointer() (p *C.blsSignature) {
- // #nosec
- return (*C.blsSignature)(unsafe.Pointer(sign))
-}
-
-// Serialize --
-func (sign *Sign) Serialize() []byte {
- return sign.v.Serialize()
-}
-
-// Deserialize --
-func (sign *Sign) Deserialize(buf []byte) error {
- return sign.v.Deserialize(buf)
-}
-
-// SerializeToHexStr --
-func (sign *Sign) SerializeToHexStr() string {
- return sign.v.GetString(IoSerializeHexStr)
-}
-
-// DeserializeHexStr --
-func (sign *Sign) DeserializeHexStr(s string) error {
- return sign.v.SetString(s, IoSerializeHexStr)
-}
-
-// GetHexString --
-func (sign *Sign) GetHexString() string {
- return sign.v.GetString(16)
-}
-
-// SetHexString --
-func (sign *Sign) SetHexString(s string) error {
- return sign.v.SetString(s, 16)
-}
-
-// IsEqual --
-func (sign *Sign) IsEqual(rhs *Sign) bool {
- if sign == nil || rhs == nil {
- return false
- }
- return sign.v.IsEqual(&rhs.v)
-}
-
-// GetPublicKey --
-func (sec *SecretKey) GetPublicKey() (pub *PublicKey) {
- pub = new(PublicKey)
- C.blsGetPublicKey(pub.getPointer(), sec.getPointer())
- return pub
-}
-
-// Sign -- Constant Time version
-func (sec *SecretKey) Sign(m string) (sign *Sign) {
- sign = new(Sign)
- buf := []byte(m)
- // #nosec
- C.blsSign(sign.getPointer(), sec.getPointer(), unsafe.Pointer(&buf[0]), C.size_t(len(buf)))
- return sign
-}
-
-// Add --
-func (sign *Sign) Add(rhs *Sign) {
- C.blsSignatureAdd(sign.getPointer(), rhs.getPointer())
-}
-
-// Recover --
-func (sign *Sign) Recover(signVec []Sign, idVec []ID) error {
- // #nosec
- return G1LagrangeInterpolation(&sign.v, *(*[]Fr)(unsafe.Pointer(&idVec)), *(*[]G1)(unsafe.Pointer(&signVec)))
-}
-
-// Verify --
-func (sign *Sign) Verify(pub *PublicKey, m string) bool {
- buf := []byte(m)
- // #nosec
- return C.blsVerify(sign.getPointer(), pub.getPointer(), unsafe.Pointer(&buf[0]), C.size_t(len(buf))) == 1
-}
-
-// VerifyPop --
-func (sign *Sign) VerifyPop(pub *PublicKey) bool {
- if pub.getPointer() == nil {
- return false
- }
- return C.blsVerifyPop(sign.getPointer(), pub.getPointer()) == 1
-}
-
-// MarshalJSON implements json.Marshaller.
-func (sign *Sign) MarshalJSON() ([]byte, error) {
- return json.Marshal(&struct {
- Sign []byte `json:"sign"`
- }{
- sign.Serialize(),
- })
-}
-
-// UnmarshalJSON implements json.Unmarshaller.
-func (sign *Sign) UnmarshalJSON(data []byte) error {
- aux := &struct {
- Sign []byte `json:"sign"`
- }{}
- if err := json.Unmarshal(data, &aux); err != nil {
- return err
- }
- if err := sign.Deserialize(aux.Sign); err != nil {
- return err
- }
- return nil
-}
-
-// DHKeyExchange --
-func DHKeyExchange(sec *SecretKey, pub *PublicKey) (out PublicKey) {
- C.blsDHKeyExchange(out.getPointer(), sec.getPointer(), pub.getPointer())
- return out
-}
-
-// HashAndMapToSignature --
-func HashAndMapToSignature(buf []byte) *Sign {
- sig := new(Sign)
- err := sig.v.HashAndMapTo(buf)
- if err == nil {
- return sig
- } else {
- return nil
- }
-}
-
-// VerifyPairing --
-func VerifyPairing(X *Sign, Y *Sign, pub *PublicKey) bool {
- if X.getPointer() == nil || Y.getPointer() == nil || pub.getPointer() == nil {
- return false
- }
- return C.blsVerifyPairing(X.getPointer(), Y.getPointer(), pub.getPointer()) == 1
-}
-
-// SignHash --
-func (sec *SecretKey) SignHash(hash []byte) (sign *Sign) {
- sign = new(Sign)
- // #nosec
- err := C.blsSignHash(sign.getPointer(), sec.getPointer(), unsafe.Pointer(&hash[0]), C.size_t(len(hash)))
- if err == 0 {
- return sign
- } else {
- return nil
- }
-}
-
-// VerifyHash --
-func (sign *Sign) VerifyHash(pub *PublicKey, hash []byte) bool {
- if pub.getPointer() == nil {
- return false
- }
- // #nosec
- return C.blsVerifyHash(sign.getPointer(), pub.getPointer(), unsafe.Pointer(&hash[0]), C.size_t(len(hash))) == 1
-}
-
-func Min(x, y int) int {
- if x < y {
- return x
- }
- return y
-}
-
-// VerifyAggregateHashes --
-func (sign *Sign) VerifyAggregateHashes(pubVec []PublicKey, hash [][]byte) bool {
- hashByte := GetOpUnitSize() * 8
- n := len(hash)
- h := make([]byte, n*hashByte)
- for i := 0; i < n; i++ {
- hn := len(hash[i])
- copy(h[i*hashByte:(i+1)*hashByte], hash[i][0:Min(hn, hashByte)])
- }
- if pubVec[0].getPointer() == nil {
- return false
- }
- return C.blsVerifyAggregatedHashes(sign.getPointer(), pubVec[0].getPointer(), unsafe.Pointer(&h[0]), C.size_t(hashByte), C.size_t(n)) == 1
-}
-
-///
-
-var s_randReader io.Reader
-
-func createSlice(buf *C.char, n C.uint) []byte {
- size := int(n)
- return (*[1 << 30]byte)(unsafe.Pointer(buf))[:size:size]
-}
-
-// this function can't be put in callback.go
-//export wrapReadRandGo
-func wrapReadRandGo(buf *C.char, n C.uint) C.uint {
- slice := createSlice(buf, n)
- ret, err := s_randReader.Read(slice)
- if ret == int(n) && err == nil {
- return n
- }
- return 0
-}
-
-// SetRandFunc --
-func SetRandFunc(randReader io.Reader) {
- s_randReader = randReader
- if randReader != nil {
- C.blsSetRandFunc(nil, C.ReadRandFunc(unsafe.Pointer(C.wrapReadRandCgo)))
- } else {
- // use default random generator
- C.blsSetRandFunc(nil, C.ReadRandFunc(unsafe.Pointer(nil)))
- }
-}
diff --git a/vendor/github.com/byzantine-lab/bls/ffi/go/bls/callback.go b/vendor/github.com/byzantine-lab/bls/ffi/go/bls/callback.go
deleted file mode 100644
index ba73a5e15..000000000
--- a/vendor/github.com/byzantine-lab/bls/ffi/go/bls/callback.go
+++ /dev/null
@@ -1,12 +0,0 @@
-package bls
-
-/*
-// exported from bls.go
-unsigned int wrapReadRandGo(void *buf, unsigned int n);
-int wrapReadRandCgo(void *self, void *buf, unsigned int n)
-{
- (void)self;
- return wrapReadRandGo(buf, n);
-}
-*/
-import "C"
diff --git a/vendor/github.com/byzantine-lab/bls/ffi/go/bls/dummy.cpp b/vendor/github.com/byzantine-lab/bls/ffi/go/bls/dummy.cpp
deleted file mode 100644
index a5103a1c5..000000000
--- a/vendor/github.com/byzantine-lab/bls/ffi/go/bls/dummy.cpp
+++ /dev/null
@@ -1,3 +0,0 @@
-// This is a dummy source file which forces cgo to use the C++ linker instead
-// of the default C linker. We can therefore eliminate non-portable linker
-// flags such as -lstdc++, which is likely to break on FreeBSD and OpenBSD.
diff --git a/vendor/github.com/byzantine-lab/bls/ffi/go/bls/mcl.go b/vendor/github.com/byzantine-lab/bls/ffi/go/bls/mcl.go
deleted file mode 100644
index ca8d7f02b..000000000
--- a/vendor/github.com/byzantine-lab/bls/ffi/go/bls/mcl.go
+++ /dev/null
@@ -1,646 +0,0 @@
-package bls
-
-/*
-#cgo bn256 CFLAGS:-DMCLBN_FP_UNIT_SIZE=4
-#cgo bn384 CFLAGS:-DMCLBN_FP_UNIT_SIZE=6
-#cgo bn384_256 CFLAGS:-DMCLBN_FP_UNIT_SIZE=6 -DMCLBN_FR_UNIT_SIZE=4
-#cgo !bn256,!bn384,!bn384_256 CFLAGS:-DMCLBN_FP_UNIT_SIZE=6
-#include <mcl/bn.h>
-*/
-import "C"
-import "fmt"
-import "unsafe"
-
-// CurveFp254BNb -- 254 bit curve
-const CurveFp254BNb = C.mclBn_CurveFp254BNb
-
-// CurveFp382_1 -- 382 bit curve 1
-const CurveFp382_1 = C.mclBn_CurveFp382_1
-
-// CurveFp382_2 -- 382 bit curve 2
-const CurveFp382_2 = C.mclBn_CurveFp382_2
-
-// BLS12_381
-const BLS12_381 = C.MCL_BLS12_381
-
-// IoSerializeHexStr
-const IoSerializeHexStr = C.MCLBN_IO_SERIALIZE_HEX_STR
-
-// GetFrUnitSize() --
-func GetFrUnitSize() int {
- return int(C.MCLBN_FR_UNIT_SIZE)
-}
-
-// GetFpUnitSize() --
-// same as GetMaxOpUnitSize()
-func GetFpUnitSize() int {
- return int(C.MCLBN_FP_UNIT_SIZE)
-}
-
-// GetMaxOpUnitSize --
-func GetMaxOpUnitSize() int {
- return int(C.MCLBN_FP_UNIT_SIZE)
-}
-
-// GetOpUnitSize --
-// the length of Fr is GetOpUnitSize() * 8 bytes
-func GetOpUnitSize() int {
- return int(C.mclBn_getOpUnitSize())
-}
-
-// GetCurveOrder --
-// return the order of G1
-func GetCurveOrder() string {
- buf := make([]byte, 1024)
- // #nosec
- n := C.mclBn_getCurveOrder((*C.char)(unsafe.Pointer(&buf[0])), C.size_t(len(buf)))
- if n == 0 {
- panic("implementation err. size of buf is small")
- }
- return string(buf[:n])
-}
-
-// GetFieldOrder --
-// return the characteristic of the field where a curve is defined
-func GetFieldOrder() string {
- buf := make([]byte, 1024)
- // #nosec
- n := C.mclBn_getFieldOrder((*C.char)(unsafe.Pointer(&buf[0])), C.size_t(len(buf)))
- if n == 0 {
- panic("implementation err. size of buf is small")
- }
- return string(buf[:n])
-}
-
-// Fr --
-type Fr struct {
- v C.mclBnFr
-}
-
-// getPointer --
-func (x *Fr) getPointer() (p *C.mclBnFr) {
- // #nosec
- return (*C.mclBnFr)(unsafe.Pointer(x))
-}
-
-// Clear --
-func (x *Fr) Clear() {
- // #nosec
- C.mclBnFr_clear(x.getPointer())
-}
-
-// SetInt64 --
-func (x *Fr) SetInt64(v int64) {
- // #nosec
- C.mclBnFr_setInt(x.getPointer(), C.int64_t(v))
-}
-
-// SetString --
-func (x *Fr) SetString(s string, base int) error {
- buf := []byte(s)
- // #nosec
- err := C.mclBnFr_setStr(x.getPointer(), (*C.char)(unsafe.Pointer(&buf[0])), C.size_t(len(buf)), C.int(base))
- if err != 0 {
- return fmt.Errorf("err mclBnFr_setStr %x", err)
- }
- return nil
-}
-
-// Deserialize --
-func (x *Fr) Deserialize(buf []byte) error {
- // #nosec
- err := C.mclBnFr_deserialize(x.getPointer(), unsafe.Pointer(&buf[0]), C.size_t(len(buf)))
- if err == 0 {
- return fmt.Errorf("err mclBnFr_deserialize %x", buf)
- }
- return nil
-}
-
-// SetLittleEndian --
-func (x *Fr) SetLittleEndian(buf []byte) error {
- // #nosec
- err := C.mclBnFr_setLittleEndian(x.getPointer(), unsafe.Pointer(&buf[0]), C.size_t(len(buf)))
- if err != 0 {
- return fmt.Errorf("err mclBnFr_setLittleEndian %x", err)
- }
- return nil
-}
-
-// IsEqual --
-func (x *Fr) IsEqual(rhs *Fr) bool {
- return C.mclBnFr_isEqual(x.getPointer(), rhs.getPointer()) == 1
-}
-
-// IsZero --
-func (x *Fr) IsZero() bool {
- return C.mclBnFr_isZero(x.getPointer()) == 1
-}
-
-// IsOne --
-func (x *Fr) IsOne() bool {
- return C.mclBnFr_isOne(x.getPointer()) == 1
-}
-
-// SetByCSPRNG --
-func (x *Fr) SetByCSPRNG() {
- err := C.mclBnFr_setByCSPRNG(x.getPointer())
- if err != 0 {
- panic("err mclBnFr_setByCSPRNG")
- }
-}
-
-// SetHashOf --
-func (x *Fr) SetHashOf(buf []byte) bool {
- // #nosec
- return C.mclBnFr_setHashOf(x.getPointer(), unsafe.Pointer(&buf[0]), C.size_t(len(buf))) == 0
-}
-
-// GetString --
-func (x *Fr) GetString(base int) string {
- buf := make([]byte, 2048)
- // #nosec
- n := C.mclBnFr_getStr((*C.char)(unsafe.Pointer(&buf[0])), C.size_t(len(buf)), x.getPointer(), C.int(base))
- if n == 0 {
- panic("err mclBnFr_getStr")
- }
- return string(buf[:n])
-}
-
-// Serialize --
-func (x *Fr) Serialize() []byte {
- buf := make([]byte, 2048)
- // #nosec
- n := C.mclBnFr_serialize(unsafe.Pointer(&buf[0]), C.size_t(len(buf)), x.getPointer())
- if n == 0 {
- panic("err mclBnFr_serialize")
- }
- return buf[:n]
-}
-
-// FrNeg --
-func FrNeg(out *Fr, x *Fr) {
- C.mclBnFr_neg(out.getPointer(), x.getPointer())
-}
-
-// FrInv --
-func FrInv(out *Fr, x *Fr) {
- C.mclBnFr_inv(out.getPointer(), x.getPointer())
-}
-
-// FrAdd --
-func FrAdd(out *Fr, x *Fr, y *Fr) {
- C.mclBnFr_add(out.getPointer(), x.getPointer(), y.getPointer())
-}
-
-// FrSub --
-func FrSub(out *Fr, x *Fr, y *Fr) {
- C.mclBnFr_sub(out.getPointer(), x.getPointer(), y.getPointer())
-}
-
-// FrMul --
-func FrMul(out *Fr, x *Fr, y *Fr) {
- C.mclBnFr_mul(out.getPointer(), x.getPointer(), y.getPointer())
-}
-
-// FrDiv --
-func FrDiv(out *Fr, x *Fr, y *Fr) {
- C.mclBnFr_div(out.getPointer(), x.getPointer(), y.getPointer())
-}
-
-// G1 --
-type G1 struct {
- v C.mclBnG1
-}
-
-// getPointer --
-func (x *G1) getPointer() (p *C.mclBnG1) {
- // #nosec
- return (*C.mclBnG1)(unsafe.Pointer(x))
-}
-
-// Clear --
-func (x *G1) Clear() {
- // #nosec
- C.mclBnG1_clear(x.getPointer())
-}
-
-// SetString --
-func (x *G1) SetString(s string, base int) error {
- buf := []byte(s)
- // #nosec
- err := C.mclBnG1_setStr(x.getPointer(), (*C.char)(unsafe.Pointer(&buf[0])), C.size_t(len(buf)), C.int(base))
- if err != 0 {
- return fmt.Errorf("err mclBnG1_setStr %x", err)
- }
- return nil
-}
-
-// Deserialize --
-func (x *G1) Deserialize(buf []byte) error {
- // #nosec
- err := C.mclBnG1_deserialize(x.getPointer(), unsafe.Pointer(&buf[0]), C.size_t(len(buf)))
- if err == 0 {
- return fmt.Errorf("err mclBnG1_deserialize %x", buf)
- }
- return nil
-}
-
-// IsEqual --
-func (x *G1) IsEqual(rhs *G1) bool {
- return C.mclBnG1_isEqual(x.getPointer(), rhs.getPointer()) == 1
-}
-
-// IsZero --
-func (x *G1) IsZero() bool {
- return C.mclBnG1_isZero(x.getPointer()) == 1
-}
-
-// HashAndMapTo --
-func (x *G1) HashAndMapTo(buf []byte) error {
- // #nosec
- err := C.mclBnG1_hashAndMapTo(x.getPointer(), unsafe.Pointer(&buf[0]), C.size_t(len(buf)))
- if err != 0 {
- return fmt.Errorf("err mclBnG1_hashAndMapTo %x", err)
- }
- return nil
-}
-
-// GetString --
-func (x *G1) GetString(base int) string {
- buf := make([]byte, 2048)
- // #nosec
- n := C.mclBnG1_getStr((*C.char)(unsafe.Pointer(&buf[0])), C.size_t(len(buf)), x.getPointer(), C.int(base))
- if n == 0 {
- panic("err mclBnG1_getStr")
- }
- return string(buf[:n])
-}
-
-// Serialize --
-func (x *G1) Serialize() []byte {
- buf := make([]byte, 2048)
- // #nosec
- n := C.mclBnG1_serialize(unsafe.Pointer(&buf[0]), C.size_t(len(buf)), x.getPointer())
- if n == 0 {
- panic("err mclBnG1_serialize")
- }
- return buf[:n]
-}
-
-// G1Neg --
-func G1Neg(out *G1, x *G1) {
- C.mclBnG1_neg(out.getPointer(), x.getPointer())
-}
-
-// G1Dbl --
-func G1Dbl(out *G1, x *G1) {
- C.mclBnG1_dbl(out.getPointer(), x.getPointer())
-}
-
-// G1Add --
-func G1Add(out *G1, x *G1, y *G1) {
- C.mclBnG1_add(out.getPointer(), x.getPointer(), y.getPointer())
-}
-
-// G1Sub --
-func G1Sub(out *G1, x *G1, y *G1) {
- C.mclBnG1_sub(out.getPointer(), x.getPointer(), y.getPointer())
-}
-
-// G1Mul --
-func G1Mul(out *G1, x *G1, y *Fr) {
- C.mclBnG1_mul(out.getPointer(), x.getPointer(), y.getPointer())
-}
-
-// G1MulCT -- constant time (depending on bit lengh of y)
-func G1MulCT(out *G1, x *G1, y *Fr) {
- C.mclBnG1_mulCT(out.getPointer(), x.getPointer(), y.getPointer())
-}
-
-// G2 --
-type G2 struct {
- v C.mclBnG2
-}
-
-// getPointer --
-func (x *G2) getPointer() (p *C.mclBnG2) {
- // #nosec
- return (*C.mclBnG2)(unsafe.Pointer(x))
-}
-
-// Clear --
-func (x *G2) Clear() {
- // #nosec
- C.mclBnG2_clear(x.getPointer())
-}
-
-// SetString --
-func (x *G2) SetString(s string, base int) error {
- buf := []byte(s)
- // #nosec
- err := C.mclBnG2_setStr(x.getPointer(), (*C.char)(unsafe.Pointer(&buf[0])), C.size_t(len(buf)), C.int(base))
- if err != 0 {
- return fmt.Errorf("err mclBnG2_setStr %x", err)
- }
- return nil
-}
-
-// Deserialize --
-func (x *G2) Deserialize(buf []byte) error {
- // #nosec
- err := C.mclBnG2_deserialize(x.getPointer(), unsafe.Pointer(&buf[0]), C.size_t(len(buf)))
- if err == 0 {
- return fmt.Errorf("err mclBnG2_deserialize %x", buf)
- }
- return nil
-}
-
-// IsEqual --
-func (x *G2) IsEqual(rhs *G2) bool {
- return C.mclBnG2_isEqual(x.getPointer(), rhs.getPointer()) == 1
-}
-
-// IsZero --
-func (x *G2) IsZero() bool {
- return C.mclBnG2_isZero(x.getPointer()) == 1
-}
-
-// HashAndMapTo --
-func (x *G2) HashAndMapTo(buf []byte) error {
- // #nosec
- err := C.mclBnG2_hashAndMapTo(x.getPointer(), unsafe.Pointer(&buf[0]), C.size_t(len(buf)))
- if err != 0 {
- return fmt.Errorf("err mclBnG2_hashAndMapTo %x", err)
- }
- return nil
-}
-
-// GetString --
-func (x *G2) GetString(base int) string {
- buf := make([]byte, 2048)
- // #nosec
- n := C.mclBnG2_getStr((*C.char)(unsafe.Pointer(&buf[0])), C.size_t(len(buf)), x.getPointer(), C.int(base))
- if n == 0 {
- panic("err mclBnG2_getStr")
- }
- return string(buf[:n])
-}
-
-// Serialize --
-func (x *G2) Serialize() []byte {
- buf := make([]byte, 2048)
- // #nosec
- n := C.mclBnG2_serialize(unsafe.Pointer(&buf[0]), C.size_t(len(buf)), x.getPointer())
- if n == 0 {
- panic("err mclBnG2_serialize")
- }
- return buf[:n]
-}
-
-// G2Neg --
-func G2Neg(out *G2, x *G2) {
- C.mclBnG2_neg(out.getPointer(), x.getPointer())
-}
-
-// G2Dbl --
-func G2Dbl(out *G2, x *G2) {
- C.mclBnG2_dbl(out.getPointer(), x.getPointer())
-}
-
-// G2Add --
-func G2Add(out *G2, x *G2, y *G2) {
- C.mclBnG2_add(out.getPointer(), x.getPointer(), y.getPointer())
-}
-
-// G2Sub --
-func G2Sub(out *G2, x *G2, y *G2) {
- C.mclBnG2_sub(out.getPointer(), x.getPointer(), y.getPointer())
-}
-
-// G2Mul --
-func G2Mul(out *G2, x *G2, y *Fr) {
- C.mclBnG2_mul(out.getPointer(), x.getPointer(), y.getPointer())
-}
-
-// GT --
-type GT struct {
- v C.mclBnGT
-}
-
-// getPointer --
-func (x *GT) getPointer() (p *C.mclBnGT) {
- // #nosec
- return (*C.mclBnGT)(unsafe.Pointer(x))
-}
-
-// Clear --
-func (x *GT) Clear() {
- // #nosec
- C.mclBnGT_clear(x.getPointer())
-}
-
-// SetInt64 --
-func (x *GT) SetInt64(v int64) {
- // #nosec
- C.mclBnGT_setInt(x.getPointer(), C.int64_t(v))
-}
-
-// SetString --
-func (x *GT) SetString(s string, base int) error {
- buf := []byte(s)
- // #nosec
- err := C.mclBnGT_setStr(x.getPointer(), (*C.char)(unsafe.Pointer(&buf[0])), C.size_t(len(buf)), C.int(base))
- if err != 0 {
- return fmt.Errorf("err mclBnGT_setStr %x", err)
- }
- return nil
-}
-
-// Deserialize --
-func (x *GT) Deserialize(buf []byte) error {
- // #nosec
- err := C.mclBnGT_deserialize(x.getPointer(), unsafe.Pointer(&buf[0]), C.size_t(len(buf)))
- if err == 0 {
- return fmt.Errorf("err mclBnGT_deserialize %x", buf)
- }
- return nil
-}
-
-// IsEqual --
-func (x *GT) IsEqual(rhs *GT) bool {
- return C.mclBnGT_isEqual(x.getPointer(), rhs.getPointer()) == 1
-}
-
-// IsZero --
-func (x *GT) IsZero() bool {
- return C.mclBnGT_isZero(x.getPointer()) == 1
-}
-
-// IsOne --
-func (x *GT) IsOne() bool {
- return C.mclBnGT_isOne(x.getPointer()) == 1
-}
-
-// GetString --
-func (x *GT) GetString(base int) string {
- buf := make([]byte, 2048)
- // #nosec
- n := C.mclBnGT_getStr((*C.char)(unsafe.Pointer(&buf[0])), C.size_t(len(buf)), x.getPointer(), C.int(base))
- if n == 0 {
- panic("err mclBnGT_getStr")
- }
- return string(buf[:n])
-}
-
-// Serialize --
-func (x *GT) Serialize() []byte {
- buf := make([]byte, 2048)
- // #nosec
- n := C.mclBnGT_serialize(unsafe.Pointer(&buf[0]), C.size_t(len(buf)), x.getPointer())
- if n == 0 {
- panic("err mclBnGT_serialize")
- }
- return buf[:n]
-}
-
-// GTNeg --
-func GTNeg(out *GT, x *GT) {
- C.mclBnGT_neg(out.getPointer(), x.getPointer())
-}
-
-// GTInv --
-func GTInv(out *GT, x *GT) {
- C.mclBnGT_inv(out.getPointer(), x.getPointer())
-}
-
-// GTAdd --
-func GTAdd(out *GT, x *GT, y *GT) {
- C.mclBnGT_add(out.getPointer(), x.getPointer(), y.getPointer())
-}
-
-// GTSub --
-func GTSub(out *GT, x *GT, y *GT) {
- C.mclBnGT_sub(out.getPointer(), x.getPointer(), y.getPointer())
-}
-
-// GTMul --
-func GTMul(out *GT, x *GT, y *GT) {
- C.mclBnGT_mul(out.getPointer(), x.getPointer(), y.getPointer())
-}
-
-// GTDiv --
-func GTDiv(out *GT, x *GT, y *GT) {
- C.mclBnGT_div(out.getPointer(), x.getPointer(), y.getPointer())
-}
-
-// GTPow --
-func GTPow(out *GT, x *GT, y *Fr) {
- C.mclBnGT_pow(out.getPointer(), x.getPointer(), y.getPointer())
-}
-
-// Pairing --
-func Pairing(out *GT, x *G1, y *G2) {
- C.mclBn_pairing(out.getPointer(), x.getPointer(), y.getPointer())
-}
-
-// FinalExp --
-func FinalExp(out *GT, x *GT) {
- C.mclBn_finalExp(out.getPointer(), x.getPointer())
-}
-
-// MillerLoop --
-func MillerLoop(out *GT, x *G1, y *G2) {
- C.mclBn_millerLoop(out.getPointer(), x.getPointer(), y.getPointer())
-}
-
-// GetUint64NumToPrecompute --
-func GetUint64NumToPrecompute() int {
- return int(C.mclBn_getUint64NumToPrecompute())
-}
-
-// PrecomputeG2 --
-func PrecomputeG2(Qbuf []uint64, Q *G2) {
- // #nosec
- C.mclBn_precomputeG2((*C.uint64_t)(unsafe.Pointer(&Qbuf[0])), Q.getPointer())
-}
-
-// PrecomputedMillerLoop --
-func PrecomputedMillerLoop(out *GT, P *G1, Qbuf []uint64) {
- // #nosec
- C.mclBn_precomputedMillerLoop(out.getPointer(), P.getPointer(), (*C.uint64_t)(unsafe.Pointer(&Qbuf[0])))
-}
-
-// PrecomputedMillerLoop2 --
-func PrecomputedMillerLoop2(out *GT, P1 *G1, Q1buf []uint64, P2 *G1, Q2buf []uint64) {
- // #nosec
- C.mclBn_precomputedMillerLoop2(out.getPointer(), P1.getPointer(), (*C.uint64_t)(unsafe.Pointer(&Q1buf[0])), P1.getPointer(), (*C.uint64_t)(unsafe.Pointer(&Q1buf[0])))
-}
-
-// FrEvaluatePolynomial -- y = c[0] + c[1] * x + c[2] * x^2 + ...
-func FrEvaluatePolynomial(y *Fr, c []Fr, x *Fr) error {
- // #nosec
- err := C.mclBn_FrEvaluatePolynomial(y.getPointer(), (*C.mclBnFr)(unsafe.Pointer(&c[0])), (C.size_t)(len(c)), x.getPointer())
- if err != 0 {
- return fmt.Errorf("err mclBn_FrEvaluatePolynomial")
- }
- return nil
-}
-
-// G1EvaluatePolynomial -- y = c[0] + c[1] * x + c[2] * x^2 + ...
-func G1EvaluatePolynomial(y *G1, c []G1, x *Fr) error {
- // #nosec
- err := C.mclBn_G1EvaluatePolynomial(y.getPointer(), (*C.mclBnG1)(unsafe.Pointer(&c[0])), (C.size_t)(len(c)), x.getPointer())
- if err != 0 {
- return fmt.Errorf("err mclBn_G1EvaluatePolynomial")
- }
- return nil
-}
-
-// G2EvaluatePolynomial -- y = c[0] + c[1] * x + c[2] * x^2 + ...
-func G2EvaluatePolynomial(y *G2, c []G2, x *Fr) error {
- // #nosec
- err := C.mclBn_G2EvaluatePolynomial(y.getPointer(), (*C.mclBnG2)(unsafe.Pointer(&c[0])), (C.size_t)(len(c)), x.getPointer())
- if err != 0 {
- return fmt.Errorf("err mclBn_G2EvaluatePolynomial")
- }
- return nil
-}
-
-// FrLagrangeInterpolation --
-func FrLagrangeInterpolation(out *Fr, xVec []Fr, yVec []Fr) error {
- if len(xVec) != len(yVec) {
- return fmt.Errorf("err FrLagrangeInterpolation:bad size")
- }
- // #nosec
- err := C.mclBn_FrLagrangeInterpolation(out.getPointer(), (*C.mclBnFr)(unsafe.Pointer(&xVec[0])), (*C.mclBnFr)(unsafe.Pointer(&yVec[0])), (C.size_t)(len(xVec)))
- if err != 0 {
- return fmt.Errorf("err FrLagrangeInterpolation")
- }
- return nil
-}
-
-// G1LagrangeInterpolation --
-func G1LagrangeInterpolation(out *G1, xVec []Fr, yVec []G1) error {
- if len(xVec) != len(yVec) {
- return fmt.Errorf("err G1LagrangeInterpolation:bad size")
- }
- // #nosec
- err := C.mclBn_G1LagrangeInterpolation(out.getPointer(), (*C.mclBnFr)(unsafe.Pointer(&xVec[0])), (*C.mclBnG1)(unsafe.Pointer(&yVec[0])), (C.size_t)(len(xVec)))
- if err != 0 {
- return fmt.Errorf("err G1LagrangeInterpolation")
- }
- return nil
-}
-
-// G2LagrangeInterpolation --
-func G2LagrangeInterpolation(out *G2, xVec []Fr, yVec []G2) error {
- if len(xVec) != len(yVec) {
- return fmt.Errorf("err G2LagrangeInterpolation:bad size")
- }
- // #nosec
- err := C.mclBn_G2LagrangeInterpolation(out.getPointer(), (*C.mclBnFr)(unsafe.Pointer(&xVec[0])), (*C.mclBnG2)(unsafe.Pointer(&yVec[0])), (C.size_t)(len(xVec)))
- if err != 0 {
- return fmt.Errorf("err G2LagrangeInterpolation")
- }
- return nil
-}