ecdsa-quirks 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/src/index.js CHANGED
@@ -47,7 +47,7 @@ function quirk(message1, message2, eip191) {
47
47
  signature2: sig2,
48
48
  };
49
49
  }
50
- function printQuired(message1, message2, quirked) {
50
+ function printQuirked(message1, message2, quirked) {
51
51
  console.log("Private key: " + quirked.privateKey);
52
52
  console.log("Address: " + quirked.address);
53
53
  console.log();
@@ -66,12 +66,18 @@ async function main() {
66
66
  .option("--m2, --message2 <MSG>", "The second message")
67
67
  .option("--eip191", "Whether to EIP-191 hash the messages before signing", false)
68
68
  .showHelpAfterError();
69
- const parsed = await program.parseAsync(process.argv);
70
- const opts = parsed.opts();
71
- if (!opts.message1 || !opts.message2) {
72
- throw new Error("Specify both messages to generate the signature for");
69
+ try {
70
+ const parsed = await program.parseAsync(process.argv);
71
+ const opts = parsed.opts();
72
+ if (!opts.message1 || !opts.message2) {
73
+ throw new Error("Specify both messages to generate the signature for");
74
+ }
75
+ const quirked = quirk(opts.message1, opts.message2, opts.eip191);
76
+ printQuirked(opts.message1, opts.message2, quirked);
77
+ }
78
+ catch (err) {
79
+ const msg = err instanceof Error ? err.message : String(err);
80
+ throw new Error(msg);
73
81
  }
74
- const quirked = quirk(opts.message1, opts.message2, opts.eip191);
75
- printQuired(opts.message1, opts.message2, quirked);
76
82
  }
77
83
  void main();
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "ecdsa-quirks",
3
3
  "description": "Generate the same ECDSA signature for two different messages",
4
- "version": "0.1.0",
4
+ "version": "0.1.1",
5
5
  "type": "module",
6
6
  "main": "dist/src/index.js",
7
7
  "types": "dist/src/index.d.ts",
package/src/index.ts CHANGED
@@ -67,7 +67,7 @@ function quirk(message1: string, message2: string, eip191: boolean): Quirked {
67
67
  };
68
68
  }
69
69
 
70
- function printQuired(message1: string, message2: string, quirked: Quirked) {
70
+ function printQuirked(message1: string, message2: string, quirked: Quirked) {
71
71
  console.log("Private key: " + quirked.privateKey);
72
72
  console.log("Address: " + quirked.address);
73
73
 
@@ -92,19 +92,25 @@ async function main(): Promise<void> {
92
92
  .option("--eip191", "Whether to EIP-191 hash the messages before signing", false)
93
93
  .showHelpAfterError();
94
94
 
95
- const parsed = await program.parseAsync(process.argv);
96
- const opts = parsed.opts<{
97
- message1: string;
98
- message2: string;
99
- eip191: boolean;
100
- }>();
95
+ try {
96
+ const parsed = await program.parseAsync(process.argv);
97
+ const opts = parsed.opts<{
98
+ message1: string;
99
+ message2: string;
100
+ eip191: boolean;
101
+ }>();
101
102
 
102
- if (!opts.message1 || !opts.message2) {
103
- throw new Error("Specify both messages to generate the signature for");
104
- }
103
+ if (!opts.message1 || !opts.message2) {
104
+ throw new Error("Specify both messages to generate the signature for");
105
+ }
106
+
107
+ const quirked = quirk(opts.message1, opts.message2, opts.eip191);
108
+ printQuirked(opts.message1, opts.message2, quirked);
109
+ } catch (err) {
110
+ const msg = err instanceof Error ? err.message : String(err);
105
111
 
106
- const quirked = quirk(opts.message1, opts.message2, opts.eip191);
107
- printQuired(opts.message1, opts.message2, quirked);
112
+ throw new Error(msg);
113
+ }
108
114
  }
109
115
 
110
116
  void main();