UNPKG

@taquito/signer

Version:

Software signer implementations and signing utilities for Taquito.

58 lines (57 loc) 2.02 kB
"use strict"; var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; var desc = Object.getOwnPropertyDescriptor(m, k); if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { desc = { enumerable: true, get: function() { return m[k]; } }; } Object.defineProperty(o, k2, desc); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; })); var __exportStar = (this && this.__exportStar) || function(m, exports) { for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); }; Object.defineProperty(exports, "__esModule", { value: true }); exports.Path = exports.Ed25519 = exports.ECDSA = void 0; const core_1 = require("@taquito/core"); const types_1 = require("./types"); exports.ECDSA = require("./ecdsa"); exports.Ed25519 = require("./ed25519"); __exportStar(require("./types"), exports); class Path extends Array { static from(iterable) { return super.from(iterable).map((x) => x >>> 0); } /** * * @param s derivation path eg: 44'/1729'/0'/0' * @returns applied hardened values */ static fromString(s) { if (s.length === 0) { return new Path(); } let parts = s.split('/'); const out = []; if (parts[0] === 'm') { parts = parts.slice(1); } for (let p of parts) { if (p.length === 0) { throw new core_1.InvalidDerivationPathError(s, `: Invalid BIP32 path`); } let h = 0; const last = p[p.length - 1]; if (last === "'" || last === 'h' || last === 'H') { h = types_1.Hard; p = p.slice(0, p.length - 1); } const index = (parseInt(p, 10) | h) >>> 0; out.push(index); } return Path.from(out); } } exports.Path = Path;