Skip to content

Commit cd06cc6

Browse files
committed
revise to use uncompressed in getPublicKey(priv, false) namedGroup
1 parent eb01700 commit cd06cc6

File tree

3 files changed

+40
-5
lines changed

3 files changed

+40
-5
lines changed

deno.json

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@tls/enum",
3-
"version": "0.8.6",
3+
"version": "0.8.7",
44
"exports": "./src/mod.ts",
55
"publish": {
66
"exclude": ["dist/"]
@@ -13,10 +13,11 @@
1313
}
1414
},
1515
"imports": {
16-
"@noble/curves": "npm:@noble/curves@^1.7.0",
17-
"@noble/hashes": "npm:@noble/hashes@^1.6.1",
16+
"@noble/curves": "npm:@noble/curves@^1.8.1",
17+
"@noble/hashes": "npm:@noble/hashes@^1.7.1",
1818
"@peculiar/x509": "npm:@peculiar/x509@^1.12.3",
1919
"@std/assert": "jsr:@std/assert@^1.0.2",
20-
"@tls/struct": "jsr:@tls/struct@^0.3.8"
20+
"@tls/struct": "jsr:@tls/struct@^0.3.8",
21+
"elliptic": "npm:elliptic@^6.6.1"
2122
}
2223
}

src/namedgroup.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ export class NamedGroup extends Enum {
103103
*/
104104
get publicKey() {
105105
if (this.#publicKey) return this.#publicKey;
106-
this.#publicKey = this.keyGen?.getPublicKey(this.privateKey);
106+
this.#publicKey = this.keyGen?.getPublicKey(this.privateKey, false);
107107
return this.#publicKey;
108108
}
109109

test/namedgroup_test.js

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
import { assertEquals } from "jsr:@std/assert";
22
import { NamedGroup } from "../src/namedgroup.js";
3+
import { p384 } from "@noble/curves/p384";
4+
import elliptic from "elliptic"
5+
import { safeuint8array } from "../src/dep.ts";
36

47
Deno.test(
58
"NamedGroup",
@@ -18,3 +21,34 @@ Deno.test(
1821

1922
}
2023
)
24+
25+
const secP384R1 = NamedGroup.SECP384R1;
26+
const pub = secP384R1.publicKey;
27+
const pri = secP384R1.privateKey;
28+
29+
const keyPair = await crypto.subtle.generateKey(
30+
{ name: "ECDSA", namedCurve: "P-384" },
31+
true,
32+
["sign", "verify"]
33+
);
34+
35+
const publicKeyJwk = await crypto.subtle.exportKey("raw", keyPair.publicKey);
36+
37+
38+
var EC = elliptic.ec;
39+
var ec = new EC('p384');
40+
41+
// generate keys
42+
var key1 = ec.genKeyPair();
43+
var key2 = ec.genKeyPair();
44+
var publicKey1 = key1.getPublic()
45+
var publicKey1Buffer = safeuint8array(0x04, publicKey1.getX().toBuffer(), publicKey1.getY().toBuffer());
46+
var publicKey2Buffer = publicKey1.encode('buffer');
47+
48+
49+
var shared1 = key1.derive(key2.getPublic());
50+
51+
const priv = p384.utils.randomPrivateKey();
52+
const publ = p384.getPublicKey(priv, false)
53+
54+

0 commit comments

Comments
 (0)