@bitgo/public-types 6.89.0 → 6.90.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.
@@ -1,7 +1,9 @@
1
1
  import * as t from "io-ts";
2
- interface DerivationIndexBrand {
3
- readonly DerivationIndex: unique symbol;
2
+ interface SafeBip44PathBrand {
3
+ readonly SafeBip44Path: unique symbol;
4
4
  }
5
+ export declare const SafeBip44Path: t.BrandC<t.StringC, SafeBip44PathBrand>;
6
+ export type SafeBip44Path = t.TypeOf<typeof SafeBip44Path>;
5
7
  export declare const MPCv2DeriveRound1Request: t.TypeC<{
6
8
  userGpgPublicKey: import("io-ts-types").NonEmptyStringC;
7
9
  userMsg1: t.TypeC<{
@@ -10,7 +12,7 @@ export declare const MPCv2DeriveRound1Request: t.TypeC<{
10
12
  signature: t.StringC;
11
13
  }>;
12
14
  parentKeyId: import("io-ts-types").NonEmptyStringC;
13
- derivationIndex: t.BrandC<t.NumberC, DerivationIndexBrand>;
15
+ path: t.BrandC<t.StringC, SafeBip44PathBrand>;
14
16
  }>;
15
17
  export type MPCv2DeriveRound1Request = t.TypeOf<typeof MPCv2DeriveRound1Request>;
16
18
  export declare const MPCv2DeriveRound1Response: t.TypeC<{
@@ -56,7 +58,7 @@ export declare const EddsaMPCv2DeriveRound1Request: t.TypeC<{
56
58
  signature: t.StringC;
57
59
  }>;
58
60
  parentKeyId: import("io-ts-types").NonEmptyStringC;
59
- derivationIndex: t.BrandC<t.NumberC, DerivationIndexBrand>;
61
+ path: t.BrandC<t.StringC, SafeBip44PathBrand>;
60
62
  }>;
61
63
  export type EddsaMPCv2DeriveRound1Request = t.TypeOf<typeof EddsaMPCv2DeriveRound1Request>;
62
64
  export declare const EddsaMPCv2DeriveRound1Response: t.TypeC<{
@@ -23,16 +23,22 @@ var __importStar = (this && this.__importStar) || function (mod) {
23
23
  return result;
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.EddsaMPCv2DeriveRound2Response = exports.EddsaMPCv2DeriveRound2Request = exports.EddsaMPCv2DeriveRound1Response = exports.EddsaMPCv2DeriveRound1Request = exports.MPCv2DeriveRound3Response = exports.MPCv2DeriveRound3Request = exports.MPCv2DeriveRound2Response = exports.MPCv2DeriveRound2Request = exports.MPCv2DeriveRound1Response = exports.MPCv2DeriveRound1Request = void 0;
26
+ exports.EddsaMPCv2DeriveRound2Response = exports.EddsaMPCv2DeriveRound2Request = exports.EddsaMPCv2DeriveRound1Response = exports.EddsaMPCv2DeriveRound1Request = exports.MPCv2DeriveRound3Response = exports.MPCv2DeriveRound3Request = exports.MPCv2DeriveRound2Response = exports.MPCv2DeriveRound2Request = exports.MPCv2DeriveRound1Response = exports.MPCv2DeriveRound1Request = exports.SafeBip44Path = void 0;
27
27
  const t = __importStar(require("io-ts"));
28
28
  const io_ts_types_1 = require("io-ts-types");
29
29
  const common_1 = require("../common");
30
- const DerivationIndex = t.brand(t.number, (index) => Number.isSafeInteger(index) && index >= 0, "DerivationIndex");
30
+ const BIP32_HARDENED_OFFSET = 0x80000000;
31
+ const SAFE_BIP44_PATH = /^m\/44'\/(0|[1-9][0-9]*)'\/(0|[1-9][0-9]*)'\/(0|[1-9][0-9]*)'$/;
32
+ exports.SafeBip44Path = t.brand(t.string, (path) => {
33
+ const match = SAFE_BIP44_PATH.exec(path);
34
+ return (match !== null &&
35
+ match.slice(1).every((segment) => Number(segment) < BIP32_HARDENED_OFFSET));
36
+ }, "SafeBip44Path");
31
37
  exports.MPCv2DeriveRound1Request = t.type({
32
38
  userGpgPublicKey: io_ts_types_1.NonEmptyString,
33
39
  userMsg1: common_1.MPCv2BroadcastMessage,
34
40
  parentKeyId: io_ts_types_1.NonEmptyString,
35
- derivationIndex: DerivationIndex,
41
+ path: exports.SafeBip44Path,
36
42
  }, "MPCv2DeriveRound1Request");
37
43
  exports.MPCv2DeriveRound1Response = t.type({
38
44
  sessionId: io_ts_types_1.NonEmptyString,
@@ -57,7 +63,7 @@ exports.EddsaMPCv2DeriveRound1Request = t.type({
57
63
  userGpgPublicKey: io_ts_types_1.NonEmptyString,
58
64
  userMsg1: common_1.EddsaMPCv2SignedMessage,
59
65
  parentKeyId: io_ts_types_1.NonEmptyString,
60
- derivationIndex: DerivationIndex,
66
+ path: exports.SafeBip44Path,
61
67
  }, "EddsaMPCv2DeriveRound1Request");
62
68
  exports.EddsaMPCv2DeriveRound1Response = t.type({
63
69
  sessionId: io_ts_types_1.NonEmptyString,
@@ -1 +1 @@
1
- {"version":3,"file":"deriveRound.js","sourceRoot":"","sources":["../../../../../src/schema/mpcv2/derive/deriveRound.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,yCAA2B;AAC3B,6CAA6C;AAC7C,sCAA2E;AAM3E,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAC7B,CAAC,CAAC,MAAM,EACR,CAAC,KAAa,EAAoD,EAAE,CAClE,MAAM,CAAC,aAAa,CAAC,KAAK,CAAC,IAAI,KAAK,IAAI,CAAC,EAC3C,iBAAiB,CAClB,CAAC;AAEW,QAAA,wBAAwB,GAAG,CAAC,CAAC,IAAI,CAC5C;IACE,gBAAgB,EAAE,4BAAc;IAChC,QAAQ,EAAE,8BAAqB;IAC/B,WAAW,EAAE,4BAAc;IAC3B,eAAe,EAAE,eAAe;CACjC,EACD,0BAA0B,CAC3B,CAAC;AAMW,QAAA,yBAAyB,GAAG,CAAC,CAAC,IAAI,CAAC;IAC9C,SAAS,EAAE,4BAAc;IACzB,SAAS,EAAE,8BAAqB;CACjC,CAAC,CAAC;AAMU,QAAA,wBAAwB,GAAG,CAAC,CAAC,IAAI,CAAC;IAC7C,SAAS,EAAE,4BAAc;IACzB,QAAQ,EAAE,8BAAqB;CAChC,CAAC,CAAC;AAMU,QAAA,yBAAyB,GAAG,CAAC,CAAC,IAAI,CAAC;IAC9C,SAAS,EAAE,4BAAc;IACzB,SAAS,EAAE,8BAAqB;CACjC,CAAC,CAAC;AAMU,QAAA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AE,gCAAuB;CACnC,CAAC,CAAC;AAMU,QAAA,6BAA6B,GAAG,CAAC,CAAC,IAAI,CAAC;IAClD,SAAS,EAAE,4BAAc;IACzB,QAAQ,EAAE,gCAAuB;CAClC,CAAC,CAAC;AAMU,QAAA,8BAA8B,GAAG,CAAC,CAAC,IAAI,CAAC;IACnD,SAAS,EAAE,4BAAc;IACzB,oBAAoB,EAAE,4BAAc;IACpC,SAAS,EAAE,gCAAuB;CACnC,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bitgo/public-types",
3
- "version": "6.89.0",
3
+ "version": "6.90.0",
4
4
  "description": "Collection of types exposed externally as part of the BitGo public API",
5
5
  "license": "UNLICENSED",
6
6
  "author": "",
@@ -2,23 +2,39 @@ import * as t from "io-ts";
2
2
  import { NonEmptyString } from "io-ts-types";
3
3
  import { MPCv2BroadcastMessage, EddsaMPCv2SignedMessage } from "../common";
4
4
 
5
- interface DerivationIndexBrand {
6
- readonly DerivationIndex: unique symbol;
5
+ const BIP32_HARDENED_OFFSET = 0x80000000;
6
+ const SAFE_BIP44_PATH =
7
+ /^m\/44'\/(0|[1-9][0-9]*)'\/(0|[1-9][0-9]*)'\/(0|[1-9][0-9]*)'$/;
8
+
9
+ interface SafeBip44PathBrand {
10
+ readonly SafeBip44Path: unique symbol;
7
11
  }
8
12
 
9
- const DerivationIndex = t.brand(
10
- t.number,
11
- (index: number): index is t.Branded<number, DerivationIndexBrand> =>
12
- Number.isSafeInteger(index) && index >= 0,
13
- "DerivationIndex",
13
+ /**
14
+ * Full hardened Safe child derivation path `m/44'/<coinType>'/<slot>'/<account>'`: purpose `44'`,
15
+ * then three more hardened segments, each a canonical decimal BIP32 index in `0 .. 2^31-1`.
16
+ * Structural only; the service that receives it compares it with the path it expects for the
17
+ * (coin, slot, account) before use.
18
+ */
19
+ export const SafeBip44Path = t.brand(
20
+ t.string,
21
+ (path: string): path is t.Branded<string, SafeBip44PathBrand> => {
22
+ const match = SAFE_BIP44_PATH.exec(path);
23
+ return (
24
+ match !== null &&
25
+ match.slice(1).every((segment) => Number(segment) < BIP32_HARDENED_OFFSET)
26
+ );
27
+ },
28
+ "SafeBip44Path",
14
29
  );
30
+ export type SafeBip44Path = t.TypeOf<typeof SafeBip44Path>;
15
31
 
16
32
  export const MPCv2DeriveRound1Request = t.type(
17
33
  {
18
34
  userGpgPublicKey: NonEmptyString,
19
35
  userMsg1: MPCv2BroadcastMessage,
20
36
  parentKeyId: NonEmptyString,
21
- derivationIndex: DerivationIndex,
37
+ path: SafeBip44Path,
22
38
  },
23
39
  "MPCv2DeriveRound1Request",
24
40
  );
@@ -76,7 +92,7 @@ export const EddsaMPCv2DeriveRound1Request = t.type(
76
92
  userGpgPublicKey: NonEmptyString,
77
93
  userMsg1: EddsaMPCv2SignedMessage,
78
94
  parentKeyId: NonEmptyString,
79
- derivationIndex: DerivationIndex,
95
+ path: SafeBip44Path,
80
96
  },
81
97
  "EddsaMPCv2DeriveRound1Request",
82
98
  );