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 +13 -7
- package/package.json +1 -1
- package/src/index.ts +18 -12
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
|
|
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
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
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
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
|
|
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
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
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
|
-
|
|
103
|
-
|
|
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
|
-
|
|
107
|
-
|
|
112
|
+
throw new Error(msg);
|
|
113
|
+
}
|
|
108
114
|
}
|
|
109
115
|
|
|
110
116
|
void main();
|