public async Task <ISecretKey> Generate(IMasterKey masterKey, IPublicKey publicKey, IAttributes attributes) { try { var masterKeyFile = await LocalHost.WriteFileAsync(masterKey.Value); var publicKeyFile = await LocalHost.WriteFileAsync(publicKey.Value); var privateKeyFile = LocalHost.GetRandomFilename(); await LocalHost.RunProcessAsync("cpabe-keygen", $"-o {privateKeyFile} {publicKeyFile} {masterKeyFile} {attributes.Get()}"); var privateKeyBytes = await LocalHost.ReadFileAsync(privateKeyFile); var privateKey = new MockSecretKey() { Value = privateKeyBytes }; File.Delete(masterKeyFile); File.Delete(publicKeyFile); File.Delete(privateKeyFile); return(privateKey); } catch (Exception exception) { throw new ABESchemeException($"Error has occured during secret key generation: {attributes.Get()}", exception); } }
private async Task CheckKeys() { if (publicKey == null) { var keys = await cpabeCenter.Setup(); publicKey = keys.PublicKey; masterKey = keys.MasterKey; } }