Slight reorganization. Add elliptic curves from X9.62.
[u/mdw/catacomb] / utils / ectab-canonify.pl
diff --git a/utils/ectab-canonify.pl b/utils/ectab-canonify.pl
new file mode 100644 (file)
index 0000000..e153214
--- /dev/null
@@ -0,0 +1,16 @@
+#! /usr/bin/perl
+
+while (<>) {
+  print, next if /^\s*(\#|$)/;
+  @F = split;
+  $k = shift @F;
+  print, next if $k eq "curve";
+  $n = lc(join("", @F));
+  if ($n =~ m"^/") {
+    $p = join(" + ", map("2^$_", split(m"/", substr($n, 1))));
+    $n = `calc 'printf("%x", $p)'`;
+  } elsif ($n =~ /../ && $n !~ /^0x/) {
+    $n = "0x$n";
+  }
+  print "  $k $n\n";
+}