Skip to content

Commit 11c5d3a

Browse files
committed
simplified sample
1 parent 91c5328 commit 11c5d3a

1 file changed

Lines changed: 24 additions & 49 deletions

File tree

samples/Examples/Program.cs

Lines changed: 24 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -18,61 +18,36 @@ static void Main(string[] args)
1818
.BorderColor(Color.Blue)
1919
.Header("[yellow]Welcome[/]"));
2020

21-
try
22-
{
23-
// Initialize the OQS library
24-
LibOqs.Initialize();
25-
26-
var demo = AnsiConsole.Prompt(
27-
new SelectionPrompt<string>()
28-
.Title("Choose the [green]demo[/] to run?")
29-
.AddChoices([
30-
"ML-KEM (Key Encapsulation)",
31-
"ML-DSA (Digital Signature)",
21+
var demo = AnsiConsole.Prompt(
22+
new SelectionPrompt<string>()
23+
.Title("Choose the [green]demo[/] to run?")
24+
.AddChoices([
25+
"ML-KEM (Key Encapsulation)",
26+
"ML-DSA (Digital Signature)",
3227
"Signed Key Exchange",
3328
"Algorithm Comparison",
3429
"Exit"
35-
]));
30+
]));
3631

37-
switch (demo)
38-
{
39-
case "ML-KEM (Key Encapsulation)":
40-
LibOqsDemo.RunMlKem();
41-
break;
42-
case "ML-DSA (Digital Signature)":
43-
LibOqsDemo.RunMlDsa();
44-
break;
45-
case "Signed Key Exchange":
46-
LibOqsDemo.RunSignedKeyExchange();
47-
break;
48-
case "Algorithm Comparison":
49-
LibOqsDemo.RunAlgorithmComparison();
50-
break;
51-
case "Exit":
52-
return;
53-
}
54-
}
55-
catch (OqsException ex)
32+
switch (demo)
5633
{
57-
AnsiConsole.Write(
58-
new Panel($"[red]Error:[/] {ex.Message}")
59-
.BorderColor(Color.Red)
60-
.Header("[red]LibOQS Error[/]"));
61-
62-
AnsiConsole.WriteLine();
63-
AnsiConsole.Write(
64-
new Panel("Please ensure the liboqs shared library is installed and accessible.\nSee BUILD.md for installation instructions.")
65-
.BorderColor(Color.Yellow)
66-
.Header("[yellow]Solution[/]"));
67-
}
68-
catch (Exception ex)
69-
{
70-
AnsiConsole.WriteException(ex);
71-
}
72-
finally
73-
{
74-
LibOqs.Cleanup();
34+
case "ML-KEM (Key Encapsulation)":
35+
LibOqsDemo.RunMlKem();
36+
break;
37+
case "ML-DSA (Digital Signature)":
38+
LibOqsDemo.RunMlDsa();
39+
break;
40+
case "Signed Key Exchange":
41+
LibOqsDemo.RunSignedKeyExchange();
42+
break;
43+
case "Algorithm Comparison":
44+
LibOqsDemo.RunAlgorithmComparison();
45+
break;
46+
case "Exit":
47+
return;
7548
}
49+
50+
LibOqs.Cleanup();
7651
}
7752
}
7853

0 commit comments

Comments
 (0)