示例#1
0
        static BlsProxy()
        {
            Platform = GetPlatform();

            int initResult = Platform switch
            {
                OsPlatform.Windows => Win64Lib.blsInit(MclBls12_381CurveId, MclBnCompileTimeVar),
                OsPlatform.Linux => PosixLib.blsInit(MclBls12_381CurveId, MclBnCompileTimeVar),
                OsPlatform.Mac => MacLib.blsInit(MclBls12_381CurveId, MclBnCompileTimeVar),
                _ => throw new ArgumentOutOfRangeException(Platform.ToString())
            };

            if (initResult != 0)
            {
                throw new CryptographicException($"Unable to load the BLS lib: {initResult}");
            }

            switch (Platform)
            {
            case OsPlatform.Windows:
                Win64Lib.blsSetETHserialization(1);
                break;

            case OsPlatform.Mac:
                MacLib.blsSetETHserialization(1);
                break;

            case OsPlatform.Linux:
                PosixLib.blsSetETHserialization(1);
                break;

            default:
                throw new ArgumentOutOfRangeException(Platform.ToString());
            }
        }