@exodus/bip322-js 1.1.0 → 1.2.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/CHANGELOG.md +61 -0
- package/README.md +13 -13
- package/dist/BIP322.d.ts +2 -33
- package/dist/BIP322.js +23 -103
- package/dist/BIP322.js.map +1 -0
- package/dist/Signer.d.ts +1 -20
- package/dist/Signer.js +32 -97
- package/dist/Signer.js.map +1 -0
- package/dist/Verifier.d.ts +0 -39
- package/dist/Verifier.js +60 -175
- package/dist/Verifier.js.map +1 -0
- package/dist/bitcoinjs/DecodeScriptSignature.d.ts +0 -1
- package/dist/bitcoinjs/DecodeScriptSignature.js +1 -7
- package/dist/bitcoinjs/DecodeScriptSignature.js.map +1 -0
- package/dist/bitcoinjs/index.d.ts +1 -2
- package/dist/bitcoinjs/index.js +1 -5
- package/dist/bitcoinjs/index.js.map +1 -0
- package/dist/helpers/Address.d.ts +2 -49
- package/dist/helpers/Address.js +57 -156
- package/dist/helpers/Address.js.map +1 -0
- package/dist/helpers/BIP137.d.ts +0 -21
- package/dist/helpers/BIP137.js +6 -61
- package/dist/helpers/BIP137.js.map +1 -0
- package/dist/helpers/VarInt.d.ts +0 -17
- package/dist/helpers/VarInt.js +11 -40
- package/dist/helpers/VarInt.js.map +1 -0
- package/dist/helpers/VarStr.d.ts +0 -17
- package/dist/helpers/VarStr.js +5 -32
- package/dist/helpers/VarStr.js.map +1 -0
- package/dist/helpers/Witness.d.ts +0 -18
- package/dist/helpers/Witness.js +10 -47
- package/dist/helpers/Witness.js.map +1 -0
- package/dist/helpers/index.d.ts +5 -6
- package/dist/helpers/index.js +5 -16
- package/dist/helpers/index.js.map +1 -0
- package/dist/index.d.ts +5 -5
- package/dist/index.js +5 -17
- package/dist/index.js.map +1 -0
- package/package.json +53 -44
package/dist/helpers/Witness.js
CHANGED
|
@@ -1,70 +1,33 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
// Import dependencies
|
|
7
|
-
const VarInt_1 = __importDefault(require("./VarInt"));
|
|
8
|
-
const VarStr_1 = __importDefault(require("./VarStr"));
|
|
9
|
-
/**
|
|
10
|
-
* Class that implement witness data serialization and deserialization.
|
|
11
|
-
*/
|
|
1
|
+
import VarInt from './VarInt.js';
|
|
2
|
+
import VarStr from './VarStr.js';
|
|
12
3
|
class Witness {
|
|
13
|
-
/**
|
|
14
|
-
* Encode array of witness into its base-64 encoded format.
|
|
15
|
-
* Follows the encoding scheme found in buidl-python:
|
|
16
|
-
* https://github.com/buidl-bitcoin/buidl-python/blob/d79e9808e8ca60975d315be41293cb40d968626d/buidl/witness.py#L35
|
|
17
|
-
* @param witnesses Array of witness data
|
|
18
|
-
* @returns Base-64 encoded witness data
|
|
19
|
-
*/
|
|
20
4
|
static serialize(witnesses) {
|
|
21
|
-
|
|
22
|
-
let witnessStack = VarInt_1.default.encode(witnesses.length);
|
|
23
|
-
// Then, for each witness array,
|
|
5
|
+
let witnessStack = VarInt.encode(witnesses.length);
|
|
24
6
|
witnesses.forEach((witness) => {
|
|
25
|
-
|
|
26
|
-
witnessStack = Buffer.concat([witnessStack, VarStr_1.default.encode(Buffer.from(witness))]);
|
|
7
|
+
witnessStack = Buffer.concat([witnessStack, VarStr.encode(Buffer.from(witness))]);
|
|
27
8
|
});
|
|
28
|
-
// Return the base-64 encoded witness stack
|
|
29
9
|
return witnessStack.toString('base64');
|
|
30
10
|
}
|
|
31
|
-
/**
|
|
32
|
-
* Decode encoded witness data, either as a base-64 encoded string or as a decoded string in a buffer, into an array of witness.
|
|
33
|
-
* Follows the decoding scheme found in buidl-python:
|
|
34
|
-
* https://github.com/buidl-bitcoin/buidl-python/blob/d79e9808e8ca60975d315be41293cb40d968626d/buidl/witness.py#L62
|
|
35
|
-
* @param encodedWitness Base-64 encoded witness data, or encoded witness data that have already been decoded
|
|
36
|
-
* @returns Decoded witness data
|
|
37
|
-
*/
|
|
38
11
|
static deserialize(encodedWitness) {
|
|
39
|
-
|
|
40
|
-
let witnessDecoded = [];
|
|
41
|
-
// Preprocess the encodedWitness if needed
|
|
12
|
+
const witnessDecoded = [];
|
|
42
13
|
let witnessToDecode;
|
|
43
14
|
if (typeof encodedWitness === 'string') {
|
|
44
|
-
// Decode the encoded witness if it is a string (assuming it is encoded using base-64)
|
|
45
15
|
witnessToDecode = Buffer.from(encodedWitness, 'base64');
|
|
46
16
|
}
|
|
47
17
|
else {
|
|
48
18
|
witnessToDecode = encodedWitness;
|
|
49
19
|
}
|
|
50
|
-
|
|
51
|
-
const
|
|
52
|
-
// Slice the VarInt in front of the witness buffer before decoding each witness
|
|
53
|
-
const varIntLength = VarInt_1.default.encode(witnessCount).byteLength;
|
|
20
|
+
const witnessCount = VarInt.decode(witnessToDecode);
|
|
21
|
+
const varIntLength = VarInt.encode(witnessCount).byteLength;
|
|
54
22
|
witnessToDecode = witnessToDecode.subarray(varIntLength);
|
|
55
|
-
// Loop for each witness encoded
|
|
56
23
|
for (let i = 0; i < witnessCount; i++) {
|
|
57
|
-
|
|
58
|
-
const witness = VarStr_1.default.decode(witnessToDecode);
|
|
59
|
-
// Append the decoded witness to witnessDecoded
|
|
24
|
+
const witness = VarStr.decode(witnessToDecode);
|
|
60
25
|
witnessDecoded.push(witness);
|
|
61
|
-
|
|
62
|
-
const witnessLength = VarStr_1.default.encode(witness).byteLength;
|
|
26
|
+
const witnessLength = VarStr.encode(witness).byteLength;
|
|
63
27
|
witnessToDecode = witnessToDecode.subarray(witnessLength);
|
|
64
28
|
}
|
|
65
|
-
// Return deserialized witness data
|
|
66
29
|
return witnessDecoded;
|
|
67
30
|
}
|
|
68
31
|
}
|
|
69
|
-
|
|
32
|
+
export default Witness;
|
|
70
33
|
//# sourceMappingURL=Witness.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Witness.js","s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C,OAAO,CAAC,CAAA;YAE5B,MAAM,aAAa,GAAG,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,UAAU,CAAA;YACvD,eAAe,GAAG,eAAe,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAA;QAC3D,CAAC;QAGD,OAAO,cAAc,CAAA;IACvB,CAAC;CACF;AAED,eAAe,OAAO,CAAA"}
|
package/dist/helpers/index.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
export { Address, BIP137, VarInt, VarStr, Witness };
|
|
1
|
+
export { default as Address } from './Address.js';
|
|
2
|
+
export { default as VarInt } from './VarInt.js';
|
|
3
|
+
export { default as BIP137 } from './BIP137.js';
|
|
4
|
+
export { default as Witness } from './Witness.js';
|
|
5
|
+
export { default as VarStr } from './VarStr.js';
|
package/dist/helpers/index.js
CHANGED
|
@@ -1,17 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
|
|
6
|
-
exports.Witness = exports.VarStr = exports.VarInt = exports.BIP137 = exports.Address = void 0;
|
|
7
|
-
const Address_1 = __importDefault(require("./Address"));
|
|
8
|
-
exports.Address = Address_1.default;
|
|
9
|
-
const BIP137_1 = __importDefault(require("./BIP137"));
|
|
10
|
-
exports.BIP137 = BIP137_1.default;
|
|
11
|
-
const VarInt_1 = __importDefault(require("./VarInt"));
|
|
12
|
-
exports.VarInt = VarInt_1.default;
|
|
13
|
-
const VarStr_1 = __importDefault(require("./VarStr"));
|
|
14
|
-
exports.VarStr = VarStr_1.default;
|
|
15
|
-
const Witness_1 = __importDefault(require("./Witness"));
|
|
16
|
-
exports.Witness = Witness_1.default;
|
|
1
|
+
export { default as Address } from './Address.js';
|
|
2
|
+
export { default as VarInt } from './VarInt.js';
|
|
3
|
+
export { default as BIP137 } from './BIP137.js';
|
|
4
|
+
export { default as Witness } from './Witness.js';
|
|
5
|
+
export { default as VarStr } from './VarStr.js';
|
|
17
6
|
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/helpers/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,OAAO,EAAE,MAAM,cAAc,CAAA;AACjD,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,aAAa,CAAA;AAC/C,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,aAAa,CAAA;AAC/C,OAAO,EAAE,OAAO,IAAI,OAAO,EAAE,MAAM,cAAc,CAAA;AACjD,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,aAAa,CAAA"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
export {
|
|
1
|
+
export { default as BIP322 } from './BIP322.js';
|
|
2
|
+
export { default as Signer } from './Signer.js';
|
|
3
|
+
export { Witness, Address } from './helpers/index.js';
|
|
4
|
+
export { default as Verifier } from './Verifier.js';
|
|
5
|
+
export { BIP137 } from './helpers/index.js';
|
package/dist/index.js
CHANGED
|
@@ -1,18 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
|
|
6
|
-
exports.BIP137 = exports.Address = exports.Witness = exports.Verifier = exports.Signer = exports.BIP322 = void 0;
|
|
7
|
-
// Import modules to be exported
|
|
8
|
-
const BIP322_1 = __importDefault(require("./BIP322"));
|
|
9
|
-
exports.BIP322 = BIP322_1.default;
|
|
10
|
-
const Signer_1 = __importDefault(require("./Signer"));
|
|
11
|
-
exports.Signer = Signer_1.default;
|
|
12
|
-
const Verifier_1 = __importDefault(require("./Verifier"));
|
|
13
|
-
exports.Verifier = Verifier_1.default;
|
|
14
|
-
const helpers_1 = require("./helpers");
|
|
15
|
-
Object.defineProperty(exports, "Witness", { enumerable: true, get: function () { return helpers_1.Witness; } });
|
|
16
|
-
Object.defineProperty(exports, "Address", { enumerable: true, get: function () { return helpers_1.Address; } });
|
|
17
|
-
Object.defineProperty(exports, "BIP137", { enumerable: true, get: function () { return helpers_1.BIP137; } });
|
|
1
|
+
export { default as BIP322 } from './BIP322.js';
|
|
2
|
+
export { default as Signer } from './Signer.js';
|
|
3
|
+
export { Witness, Address } from './helpers/index.js';
|
|
4
|
+
export { default as Verifier } from './Verifier.js';
|
|
5
|
+
export { BIP137 } from './helpers/index.js';
|
|
18
6
|
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,aAAa,CAAA;AAC/C,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,aAAa,CAAA;AAC/C,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAA;AACrD,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,MAAM,eAAe,CAAA;AAEnD,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,46 +1,55 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
"
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
2
|
+
"name": "@exodus/bip322-js",
|
|
3
|
+
"version": "1.2.1",
|
|
4
|
+
"description": "A Javascript library that provides utility functions related to the BIP-322 signature scheme",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"publishConfig": {
|
|
9
|
+
"access": "restricted"
|
|
10
|
+
},
|
|
11
|
+
"files": [
|
|
12
|
+
"dist",
|
|
13
|
+
"CHANGELOG.md"
|
|
14
|
+
],
|
|
15
|
+
"scripts": {
|
|
16
|
+
"build": "tsc",
|
|
17
|
+
"lint": "eslint",
|
|
18
|
+
"lint:fix": "run lint --fix",
|
|
19
|
+
"doc": "typedoc src/index.ts",
|
|
20
|
+
"prepack": "npm run build",
|
|
21
|
+
"test": "run -T exodus-test --jest --esbuild",
|
|
22
|
+
"prepublishOnly": "yarn run -T build --scope @exodus/bip322-js"
|
|
23
|
+
},
|
|
24
|
+
"keywords": [
|
|
25
|
+
"bip322",
|
|
26
|
+
"bitcoinjs",
|
|
27
|
+
"javascript",
|
|
28
|
+
"typescript",
|
|
29
|
+
"no-WASM"
|
|
30
|
+
],
|
|
31
|
+
"author": "Exodus Movement, Inc.",
|
|
32
|
+
"repository": {
|
|
33
|
+
"type": "git",
|
|
34
|
+
"url": "git+https://github.com/ExodusMovement/exodus-hydra.git"
|
|
35
|
+
},
|
|
36
|
+
"license": "MIT",
|
|
37
|
+
"devDependencies": {
|
|
38
|
+
"@types/create-hash": "^1",
|
|
39
|
+
"@types/node": "^20.2.5",
|
|
40
|
+
"typedoc": "^0.24.8",
|
|
41
|
+
"typescript": "^5.1.3"
|
|
42
|
+
},
|
|
43
|
+
"dependencies": {
|
|
44
|
+
"@exodus/bitcoinerlab-secp256k1": "^1.0.5-exodus.1",
|
|
45
|
+
"@exodus/bitcoinjs": "^1.1.0",
|
|
46
|
+
"@exodus/secp256k1": "^4.0.2-exodus.0",
|
|
47
|
+
"bitcoinjs-message": "^2.2.0",
|
|
48
|
+
"create-hash": "^1.2.0"
|
|
49
|
+
},
|
|
50
|
+
"homepage": "https://github.com/ExodusMovement/exodus-hydra/tree/master/libraries/bip322-js",
|
|
51
|
+
"bugs": {
|
|
52
|
+
"url": "https://github.com/ExodusMovement/exodus-hydra/issues?q=is%3Aissue+is%3Aopen+label%3Abip322-js"
|
|
53
|
+
},
|
|
54
|
+
"gitHead": "6a40d50082582568d68206d8926737eea560fa50"
|
|
46
55
|
}
|