@ckb-ccc/core 1.11.4 → 1.12.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/CHANGELOG.md +38 -0
- package/dist/ckb/transaction.d.ts +160 -29
- package/dist/ckb/transaction.d.ts.map +1 -1
- package/dist/ckb/transaction.js +185 -39
- package/dist/client/jsonRpc/client.d.ts +1 -1
- package/dist/client/jsonRpc/client.d.ts.map +1 -1
- package/dist/client/jsonRpc/client.js +4 -1
- package/dist/client/jsonRpc/transformers.d.ts +1 -1
- package/dist/client/jsonRpc/transformers.d.ts.map +1 -1
- package/dist/client/jsonRpc/transformers.js +2 -1
- package/dist/jsonRpc/requestor.js +1 -1
- package/dist/molecule/entity.d.ts +3 -3
- package/dist/molecule/entity.d.ts.map +1 -1
- package/dist/molecule/entity.js +1 -1
- package/dist/signer/btc/verify.d.ts +21 -0
- package/dist/signer/btc/verify.d.ts.map +1 -1
- package/dist/signer/btc/verify.js +38 -2
- package/dist/signer/doge/signerDogePrivateKey.d.ts.map +1 -1
- package/dist/signer/doge/signerDogePrivateKey.js +2 -2
- package/dist/signer/doge/verify.d.ts +12 -1
- package/dist/signer/doge/verify.d.ts.map +1 -1
- package/dist/signer/doge/verify.js +15 -5
- package/dist/signer/nostr/verify.js +4 -4
- package/dist/signer/signer/index.d.ts +14 -5
- package/dist/signer/signer/index.d.ts.map +1 -1
- package/dist/signer/signer/index.js +19 -11
- package/dist.commonjs/ckb/transaction.d.ts +160 -29
- package/dist.commonjs/ckb/transaction.d.ts.map +1 -1
- package/dist.commonjs/ckb/transaction.js +187 -40
- package/dist.commonjs/client/jsonRpc/client.d.ts +1 -1
- package/dist.commonjs/client/jsonRpc/client.d.ts.map +1 -1
- package/dist.commonjs/client/jsonRpc/client.js +4 -1
- package/dist.commonjs/client/jsonRpc/transformers.d.ts +1 -1
- package/dist.commonjs/client/jsonRpc/transformers.d.ts.map +1 -1
- package/dist.commonjs/client/jsonRpc/transformers.js +2 -1
- package/dist.commonjs/jsonRpc/requestor.js +1 -1
- package/dist.commonjs/molecule/entity.d.ts +3 -3
- package/dist.commonjs/molecule/entity.d.ts.map +1 -1
- package/dist.commonjs/molecule/entity.js +1 -1
- package/dist.commonjs/signer/btc/verify.d.ts +21 -0
- package/dist.commonjs/signer/btc/verify.d.ts.map +1 -1
- package/dist.commonjs/signer/btc/verify.js +40 -2
- package/dist.commonjs/signer/doge/signerDogePrivateKey.d.ts.map +1 -1
- package/dist.commonjs/signer/doge/signerDogePrivateKey.js +2 -2
- package/dist.commonjs/signer/doge/verify.d.ts +12 -1
- package/dist.commonjs/signer/doge/verify.d.ts.map +1 -1
- package/dist.commonjs/signer/doge/verify.js +15 -4
- package/dist.commonjs/signer/nostr/verify.js +5 -5
- package/dist.commonjs/signer/signer/index.d.ts +14 -5
- package/dist.commonjs/signer/signer/index.d.ts.map +1 -1
- package/dist.commonjs/signer/signer/index.js +21 -13
- package/package.json +3 -4
- package/{prettier.config.mjs → prettier.config.cjs} +2 -4
- package/src/ckb/transaction.ts +254 -80
- package/src/client/jsonRpc/client.ts +5 -2
- package/src/client/jsonRpc/transformers.ts +6 -1
- package/src/jsonRpc/requestor.ts +2 -2
- package/src/molecule/entity.ts +10 -9
- package/src/signer/btc/verify.ts +52 -3
- package/src/signer/doge/signerDogePrivateKey.ts +2 -2
- package/src/signer/doge/verify.ts +23 -7
- package/src/signer/nostr/verify.ts +4 -4
- package/src/signer/signer/index.ts +20 -10
- /package/{vitest.config.ts → vitest.config.mts} +0 -0
|
@@ -119,7 +119,10 @@ export class ClientJsonRpc extends Client {
|
|
|
119
119
|
* @param validator - "passthrough": Disable validation. "well_known_scripts_only": Only accept well known scripts in the transaction.
|
|
120
120
|
* @returns Transaction hash.
|
|
121
121
|
*/
|
|
122
|
-
this.sendTransactionNoCache = this.buildSender("send_transaction", [
|
|
122
|
+
this.sendTransactionNoCache = this.buildSender("send_transaction", [
|
|
123
|
+
JsonRpcTransformers.transactionFrom,
|
|
124
|
+
(validator) => validator ?? undefined,
|
|
125
|
+
], hexFrom);
|
|
123
126
|
/**
|
|
124
127
|
* Get a transaction from node.
|
|
125
128
|
*
|
|
@@ -14,7 +14,7 @@ export declare class JsonRpcTransformers {
|
|
|
14
14
|
static outPointTo(outPoint: JsonRpcOutPoint): OutPoint;
|
|
15
15
|
static cellInputFrom(cellInputLike: CellInputLike): JsonRpcCellInput;
|
|
16
16
|
static cellInputTo(cellInput: JsonRpcCellInput): CellInput;
|
|
17
|
-
static cellOutputFrom(
|
|
17
|
+
static cellOutputFrom(cellOutputLike: CellOutputLike, outputData?: HexLike | null): JsonRpcCellOutput;
|
|
18
18
|
static cellOutputTo(cellOutput: JsonRpcCellOutput): CellOutput;
|
|
19
19
|
static cellDepFrom(cellDep: CellDepLike): JsonRpcCellDep;
|
|
20
20
|
static cellDepTo(cellDep: JsonRpcCellDep): CellDep;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transformers.d.ts","sourceRoot":"","sources":["../../../src/client/jsonRpc/transformers.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,OAAO,EACP,WAAW,EACX,SAAS,EACT,aAAa,EACb,UAAU,EACV,cAAc,EACd,OAAO,EACP,WAAW,EACX,QAAQ,EACR,YAAY,EACZ,QAAQ,EACR,YAAY,EACZ,MAAM,EACN,UAAU,EACV,WAAW,EACX,eAAe,EAIhB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,GAAG,EAAE,OAAO,EAAW,MAAM,oBAAoB,CAAC;AAC3D,OAAO,EAAE,OAAO,EAAqC,MAAM,oBAAoB,CAAC;AAEhF,OAAO,EACL,WAAW,EACX,iBAAiB,EACjB,gBAAgB,EAChB,uBAAuB,EACvB,qCAAqC,EACrC,8BAA8B,EAE9B,4BAA4B,EAC5B,0BAA0B,EAE1B,qCAAqC,EACrC,yBAAyB,EACzB,iBAAiB,EAClB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACL,YAAY,EACZ,kBAAk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;IAoBhC,MAAM,CAAC,oBAAoB,CACzB,OAAO,EAAE,0BAA0B,GAClC,uBAAuB;IAU1B,MAAM,CAAC,mBAAmB,CAAC,EACzB,WAAW,EACX,OAAO,GACR,EAAE;QACD,WAAW,EAAE,MAAM,CAAC;QACpB,OAAO,EAAE;YACP,SAAS,EAAE,eAAe,CAAC;YAC3B,MAAM,EAAE,iBAAiB,CAAC;YAC1B,WAAW,CAAC,EAAE,GAAG,CAAC;SACnB,EAAE,CAAC;KACL,GAAG,uBAAuB;IAY3B,MAAM,CAAC,+BAA+B,CACpC,OAAO,EAAE,qCAAqC,GAC7C,kCAAkC;IAUrC,MAAM,CAAC,0BAA0B,CAAC,EAChC,WAAW,EACX,OAAO,GACR,EACG,sCAAsC,GACtC,6CAA6C,GAC7C,8BAA8B,GAC9B,qCAAqC;CAqC1C"}
|
|
@@ -68,7 +68,8 @@ export class JsonRpcTransformers {
|
|
|
68
68
|
since: cellInput.since,
|
|
69
69
|
});
|
|
70
70
|
}
|
|
71
|
-
static cellOutputFrom(
|
|
71
|
+
static cellOutputFrom(cellOutputLike, outputData) {
|
|
72
|
+
const cellOutput = CellOutput.from(cellOutputLike, outputData);
|
|
72
73
|
return {
|
|
73
74
|
capacity: numToHex(cellOutput.capacity),
|
|
74
75
|
lock: JsonRpcTransformers.scriptFrom(cellOutput.lock),
|
|
@@ -102,11 +102,11 @@ export declare abstract class Entity {
|
|
|
102
102
|
* }
|
|
103
103
|
* ```
|
|
104
104
|
*/
|
|
105
|
-
export declare function codec<Encodable, TypeLike extends Encodable, Decoded extends TypeLike, Type extends
|
|
105
|
+
export declare function codec<Encodable, TypeLike extends Encodable, Decoded extends TypeLike>(codec: Codec<Encodable, Decoded>): <Type extends TypeLike, ConstructorType extends Constructor<Type> & {
|
|
106
106
|
from(decoded: TypeLike): Type;
|
|
107
107
|
byteLength?: number;
|
|
108
108
|
encode(encodable: TypeLike): Bytes;
|
|
109
|
-
decode(bytesLike: BytesLike):
|
|
109
|
+
decode(bytesLike: BytesLike): Type;
|
|
110
110
|
fromBytes(bytes: BytesLike): Type;
|
|
111
|
-
}>(
|
|
111
|
+
}>(Constructor: ConstructorType, ..._: unknown[]) => ConstructorType;
|
|
112
112
|
//# sourceMappingURL=entity.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entity.d.ts","sourceRoot":"","sources":["../../src/molecule/entity.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAW,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAE9D,OAAO,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAC;AACtC,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAEnC;;;GAGG;AACH,8BAAsB,MAAM;IAC1B;;;;OAIG;IACH,MAAM,CAAC,IAAI,CAAC,WAAW,EAAE,OAAO,GAAG,WAAW;QA6D1C;;;;WAIG;mBACQ,KAAK;QAMhB;;;;WAIG;iBACM,OAAO;QAMhB;;;;;WAKG;kBACO,WAAW,GAAG,OAAO;QAe/B;;;;WAIG;gBACK,GAAG;;QA3GX;;;;WAIG;qBACiB,MAAM;QAC1B;;;;;;;WAOG;kBACc,WAAW,GAAG,KAAK;QAKpC;;;;;;;WAOG;kBACc,SAAS,GAAG,OAAO;QAMpC;;;;;;;WAOG;0BACsB,SAAS,GAAG,OAAO;QAM5C;;;;;;;WAOG;gBACY,WAAW,GAAG,OAAO;;IA4DxC,QAAQ,CAAC,OAAO,IAAI,KAAK;IACzB,QAAQ,CAAC,IAAI,IAAI,GAAG;IACpB,QAAQ,CAAC,KAAK,IAAI,MAAM;CACzB;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,KAAK,CACnB,SAAS,EACT,QAAQ,SAAS,SAAS,EAC1B,OAAO,SAAS,QAAQ,EACxB,
|
|
1
|
+
{"version":3,"file":"entity.d.ts","sourceRoot":"","sources":["../../src/molecule/entity.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G,IAAI,CAAC;IACnC,SAAS,CAAC,KAAK,EAAE,SAAS,GAAG,IAAI,CAAC;CACnC,EACD,aAAa,eAAe,EAAE,GAAG,GAAG,OAAO,EAAE,qBAchD"}
|
package/dist/molecule/entity.js
CHANGED
|
@@ -115,7 +115,7 @@ export class Entity {
|
|
|
115
115
|
* ```
|
|
116
116
|
*/
|
|
117
117
|
export function codec(codec) {
|
|
118
|
-
return function (Constructor) {
|
|
118
|
+
return function (Constructor, ..._) {
|
|
119
119
|
Constructor.byteLength = codec.byteLength;
|
|
120
120
|
Constructor.encode = function (encodable) {
|
|
121
121
|
return codec.encode(encodable);
|
|
@@ -1,5 +1,26 @@
|
|
|
1
1
|
import { Bytes, BytesLike } from "../../bytes/index.js";
|
|
2
2
|
import { Hex } from "../../hex/index.js";
|
|
3
|
+
import { NumLike } from "../../num/index.js";
|
|
4
|
+
/**
|
|
5
|
+
* Encodes a number into a variable-length byte array according to the Bitcoin protocol.
|
|
6
|
+
* This format is used for encoding lengths of data, such as script lengths.
|
|
7
|
+
*
|
|
8
|
+
* @param len - The number to encode. Can be a NumLike.
|
|
9
|
+
* @returns The encoded length as a Bytes.
|
|
10
|
+
* @public
|
|
11
|
+
*/
|
|
12
|
+
export declare function btcVarLengthBytesFrom(len: NumLike): Bytes;
|
|
13
|
+
/**
|
|
14
|
+
* Computes the message hash for Bitcoin ECDSA signatures.
|
|
15
|
+
* This function follows the Bitcoin message signing standard, which involves
|
|
16
|
+
* prefixing the message with a magic string and its length, then double SHA256 hashing the result.
|
|
17
|
+
*
|
|
18
|
+
* @param message - The message to be hashed. Can be a string or BytesLike.
|
|
19
|
+
* @param messagePrefix - Optional. A custom prefix to use instead of the default "\u0018Bitcoin Signed Message:\n".
|
|
20
|
+
* @returns The Bitcoin hash of the prefixed message as Bytes.
|
|
21
|
+
* @public
|
|
22
|
+
*/
|
|
23
|
+
export declare function messageHashBtcEcdsa(message: string | BytesLike, messagePrefix?: string | BytesLike): Bytes;
|
|
3
24
|
/**
|
|
4
25
|
* @public
|
|
5
26
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"verify.d.ts","sourceRoot":"","sources":["../../../src/signer/btc/verify.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"verify.d.ts","sourceRoot":"","sources":["../../../src/signer/btc/verify.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,EAA0B,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAChF,OAAO,EAAE,GAAG,EAAW,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAyB,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAEpE;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,OAAO,GAAG,KAAK,CAUzD;AAED;;;;;;;;;GASG;AACH,wBAAgB,mBAAmB,CACjC,OAAO,EAAE,MAAM,GAAG,SAAS,EAC3B,aAAa,CAAC,EAAE,MAAM,GAAG,SAAS,GACjC,KAAK,CAcP;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,SAAS,EAAE,SAAS,GAAG,KAAK,CAEjE;AAED;;GAEG;AACH,wBAAgB,4BAA4B,CAC1C,SAAS,EAAE,SAAS,EACpB,OAAO,EAAE,MAAM,GACd,MAAM,CAIR;AAED;;GAEG;AACH,wBAAgB,4BAA4B,CAAC,OAAO,EAAE,MAAM,GAAG,GAAG,CAEjE;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,MAAM,GAAG,SAAS,EAC3B,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,MAAM,GAChB,OAAO,CAWT"}
|
|
@@ -1,10 +1,46 @@
|
|
|
1
1
|
import { secp256k1 } from "@noble/curves/secp256k1";
|
|
2
2
|
import { ripemd160 } from "@noble/hashes/legacy.js";
|
|
3
3
|
import { sha256 } from "@noble/hashes/sha2.js";
|
|
4
|
-
import { magicHash } from "bitcoinjs-message";
|
|
5
4
|
import bs58check from "bs58check";
|
|
6
5
|
import { bytesConcat, bytesFrom } from "../../bytes/index.js";
|
|
7
6
|
import { hexFrom } from "../../hex/index.js";
|
|
7
|
+
import { numFrom, numLeToBytes } from "../../num/index.js";
|
|
8
|
+
/**
|
|
9
|
+
* Encodes a number into a variable-length byte array according to the Bitcoin protocol.
|
|
10
|
+
* This format is used for encoding lengths of data, such as script lengths.
|
|
11
|
+
*
|
|
12
|
+
* @param len - The number to encode. Can be a NumLike.
|
|
13
|
+
* @returns The encoded length as a Bytes.
|
|
14
|
+
* @public
|
|
15
|
+
*/
|
|
16
|
+
export function btcVarLengthBytesFrom(len) {
|
|
17
|
+
const num = numFrom(len);
|
|
18
|
+
return num < 0xfd
|
|
19
|
+
? numLeToBytes(num, 1)
|
|
20
|
+
: num <= 0xffff
|
|
21
|
+
? bytesConcat([0xfd], numLeToBytes(num, 2))
|
|
22
|
+
: num <= 0xffffffff
|
|
23
|
+
? bytesConcat([0xfe], numLeToBytes(num, 4))
|
|
24
|
+
: bytesConcat([0xff], numLeToBytes(num, 8));
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Computes the message hash for Bitcoin ECDSA signatures.
|
|
28
|
+
* This function follows the Bitcoin message signing standard, which involves
|
|
29
|
+
* prefixing the message with a magic string and its length, then double SHA256 hashing the result.
|
|
30
|
+
*
|
|
31
|
+
* @param message - The message to be hashed. Can be a string or BytesLike.
|
|
32
|
+
* @param messagePrefix - Optional. A custom prefix to use instead of the default "\u0018Bitcoin Signed Message:\n".
|
|
33
|
+
* @returns The Bitcoin hash of the prefixed message as Bytes.
|
|
34
|
+
* @public
|
|
35
|
+
*/
|
|
36
|
+
export function messageHashBtcEcdsa(message, messagePrefix) {
|
|
37
|
+
const prefix = messagePrefix ?? "\u0018Bitcoin Signed Message:\n";
|
|
38
|
+
const rawPrefix = typeof prefix === "string" ? bytesFrom(prefix, "utf8") : bytesFrom(prefix);
|
|
39
|
+
const rawMsg = typeof message === "string"
|
|
40
|
+
? bytesFrom(message, "utf8")
|
|
41
|
+
: bytesFrom(message);
|
|
42
|
+
return sha256(sha256(bytesConcat(rawPrefix, btcVarLengthBytesFrom(rawMsg.length), rawMsg)));
|
|
43
|
+
}
|
|
8
44
|
/**
|
|
9
45
|
* @public
|
|
10
46
|
*/
|
|
@@ -29,5 +65,5 @@ export function btcPublicKeyFromP2pkhAddress(address) {
|
|
|
29
65
|
export function verifyMessageBtcEcdsa(message, signature, publicKey) {
|
|
30
66
|
const challenge = typeof message === "string" ? message : hexFrom(message).slice(2);
|
|
31
67
|
const rawSign = bytesFrom(signature, "base64").slice(1);
|
|
32
|
-
return secp256k1.verify(bytesFrom(rawSign),
|
|
68
|
+
return secp256k1.verify(bytesFrom(rawSign), messageHashBtcEcdsa(challenge), bytesFrom(publicKey));
|
|
33
69
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signerDogePrivateKey.d.ts","sourceRoot":"","sources":["../../../src/signer/doge/signerDogePrivateKey.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"signerDogePrivateKey.d.ts","sourceRoot":"","sources":["../../../src/signer/doge/signerDogePrivateKey.ts"],"names":[],"mappings":"AACA,OAAO,EAIL,SAAS,EAEV,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAC/C,OAAO,EAAE,GAAG,EAAW,MAAM,oBAAoB,CAAC;AAElD,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAG7C;;;GAGG;AACH,qBAAa,oBAAqB,SAAQ,UAAU;aAYhC,WAAW;IAX7B,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAQ;IAEnC;;;;;OAKG;gBAED,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,SAAS,EACL,WAAW,SAAO;IASpC;;;;OAIG;IACG,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAE9B;;;;OAIG;IACG,WAAW,IAAI,OAAO,CAAC,OAAO,CAAC;IAI/B,gBAAgB,IAAI,OAAO,CAAC,GAAG,CAAC;IAItC;;;;;;;;;OASG;IACG,cAAc,IAAI,OAAO,CAAC,MAAM,CAAC;IAOvC;;;;;;OAMG;IACG,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,CAAC,MAAM,CAAC;CAa/D"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { secp256k1 } from "@noble/curves/secp256k1";
|
|
2
|
-
import { magicHash } from "bitcoinjs-message";
|
|
3
2
|
import { bytesConcat, bytesFrom, bytesTo, } from "../../bytes/index.js";
|
|
4
3
|
import { hexFrom } from "../../hex/index.js";
|
|
5
4
|
import { btcP2pkhAddressFromPublicKey } from "../btc/verify.js";
|
|
6
5
|
import { SignerDoge } from "./signerDoge.js";
|
|
6
|
+
import { messageHashDogeEcdsa } from "./verify.js";
|
|
7
7
|
/**
|
|
8
8
|
* A class extending SignerDoge that provides access to a Doge address.
|
|
9
9
|
* @public
|
|
@@ -62,7 +62,7 @@ export class SignerDogePrivateKey extends SignerDoge {
|
|
|
62
62
|
*/
|
|
63
63
|
async signMessageRaw(msg) {
|
|
64
64
|
const challenge = typeof msg === "string" ? msg : hexFrom(msg).slice(2);
|
|
65
|
-
const signature = secp256k1.sign(
|
|
65
|
+
const signature = secp256k1.sign(messageHashDogeEcdsa(challenge), this.privateKey);
|
|
66
66
|
return bytesTo(bytesConcat([31 + signature.recovery], signature.toCompactRawBytes()), "base64");
|
|
67
67
|
}
|
|
68
68
|
}
|
|
@@ -1,4 +1,15 @@
|
|
|
1
|
-
import { BytesLike } from "../../bytes/index.js";
|
|
1
|
+
import { Bytes, BytesLike } from "../../bytes/index.js";
|
|
2
|
+
/**
|
|
3
|
+
* Computes the message hash for Dogecoin ECDSA signatures.
|
|
4
|
+
* This function follows the Dogecoin message signing standard, which involves
|
|
5
|
+
* prefixing the message with a magic string and its length, then double SHA256 hashing the result.
|
|
6
|
+
*
|
|
7
|
+
* @param message - The message to be hashed. Can be a string or BytesLike.
|
|
8
|
+
* @param messagePrefix - Optional. A custom prefix to use instead of the default "\x19Dogecoin Signed Message:\n".
|
|
9
|
+
* @returns The Dogecoin hash of the prefixed message as Bytes.
|
|
10
|
+
* @public
|
|
11
|
+
*/
|
|
12
|
+
export declare function messageHashDogeEcdsa(message: string | BytesLike, messagePrefix?: string | BytesLike): Bytes;
|
|
2
13
|
/**
|
|
3
14
|
* @public
|
|
4
15
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"verify.d.ts","sourceRoot":"","sources":["../../../src/signer/doge/verify.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"verify.d.ts","sourceRoot":"","sources":["../../../src/signer/doge/verify.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAa,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAQnE;;;;;;;;;GASG;AACH,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,MAAM,GAAG,SAAS,EAC3B,aAAa,CAAC,EAAE,MAAM,GAAG,SAAS,GACjC,KAAK,CAKP;AAED;;GAEG;AACH,wBAAgB,sBAAsB,CACpC,OAAO,EAAE,MAAM,GAAG,SAAS,EAC3B,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,MAAM,GACd,OAAO,CAmBT"}
|
|
@@ -1,8 +1,20 @@
|
|
|
1
1
|
import { secp256k1 } from "@noble/curves/secp256k1";
|
|
2
|
-
import { magicHash } from "bitcoinjs-message";
|
|
3
2
|
import { bytesFrom } from "../../bytes/index.js";
|
|
4
3
|
import { hexFrom } from "../../hex/index.js";
|
|
5
|
-
import { btcEcdsaPublicKeyHash, btcPublicKeyFromP2pkhAddress, } from "../btc/verify.js";
|
|
4
|
+
import { btcEcdsaPublicKeyHash, btcPublicKeyFromP2pkhAddress, messageHashBtcEcdsa, } from "../btc/verify.js";
|
|
5
|
+
/**
|
|
6
|
+
* Computes the message hash for Dogecoin ECDSA signatures.
|
|
7
|
+
* This function follows the Dogecoin message signing standard, which involves
|
|
8
|
+
* prefixing the message with a magic string and its length, then double SHA256 hashing the result.
|
|
9
|
+
*
|
|
10
|
+
* @param message - The message to be hashed. Can be a string or BytesLike.
|
|
11
|
+
* @param messagePrefix - Optional. A custom prefix to use instead of the default "\x19Dogecoin Signed Message:\n".
|
|
12
|
+
* @returns The Dogecoin hash of the prefixed message as Bytes.
|
|
13
|
+
* @public
|
|
14
|
+
*/
|
|
15
|
+
export function messageHashDogeEcdsa(message, messagePrefix) {
|
|
16
|
+
return messageHashBtcEcdsa(message, messagePrefix ?? "\x19Dogecoin Signed Message:\n");
|
|
17
|
+
}
|
|
6
18
|
/**
|
|
7
19
|
* @public
|
|
8
20
|
*/
|
|
@@ -13,7 +25,5 @@ export function verifyMessageDogeEcdsa(message, signature, address) {
|
|
|
13
25
|
const rawSign = signatureBytes.slice(1);
|
|
14
26
|
const sig = secp256k1.Signature.fromCompact(hexFrom(rawSign).slice(2)).addRecoveryBit(recoveryBit - 31);
|
|
15
27
|
return (btcPublicKeyFromP2pkhAddress(address) ===
|
|
16
|
-
hexFrom(btcEcdsaPublicKeyHash(sig
|
|
17
|
-
.recoverPublicKey(magicHash(challenge, "\x19Dogecoin Signed Message:\n"))
|
|
18
|
-
.toHex())));
|
|
28
|
+
hexFrom(btcEcdsaPublicKeyHash(sig.recoverPublicKey(messageHashDogeEcdsa(challenge)).toHex())));
|
|
19
29
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { schnorr } from "@noble/curves/secp256k1";
|
|
2
|
-
import { sha256 } from "@noble/hashes/
|
|
2
|
+
import { sha256 } from "@noble/hashes/sha2.js";
|
|
3
3
|
import { bech32 } from "bech32";
|
|
4
4
|
import { bytesFrom } from "../../bytes/index.js";
|
|
5
5
|
import { hexFrom } from "../../hex/index.js";
|
|
@@ -43,11 +43,11 @@ export function nostrEventHash(event) {
|
|
|
43
43
|
}
|
|
44
44
|
export function verifyMessageNostrEvent(message, signature, address) {
|
|
45
45
|
const { words } = bech32.decode(address);
|
|
46
|
-
const
|
|
46
|
+
const pubkey = hexFrom(bech32.fromWords(words)).slice(2);
|
|
47
47
|
const event = buildNostrEventFromMessage(message);
|
|
48
|
-
const eventHash = nostrEventHash(event);
|
|
48
|
+
const eventHash = nostrEventHash({ ...event, pubkey });
|
|
49
49
|
try {
|
|
50
|
-
return schnorr.verify(hexFrom(signature).slice(2), eventHash,
|
|
50
|
+
return schnorr.verify(hexFrom(signature).slice(2), eventHash, pubkey);
|
|
51
51
|
}
|
|
52
52
|
catch (_) {
|
|
53
53
|
return false;
|
|
@@ -211,13 +211,22 @@ export declare abstract class Signer {
|
|
|
211
211
|
*/
|
|
212
212
|
signTransaction(tx: TransactionLike): Promise<Transaction>;
|
|
213
213
|
/**
|
|
214
|
-
*
|
|
214
|
+
* Prepares a transaction before signing.
|
|
215
|
+
* This method can be overridden by subclasses to perform any necessary steps,
|
|
216
|
+
* such as adding cell dependencies or witnesses, before the transaction is signed.
|
|
217
|
+
* The default implementation converts the {@link TransactionLike} object to a {@link Transaction} object
|
|
218
|
+
* without modification.
|
|
215
219
|
*
|
|
216
|
-
* @
|
|
217
|
-
*
|
|
218
|
-
*
|
|
220
|
+
* @remarks
|
|
221
|
+
* Note that this default implementation does not add any cell dependencies or dummy witnesses.
|
|
222
|
+
* This may lead to an underestimation of transaction size and fees if used with methods
|
|
223
|
+
* like `Transaction.completeFee`. Subclasses for signers that are intended to sign
|
|
224
|
+
* transactions should override this method to perform necessary preparations.
|
|
225
|
+
*
|
|
226
|
+
* @param tx - The transaction to prepare.
|
|
227
|
+
* @returns A promise that resolves to the prepared {@link Transaction} object.
|
|
219
228
|
*/
|
|
220
|
-
prepareTransaction(
|
|
229
|
+
prepareTransaction(tx: TransactionLike): Promise<Transaction>;
|
|
221
230
|
/**
|
|
222
231
|
* Signs a transaction without preparing information for it. This method is not implemented and should be overridden by subclasses.
|
|
223
232
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts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,CAAC,CAC3D;IAiCD;;;;OAIG;IACG,UAAU,IAAI,OAAO,CAAC,GAAG,CAAC;IAMhC;;;;;;OAMG;IACG,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,CAAC,SAAS,CAAC;IAQlE;;;;;;OAMG;IACH,cAAc,CAAC,CAAC,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,CAAC,MAAM,CAAC;IAItD;;;;;;;OAOG;IACG,aAAa,CACjB,OAAO,EAAE,MAAM,GAAG,SAAS,EAC3B,SAAS,EAAE,MAAM,GAAG,SAAS,GAC5B,OAAO,CAAC,OAAO,CAAC;IAmBnB;;;;;OAKG;IACG,eAAe,CAAC,EAAE,EAAE,eAAe,GAAG,OAAO,CAAC,GAAG,CAAC;IAIxD;;;;;OAKG;IACG,eAAe,CAAC,EAAE,EAAE,eAAe,GAAG,OAAO,CAAC,WAAW,CAAC;IAKhE;;;;;;;;;;;;;;;OAeG;IACG,kBAAkB,CAAC,EAAE,EAAE,eAAe,GAAG,OAAO,CAAC,WAAW,CAAC;IAInE;;;;;;OAMG;IACH,mBAAmB,CAAC,CAAC,EAAE,eAAe,GAAG,OAAO,CAAC,WAAW,CAAC;CAG9D;AAED;;;GAGG;AACH,qBAAa,UAAU;IAEZ,IAAI,EAAE,MAAM;IACZ,MAAM,EAAE,MAAM;gBADd,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM;CAExB;AAED;;;GAGG;AACH,MAAM,MAAM,MAAM,GAAG;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd,CAAC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Transaction } from "../../ckb/index.js";
|
|
1
2
|
import { verifyMessageBtcEcdsa } from "../btc/index.js";
|
|
2
3
|
import { verifyMessageCkbSecp256k1 } from "../ckb/verifyCkbSecp256k1.js";
|
|
3
4
|
import { verifyMessageJoyId } from "../ckb/verifyJoyId.js";
|
|
@@ -55,11 +56,9 @@ export class Signer {
|
|
|
55
56
|
// undefined otherwise
|
|
56
57
|
matchNetworkPreference(preferences, currentNetwork) {
|
|
57
58
|
if (currentNetwork !== undefined &&
|
|
58
|
-
preferences.some(({ signerType, addressPrefix, network }) =>
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
network === currentNetwork;
|
|
62
|
-
})) {
|
|
59
|
+
preferences.some(({ signerType, addressPrefix, network }) => signerType === this.type &&
|
|
60
|
+
addressPrefix === this.client.addressPrefix &&
|
|
61
|
+
network === currentNetwork)) {
|
|
63
62
|
return;
|
|
64
63
|
}
|
|
65
64
|
return preferences.find(({ signerType, addressPrefix }) => signerType === this.type && addressPrefix === this.client.addressPrefix);
|
|
@@ -265,14 +264,23 @@ export class Signer {
|
|
|
265
264
|
return this.signOnlyTransaction(preparedTx);
|
|
266
265
|
}
|
|
267
266
|
/**
|
|
268
|
-
*
|
|
267
|
+
* Prepares a transaction before signing.
|
|
268
|
+
* This method can be overridden by subclasses to perform any necessary steps,
|
|
269
|
+
* such as adding cell dependencies or witnesses, before the transaction is signed.
|
|
270
|
+
* The default implementation converts the {@link TransactionLike} object to a {@link Transaction} object
|
|
271
|
+
* without modification.
|
|
269
272
|
*
|
|
270
|
-
* @
|
|
271
|
-
*
|
|
272
|
-
*
|
|
273
|
+
* @remarks
|
|
274
|
+
* Note that this default implementation does not add any cell dependencies or dummy witnesses.
|
|
275
|
+
* This may lead to an underestimation of transaction size and fees if used with methods
|
|
276
|
+
* like `Transaction.completeFee`. Subclasses for signers that are intended to sign
|
|
277
|
+
* transactions should override this method to perform necessary preparations.
|
|
278
|
+
*
|
|
279
|
+
* @param tx - The transaction to prepare.
|
|
280
|
+
* @returns A promise that resolves to the prepared {@link Transaction} object.
|
|
273
281
|
*/
|
|
274
|
-
prepareTransaction(
|
|
275
|
-
|
|
282
|
+
async prepareTransaction(tx) {
|
|
283
|
+
return Transaction.from(tx);
|
|
276
284
|
}
|
|
277
285
|
/**
|
|
278
286
|
* Signs a transaction without preparing information for it. This method is not implemented and should be overridden by subclasses.
|