@ocap/mcrypto 1.27.15 → 1.28.0
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/esm/crypter/aes-legacy.d.ts +8 -6
- package/esm/crypter/aes-legacy.js +27 -24
- package/esm/crypter/aes.d.ts +9 -7
- package/esm/crypter/aes.js +27 -25
- package/esm/crypter/rsa-browserify.d.ts +7 -6
- package/esm/crypter/rsa-browserify.js +34 -31
- package/esm/crypter/rsa.d.ts +11 -9
- package/esm/crypter/rsa.js +31 -28
- package/esm/encode.d.ts +12 -8
- package/esm/encode.js +13 -18
- package/esm/hasher/keccak.d.ts +8 -5
- package/esm/hasher/keccak.js +37 -36
- package/esm/hasher/sha2.d.ts +8 -5
- package/esm/hasher/sha2.js +42 -40
- package/esm/hasher/sha3.d.ts +8 -5
- package/esm/hasher/sha3.js +37 -36
- package/esm/index.d.ts +148 -143
- package/esm/index.js +172 -209
- package/esm/protocols/crypter.d.ts +3 -1
- package/esm/protocols/crypter.js +7 -4
- package/esm/protocols/hasher.d.ts +3 -1
- package/esm/protocols/hasher.js +7 -4
- package/esm/protocols/signer.d.ts +3 -1
- package/esm/protocols/signer.js +7 -4
- package/esm/signer/ed25519.d.ts +49 -46
- package/esm/signer/ed25519.js +80 -80
- package/esm/signer/ethereum.d.ts +11 -8
- package/esm/signer/ethereum.js +34 -34
- package/esm/signer/passkey.d.ts +21 -18
- package/esm/signer/passkey.js +49 -58
- package/esm/signer/secp256k1.d.ts +35 -32
- package/esm/signer/secp256k1.js +80 -93
- package/lib/_virtual/rolldown_runtime.js +29 -0
- package/lib/crypter/aes-legacy.d.ts +8 -6
- package/lib/crypter/aes-legacy.js +35 -52
- package/lib/crypter/aes.d.ts +9 -7
- package/lib/crypter/aes.js +29 -29
- package/lib/crypter/rsa-browserify.d.ts +7 -6
- package/lib/crypter/rsa-browserify.js +36 -33
- package/lib/crypter/rsa.d.ts +11 -9
- package/lib/crypter/rsa.js +33 -32
- package/lib/encode.d.ts +12 -8
- package/lib/encode.js +14 -21
- package/lib/hasher/keccak.d.ts +8 -5
- package/lib/hasher/keccak.js +40 -41
- package/lib/hasher/sha2.d.ts +8 -5
- package/lib/hasher/sha2.js +43 -42
- package/lib/hasher/sha3.d.ts +8 -5
- package/lib/hasher/sha3.js +40 -41
- package/lib/index.d.ts +148 -143
- package/lib/index.js +177 -216
- package/lib/protocols/crypter.d.ts +3 -1
- package/lib/protocols/crypter.js +10 -9
- package/lib/protocols/hasher.d.ts +3 -1
- package/lib/protocols/hasher.js +10 -9
- package/lib/protocols/signer.d.ts +3 -1
- package/lib/protocols/signer.js +10 -9
- package/lib/signer/ed25519.d.ts +49 -46
- package/lib/signer/ed25519.js +85 -86
- package/lib/signer/ethereum.d.ts +11 -8
- package/lib/signer/ethereum.js +38 -39
- package/lib/signer/passkey.d.ts +21 -18
- package/lib/signer/passkey.js +51 -63
- package/lib/signer/secp256k1.d.ts +35 -32
- package/lib/signer/secp256k1.js +85 -99
- package/package.json +25 -10
package/lib/signer/ed25519.js
CHANGED
|
@@ -1,88 +1,87 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
const
|
|
13
|
-
const ed25519 = tweetnacl_1.default.sign;
|
|
1
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
2
|
+
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.js');
|
|
3
|
+
const require_encode = require('../encode.js');
|
|
4
|
+
const require_protocols_signer = require('../protocols/signer.js');
|
|
5
|
+
let _ocap_util = require("@ocap/util");
|
|
6
|
+
let randombytes = require("randombytes");
|
|
7
|
+
randombytes = require_rolldown_runtime.__toESM(randombytes);
|
|
8
|
+
let tweetnacl = require("tweetnacl");
|
|
9
|
+
tweetnacl = require_rolldown_runtime.__toESM(tweetnacl);
|
|
10
|
+
|
|
11
|
+
//#region src/signer/ed25519.ts
|
|
12
|
+
const ed25519 = tweetnacl.default.sign;
|
|
14
13
|
/**
|
|
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
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
14
|
+
* Signer implementation for ed25519, based on `tweetnacl`
|
|
15
|
+
*
|
|
16
|
+
* @class Ed25519Signer
|
|
17
|
+
*/
|
|
18
|
+
var Ed25519Signer = class extends require_protocols_signer.default {
|
|
19
|
+
constructor() {
|
|
20
|
+
super();
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* @public
|
|
24
|
+
* @typedefKeyPairType
|
|
25
|
+
* @prop {string} publicKey - publicKey in hex format
|
|
26
|
+
* @prop {string} secretKey - secretKey in hex format
|
|
27
|
+
* @memberof Ed25519Signer
|
|
28
|
+
*/
|
|
29
|
+
/**
|
|
30
|
+
* Generate random secret/public key pair
|
|
31
|
+
*
|
|
32
|
+
* @param {Buffer|Uint8Array} [userSeed=undefined]
|
|
33
|
+
* @param {string} [encoding='hex']
|
|
34
|
+
* @returns {KeyPairType}
|
|
35
|
+
* @memberof Ed25519Signer
|
|
36
|
+
*/
|
|
37
|
+
genKeyPair(encoding = "hex", userSeed) {
|
|
38
|
+
const seed = userSeed ? (0, _ocap_util.toUint8Array)(userSeed) : new Uint8Array((0, randombytes.default)(32));
|
|
39
|
+
if (seed.byteLength !== 32) throw new Error("Invalid seed to generate key pair");
|
|
40
|
+
const keyPair = ed25519.keyPair.fromSeed(seed);
|
|
41
|
+
keyPair.publicKey = require_encode.encode(keyPair.publicKey, encoding);
|
|
42
|
+
keyPair.secretKey = require_encode.encode(keyPair.secretKey, encoding);
|
|
43
|
+
return keyPair;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Get publicKey from secretKey
|
|
47
|
+
*
|
|
48
|
+
* @param {hex|buffer|base58|Uint8Array} sk - can be either a hex encoded string or a buffer
|
|
49
|
+
* @returns {string} hex encoded publicKey
|
|
50
|
+
*/
|
|
51
|
+
getPublicKey(sk, encoding = "hex") {
|
|
52
|
+
const skBytes = (0, _ocap_util.toUint8Array)(sk);
|
|
53
|
+
const pk = ed25519.keyPair.fromSecretKey(skBytes).publicKey;
|
|
54
|
+
return require_encode.encode(pk, encoding);
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Sign a message and get the signature hex
|
|
58
|
+
*
|
|
59
|
+
* @param {hex|base58|buffer|Uint8Array} message
|
|
60
|
+
* @param {hex|base58|buffer|Uint8Array} sk
|
|
61
|
+
* @returns {string} hex encoded signature
|
|
62
|
+
*/
|
|
63
|
+
sign(message, sk, encoding = "hex") {
|
|
64
|
+
const skBytes = (0, _ocap_util.toUint8Array)(sk);
|
|
65
|
+
const messageBytes = (0, _ocap_util.toUint8Array)(message);
|
|
66
|
+
return require_encode.encode(ed25519.detached(messageBytes, skBytes), encoding);
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Verify if a signature is valid
|
|
70
|
+
*
|
|
71
|
+
* @param {string|buffer} message
|
|
72
|
+
* @param {string|buffer} signature
|
|
73
|
+
* @param {string|buffer} pk
|
|
74
|
+
* @returns {bool}
|
|
75
|
+
*/
|
|
76
|
+
verify(message, signature, pk) {
|
|
77
|
+
const pkBytes = (0, _ocap_util.toUint8Array)(pk);
|
|
78
|
+
const messageBytes = (0, _ocap_util.toUint8Array)(message);
|
|
79
|
+
const signatureBytes = (0, _ocap_util.toUint8Array)(signature);
|
|
80
|
+
return ed25519.detached.verify(messageBytes, signatureBytes, pkBytes);
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
var ed25519_default = new Ed25519Signer();
|
|
84
|
+
|
|
85
|
+
//#endregion
|
|
87
86
|
exports.Ed25519Signer = Ed25519Signer;
|
|
88
|
-
exports.default =
|
|
87
|
+
exports.default = ed25519_default;
|
package/lib/signer/ethereum.d.ts
CHANGED
|
@@ -1,16 +1,19 @@
|
|
|
1
|
-
import { Secp256k1Signer } from
|
|
1
|
+
import { Secp256k1Signer } from "./secp256k1.js";
|
|
2
|
+
|
|
3
|
+
//#region src/signer/ethereum.d.ts
|
|
4
|
+
|
|
2
5
|
/**
|
|
3
6
|
* Signer implementation for secp256k1, based on `elliptic`, and ethereum compatible
|
|
4
7
|
*
|
|
5
8
|
* @class EthereumSigner
|
|
6
9
|
*/
|
|
7
10
|
declare class EthereumSigner extends Secp256k1Signer {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
pkHasFormatPrefix: boolean;
|
|
12
|
+
constructor();
|
|
13
|
+
ethHash(data: string): string;
|
|
14
|
+
ethSign(data: string, privateKey: string): string;
|
|
15
|
+
ethRecover(data: string, signature: string): string;
|
|
13
16
|
}
|
|
14
17
|
declare const _default: EthereumSigner;
|
|
15
|
-
|
|
16
|
-
export { EthereumSigner };
|
|
18
|
+
//#endregion
|
|
19
|
+
export { EthereumSigner, _default as default };
|
package/lib/signer/ethereum.js
CHANGED
|
@@ -1,41 +1,40 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
const hash_1 = __importDefault(require("eth-lib/lib/hash"));
|
|
12
|
-
const util_1 = require("@ocap/util");
|
|
13
|
-
const secp256k1_1 = require("./secp256k1");
|
|
1
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
2
|
+
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.js');
|
|
3
|
+
const require_signer_secp256k1 = require('./secp256k1.js');
|
|
4
|
+
let _ocap_util = require("@ocap/util");
|
|
5
|
+
let eth_lib_lib_account = require("eth-lib/lib/account");
|
|
6
|
+
eth_lib_lib_account = require_rolldown_runtime.__toESM(eth_lib_lib_account);
|
|
7
|
+
let eth_lib_lib_hash = require("eth-lib/lib/hash");
|
|
8
|
+
eth_lib_lib_hash = require_rolldown_runtime.__toESM(eth_lib_lib_hash);
|
|
9
|
+
|
|
10
|
+
//#region src/signer/ethereum.ts
|
|
14
11
|
/**
|
|
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
|
-
|
|
12
|
+
* Signer implementation for secp256k1, based on `elliptic`, and ethereum compatible
|
|
13
|
+
*
|
|
14
|
+
* @class EthereumSigner
|
|
15
|
+
*/
|
|
16
|
+
var EthereumSigner = class extends require_signer_secp256k1.Secp256k1Signer {
|
|
17
|
+
constructor() {
|
|
18
|
+
super();
|
|
19
|
+
this.pkHasFormatPrefix = false;
|
|
20
|
+
}
|
|
21
|
+
ethHash(data) {
|
|
22
|
+
const messageBytes = (0, _ocap_util.hexToBytes)((0, _ocap_util.isHexStrict)(data) ? data : (0, _ocap_util.utf8ToHex)(data));
|
|
23
|
+
const messageBuffer = Buffer.from(messageBytes);
|
|
24
|
+
const preamble = `\x19Ethereum Signed Message:\n${messageBytes.length}`;
|
|
25
|
+
const preambleBuffer = Buffer.from(preamble);
|
|
26
|
+
const ethMessage = Buffer.concat([preambleBuffer, messageBuffer]);
|
|
27
|
+
return eth_lib_lib_hash.default.keccak256s(ethMessage);
|
|
28
|
+
}
|
|
29
|
+
ethSign(data, privateKey) {
|
|
30
|
+
return eth_lib_lib_account.default.sign(data, privateKey);
|
|
31
|
+
}
|
|
32
|
+
ethRecover(data, signature) {
|
|
33
|
+
return eth_lib_lib_account.default.recover(data, signature);
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
var ethereum_default = new EthereumSigner();
|
|
37
|
+
|
|
38
|
+
//#endregion
|
|
40
39
|
exports.EthereumSigner = EthereumSigner;
|
|
41
|
-
exports.default =
|
|
40
|
+
exports.default = ethereum_default;
|
package/lib/signer/passkey.d.ts
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import _default$1 from "../protocols/signer.js";
|
|
2
|
+
import { BytesType, EncodingType, KeyPairType } from "@ocap/util";
|
|
3
|
+
|
|
4
|
+
//#region src/signer/passkey.d.ts
|
|
5
|
+
|
|
3
6
|
/**
|
|
4
7
|
* Signer implementation for passkey, based on `@simplewebauthn/server`
|
|
5
8
|
* Since passkey supports only verification, we do not need to implement the sign method
|
|
@@ -7,21 +10,21 @@ import BaseSigner from '../protocols/signer';
|
|
|
7
10
|
*
|
|
8
11
|
* @class PasskeySigner
|
|
9
12
|
*/
|
|
10
|
-
declare class PasskeySigner extends
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
13
|
+
declare class PasskeySigner extends _default$1 {
|
|
14
|
+
constructor();
|
|
15
|
+
genKeyPair(encoding?: EncodingType, userSeed?: BytesType): KeyPairType;
|
|
16
|
+
getPublicKey(sk: BytesType, encoding?: EncodingType): BytesType;
|
|
17
|
+
sign(message: BytesType, sk: BytesType, encoding?: EncodingType): BytesType;
|
|
18
|
+
/**
|
|
19
|
+
* Verify if a signature is valid
|
|
20
|
+
*
|
|
21
|
+
* @param {string|buffer} challenge - the challenge sent to passkey, should be txHash when signing a transaction
|
|
22
|
+
* @param {string|buffer} signature - signature from passkey
|
|
23
|
+
* @param {string|buffer} pk - credentialPublicKey from passkey, must be parsed with `parseAuthenticatorData`
|
|
24
|
+
* @returns {bool}
|
|
25
|
+
*/
|
|
26
|
+
verify(challenge: BytesType, signature: BytesType, pk: BytesType, extra: string): Promise<boolean>;
|
|
24
27
|
}
|
|
25
28
|
declare const _default: PasskeySigner;
|
|
26
|
-
|
|
27
|
-
export { PasskeySigner };
|
|
29
|
+
//#endregion
|
|
30
|
+
export { PasskeySigner, _default as default };
|
package/lib/signer/passkey.js
CHANGED
|
@@ -1,65 +1,53 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const util_1 = require("@ocap/util");
|
|
9
|
-
const helpers_1 = require("@simplewebauthn/server/helpers");
|
|
10
|
-
const signer_1 = __importDefault(require("../protocols/signer"));
|
|
1
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
2
|
+
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.js');
|
|
3
|
+
const require_protocols_signer = require('../protocols/signer.js');
|
|
4
|
+
let _ocap_util = require("@ocap/util");
|
|
5
|
+
let _simplewebauthn_server_helpers = require("@simplewebauthn/server/helpers");
|
|
6
|
+
|
|
7
|
+
//#region src/signer/passkey.ts
|
|
11
8
|
/**
|
|
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
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
// throw new Error('Invalid client data type');
|
|
56
|
-
// }
|
|
57
|
-
return (0, helpers_1.verifySignature)({
|
|
58
|
-
signature: helpers_1.isoBase64URL.toBuffer(typeof signature === 'string' ? signature : (0, util_1.toBase64)(signature)),
|
|
59
|
-
data: helpers_1.isoUint8Array.concat([authDataBuffer, clientDataHash]),
|
|
60
|
-
credentialPublicKey: pk,
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
}
|
|
9
|
+
* Signer implementation for passkey, based on `@simplewebauthn/server`
|
|
10
|
+
* Since passkey supports only verification, we do not need to implement the sign method
|
|
11
|
+
* And passkeys can used multiple algorithms, we do not need to implement the algorithm selection
|
|
12
|
+
*
|
|
13
|
+
* @class PasskeySigner
|
|
14
|
+
*/
|
|
15
|
+
var PasskeySigner = class extends require_protocols_signer.default {
|
|
16
|
+
constructor() {
|
|
17
|
+
super();
|
|
18
|
+
}
|
|
19
|
+
genKeyPair(encoding = "hex", userSeed) {
|
|
20
|
+
throw new Error("Not supported");
|
|
21
|
+
}
|
|
22
|
+
getPublicKey(sk, encoding = "hex") {
|
|
23
|
+
throw new Error("Not supported");
|
|
24
|
+
}
|
|
25
|
+
sign(message, sk, encoding = "hex") {
|
|
26
|
+
throw new Error("Not supported");
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Verify if a signature is valid
|
|
30
|
+
*
|
|
31
|
+
* @param {string|buffer} challenge - the challenge sent to passkey, should be txHash when signing a transaction
|
|
32
|
+
* @param {string|buffer} signature - signature from passkey
|
|
33
|
+
* @param {string|buffer} pk - credentialPublicKey from passkey, must be parsed with `parseAuthenticatorData`
|
|
34
|
+
* @returns {bool}
|
|
35
|
+
*/
|
|
36
|
+
async verify(challenge, signature, pk, extra) {
|
|
37
|
+
const parsed = JSON.parse(extra);
|
|
38
|
+
if (!parsed.authenticatorData || !parsed.clientDataJSON) throw new Error("extra.authenticatorData or extra.clientDataJSON is required for passkey signature verification");
|
|
39
|
+
const authDataBuffer = (0, _ocap_util.toBuffer)((0, _ocap_util.fromBase64)(parsed.authenticatorData));
|
|
40
|
+
const clientDataHash = await (0, _simplewebauthn_server_helpers.toHash)(_simplewebauthn_server_helpers.isoBase64URL.toBuffer(parsed.clientDataJSON));
|
|
41
|
+
if ((0, _simplewebauthn_server_helpers.decodeClientDataJSON)(parsed.clientDataJSON).challenge !== (0, _ocap_util.toBase64)(challenge)) throw new Error("challenge mismatch for passkey signature");
|
|
42
|
+
return (0, _simplewebauthn_server_helpers.verifySignature)({
|
|
43
|
+
signature: _simplewebauthn_server_helpers.isoBase64URL.toBuffer(typeof signature === "string" ? signature : (0, _ocap_util.toBase64)(signature)),
|
|
44
|
+
data: _simplewebauthn_server_helpers.isoUint8Array.concat([authDataBuffer, clientDataHash]),
|
|
45
|
+
credentialPublicKey: pk
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
var passkey_default = new PasskeySigner();
|
|
50
|
+
|
|
51
|
+
//#endregion
|
|
64
52
|
exports.PasskeySigner = PasskeySigner;
|
|
65
|
-
exports.default =
|
|
53
|
+
exports.default = passkey_default;
|
|
@@ -1,39 +1,42 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import _default$1 from "../protocols/signer.js";
|
|
2
|
+
import { BytesType, EncodingType, KeyPairType } from "@ocap/util";
|
|
3
|
+
|
|
4
|
+
//#region src/signer/secp256k1.d.ts
|
|
5
|
+
|
|
3
6
|
/**
|
|
4
7
|
* Signer implementation for secp256k1, based on `elliptic`
|
|
5
8
|
*
|
|
6
9
|
* @class Secp256k1Signer
|
|
7
10
|
*/
|
|
8
|
-
declare class Secp256k1Signer extends
|
|
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
|
-
|
|
11
|
+
declare class Secp256k1Signer extends _default$1 {
|
|
12
|
+
pkCompressed: boolean;
|
|
13
|
+
pkHasFormatPrefix: boolean;
|
|
14
|
+
constructor();
|
|
15
|
+
isValidSK(sk: Uint8Array): boolean;
|
|
16
|
+
/**
|
|
17
|
+
* @public
|
|
18
|
+
* @typedefKeyPairType
|
|
19
|
+
* @prop {string} publicKey - publicKey in hex format
|
|
20
|
+
* @prop {string} secretKey - secretKey in hex format
|
|
21
|
+
* @memberof Secp256k1Signer
|
|
22
|
+
*/
|
|
23
|
+
/**
|
|
24
|
+
* Generate random secret/public key pair
|
|
25
|
+
*/
|
|
26
|
+
genKeyPair(encoding?: EncodingType): KeyPairType;
|
|
27
|
+
/**
|
|
28
|
+
* Get publicKey from secretKey
|
|
29
|
+
*/
|
|
30
|
+
getPublicKey(sk: BytesType, encoding?: EncodingType): BytesType;
|
|
31
|
+
/**
|
|
32
|
+
* Sign a message and get the signature hex
|
|
33
|
+
*/
|
|
34
|
+
sign(message: BytesType, sk: BytesType, encoding?: EncodingType): BytesType;
|
|
35
|
+
/**
|
|
36
|
+
* Verify if a signature is valid
|
|
37
|
+
*/
|
|
38
|
+
verify(message: BytesType, signature: BytesType, pk: BytesType): boolean;
|
|
36
39
|
}
|
|
37
40
|
declare const _default: Secp256k1Signer;
|
|
38
|
-
|
|
39
|
-
export { Secp256k1Signer };
|
|
41
|
+
//#endregion
|
|
42
|
+
export { Secp256k1Signer, _default as default };
|