-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNNostr.cs
53 lines (47 loc) · 1.11 KB
/
NNostr.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
using BenchmarkDotNet.Attributes;
using NBitcoin;
using NBitcoin.Secp256k1;
using NNostr.Client;
public class NNostrClient
{
private ECPrivKey privateKey;
private NostrEvent? signedEvent;
public NNostrClient()
{
privateKey = ECPrivKey.Create(RandomUtils.GetBytes(32));
}
[GlobalSetup]
public async Task Setup()
{
var unsignedEvent = new NostrEvent()
{
Kind = 1,
Content = ""
};
signedEvent = await unsignedEvent.ComputeIdAndSignAsync(privateKey);
}
[Benchmark]
public void Create()
{
ECPrivKey.Create(RandomUtils.GetBytes(32));
}
[Benchmark]
public async Task ComputeIdAndSignAsync()
{
var unsignedEvent = new NostrEvent()
{
Kind = 1,
Content = ""
};
await unsignedEvent.ComputeIdAndSignAsync(privateKey);
}
[Benchmark]
public void Verify()
{
if (signedEvent == null)
{
throw new Exception();
}
signedEvent.Verify();
}
}