-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathalgs.go
46 lines (41 loc) · 988 Bytes
/
algs.go
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
package main
import (
"fmt"
"os"
"github.com/bwesterb/go-xmssmt"
"github.com/dustin/go-humanize"
"github.com/olekukonko/tablewriter"
"github.com/urfave/cli"
)
func cmdAlgs(c *cli.Context) error {
table := tablewriter.NewWriter(os.Stdout)
table.SetHeader([]string{
"name",
"oid",
"#sigs",
"sigSize",
"cache size"})
names := xmssmt.ListNames()
if c.Bool("non-std") {
names = xmssmt.ListNames2()
}
for _, name := range names {
ctx, _ := xmssmt.NewContextFromName2(name)
var cacheSize uint64
if ctx.MT() {
cacheSize = uint64((ctx.Params().D+1)*ctx.Params().N) * (1 << uint64(ctx.Params().FullHeight/ctx.Params().D))
} else {
cacheSize = (1 << uint64(ctx.Params().FullHeight)) *
uint64(ctx.Params().N)
}
table.Append([]string{
name,
fmt.Sprintf("%d", ctx.Oid()),
fmt.Sprintf("2^%d", ctx.Params().FullHeight),
humanize.Bytes(uint64(ctx.SignatureSize())),
humanize.Bytes(uint64(cacheSize)),
})
}
table.Render()
return nil
}