@planetarium/account
Version:
Libplanet accounts for JavaScript/TypeScript
8 lines (7 loc) • 20.7 kB
Source Map (JSON)
{
"version": 3,
"sources": ["../src/index.ts", "../src/Account.ts", "../src/Address.ts", "../src/PublicKey.ts", "../src/Message.ts", "../src/Signature.ts", "../src/RawPrivateKey.ts"],
"sourcesContent": ["export { type Account, type ExportableAccount } from \"./Account.js\";\nexport { Address } from \"./Address.js\";\nexport {\n type AccountDeletion,\n type AccountGeneration,\n type AccountImportation,\n type AccountMetadata,\n type AccountRetrieval,\n type ImportableKeyStore,\n type KeyStore,\n type MutableKeyStore,\n} from \"./KeyStore.js\";\nexport { type Message } from \"./Message.js\";\nexport { PublicKey, type PublicKeyForm } from \"./PublicKey.js\";\nexport { RawPrivateKey } from \"./RawPrivateKey.js\";\nexport { Signature } from \"./Signature.js\";\n", "import { type Message } from \"./Message.js\";\nimport Address from \"./Address.js\";\nimport PublicKey from \"./PublicKey.js\";\nimport RawPrivateKey from \"./RawPrivateKey.js\";\nimport Signature from \"./Signature.js\";\n\nexport interface Account {\n getAddress(): Promise<Address>;\n getPublicKey(): Promise<PublicKey>;\n sign(message: Message): Promise<Signature>;\n}\n\nexport function isAccount(account: unknown): account is Account {\n return (\n typeof account === \"object\" &&\n account != null &&\n \"getAddress\" in account &&\n account.getAddress instanceof Function &&\n \"getPublicKey\" in account &&\n account.getPublicKey instanceof Function &&\n \"sign\" in account &&\n account.sign instanceof Function\n );\n}\n\nexport interface ExportableAccount extends Account {\n exportPrivateKey(): Promise<RawPrivateKey>;\n}\n\nexport default Account;\n", "import { Buffer } from \"buffer\";\nimport { keccak_256 } from \"@noble/hashes/sha3\";\nimport { Account, isAccount } from \"./Account.js\";\nimport { PublicKey } from \"./PublicKey.js\";\n\nif (typeof globalThis.TextEncoder === \"undefined\") {\n // FIXME: This is a workaround for the lack of TextEncoder in Vitest.\n globalThis.TextEncoder = require(\"node:util\").TextEncoder;\n}\n\nfunction toHex(bytes: Uint8Array): string {\n let hex = \"\";\n for (let i = 0; i < bytes.length; i++) {\n hex += bytes[i].toString(16).padStart(2, \"0\");\n }\n return hex;\n}\n\nfunction checksum(hex: string): string {\n hex = hex.toLowerCase();\n\n const hexAsciiIntoBytes = new TextEncoder!().encode(hex);\n const hashedAddr = toHex(keccak_256(hexAsciiIntoBytes));\n let checksum = \"\";\n for (let nibbleIdx = 0; nibbleIdx < hex.length; nibbleIdx++) {\n const nibbleHex = hex.charAt(nibbleIdx);\n if (nibbleHex.match(/^[0-9]$/)) {\n checksum += nibbleHex;\n continue;\n } else {\n const nibble = parseInt(hashedAddr.charAt(nibbleIdx), 16);\n checksum += nibble > 7 ? nibbleHex.toUpperCase() : nibbleHex;\n }\n }\n\n return checksum;\n}\n\nexport class Address {\n #bytes: Uint8Array;\n\n private constructor(bytes: Uint8Array) {\n this.#bytes = bytes;\n }\n\n static deriveFrom(publicKey: PublicKey): Address;\n static deriveFrom(account: Account): Promise<Address>;\n\n static deriveFrom(\n publicKey: PublicKey | Account\n ): Address | Promise<Address> {\n if (isAccount(publicKey)) {\n return publicKey.getPublicKey().then(this.#deriveFrom);\n } else if (publicKey instanceof PublicKey) {\n return this.#deriveFrom(publicKey);\n }\n\n throw new Error(\n `Expected either PublicKey or Account, got ${typeof publicKey}`\n );\n }\n\n static #deriveFrom(publicKey: PublicKey): Address {\n const pub = publicKey.toBytes(\"uncompressed\").slice(1);\n const digest = keccak_256(pub);\n const addr = digest.slice(digest.length - 20);\n return new Address(addr);\n }\n\n static fromHex(hex: string, ignoreChecksum: boolean = false): Address {\n if (typeof hex !== \"string\") {\n throw new Error(`Expected a string, but ${typeof hex} was given.`);\n } else if (!hex.match(/^(0x)?[0-9a-f]{40}$/i)) {\n throw new Error(\n `Expected a string of 40 hexadecimals, but ${JSON.stringify(\n hex\n )} was given.`\n );\n }\n\n if (hex.match(/^0x/i)) {\n hex = hex.slice(2);\n }\n\n const addr = new Address(new Uint8Array(Buffer.from(hex, \"hex\")));\n if (ignoreChecksum) {\n return addr;\n }\n\n const expectedChecksum = checksum(hex);\n if (expectedChecksum !== hex) {\n throw new Error(\n `Expected checksum is 0x${expectedChecksum}, but 0x${hex} was given.`\n );\n }\n\n return addr;\n }\n\n static fromBytes(bytes: Uint8Array) {\n if (!(bytes instanceof Uint8Array)) {\n throw new Error(`Expected a Uint8Array, but ${typeof bytes} was given.`);\n }\n\n if (bytes.length !== 20) {\n throw new Error(\n `Expected 20 bytes, but ${bytes.length} bytes were given.`\n );\n }\n\n return new Address(bytes);\n }\n\n toBytes(): Uint8Array {\n return this.#bytes;\n }\n\n toHex(casing: \"checksum\" | \"lower\" = \"checksum\"): string {\n const hex = toHex(this.#bytes);\n return casing === \"checksum\" ? checksum(hex) : hex;\n }\n\n equals(other: Address): boolean {\n if (!(other instanceof Address)) return false;\n for (let i = 0; i < 20; i++) {\n if (this.#bytes[i] !== other.#bytes[i]) return false;\n }\n\n return true;\n }\n\n isAddressOf(publicKey: PublicKey): boolean {\n return Address.deriveFrom(publicKey).equals(this);\n }\n\n toString(): string {\n return `0x${this.toHex()}`;\n }\n}\n\nexport default Address;\n", "import { Buffer } from \"buffer\";\nimport * as secp256k1 from \"@noble/secp256k1\";\nimport { Message, hashMessage } from \"./Message.js\";\nimport Signature from \"./Signature.js\";\n\nexport type PublicKeyForm = \"compressed\" | \"uncompressed\";\n\nexport class PublicKey {\n readonly #point: secp256k1.Point;\n\n private constructor(point: secp256k1.Point) {\n this.#point = point;\n }\n\n static fromBytes(bytes: Uint8Array, form: PublicKeyForm): PublicKey {\n if (!(bytes instanceof Uint8Array)) {\n throw new Error(`Expected a Uint8Array, but got ${typeof bytes}`);\n }\n const header = bytes[0];\n if (form === \"compressed\") {\n if (bytes.length !== 33) {\n throw new Error(\n `Invalid compressed public key: expected 33 bytes, but got ${bytes.length} bytes`\n );\n } else if (header !== 0x02 && header !== 0x03) {\n throw new Error(\n `Invalid compressed public key: expected either 0x02 or 0x03 as the header, but got 0x${header\n .toString(16)\n .padStart(2, \"0\")}`\n );\n }\n } else if (form === \"uncompressed\") {\n if (bytes.length !== 65) {\n throw new Error(\n `Invalid uncompressed public key expected 65 bytes, but got ${bytes.length} bytes`\n );\n } else if (header !== 0x04) {\n throw new Error(\n `Invalid compressed public key: expected 0x04 as the header, but got 0x${header\n .toString(16)\n .padStart(2, \"0\")}`\n );\n }\n } else {\n throw new Error(\n \"Invalid public key form: choose 'compressed' or 'uncompressed'\"\n );\n }\n return new PublicKey(secp256k1.Point.fromHex(bytes));\n }\n\n // TODO: more explicit length checking\n static fromHex(hex: string, form: PublicKeyForm): PublicKey {\n if (typeof hex !== \"string\") {\n throw new Error(`Expected a string, but got ${typeof hex}`);\n } else if (form === \"compressed\" && hex.length !== 66) {\n throw new Error(\n `Invalid compressed public key: expected 33 hexadigits, but got ${hex.length} hexadigits`\n );\n } else if (form === \"uncompressed\" && hex.length !== 130) {\n throw new Error(\n `Invalid uncompressed public key expected 130 hexadigits, but got ${hex.length} hexadigits`\n );\n }\n const bytes = new Uint8Array(Buffer.from(hex, \"hex\"));\n return this.fromBytes(bytes, form);\n }\n\n async verify(message: Message, signature: Signature): Promise<boolean> {\n if (!(message instanceof Uint8Array)) {\n throw new Error(`Expected Uint8Array, but got ${typeof message}`);\n } else if (!(signature instanceof Signature)) {\n throw new Error(`Expected Signature, but got ${typeof signature}`);\n }\n const msgHash = await hashMessage(message);\n return secp256k1.verify(signature.toBytes(), msgHash, this.#point);\n }\n\n toBytes(form: PublicKeyForm): Uint8Array {\n if (form !== \"compressed\" && form !== \"uncompressed\") {\n throw new Error(\n \"Invalid public key form: choose 'compressed' or 'uncompressed'\"\n );\n }\n return this.#point.toRawBytes(form === \"compressed\");\n }\n\n toHex(form: PublicKeyForm): string {\n if (form !== \"compressed\" && form !== \"uncompressed\") {\n throw new Error(\n \"Invalid public key form: choose 'compressed' or 'uncompressed'\"\n );\n }\n return this.#point.toHex(form === \"compressed\");\n }\n\n equals(other: PublicKey): boolean {\n return other instanceof PublicKey && this.#point.equals(other.#point);\n }\n}\n\nexport default PublicKey;\n", "import { sha256 } from \"@noble/hashes/sha256\";\n\nexport type Message = Uint8Array;\n\nexport async function hashMessage(message: Message): Promise<Uint8Array> {\n // TODO: Use Web Crypto API when it is available.\n // return new Uint8Array(await crypto!.subtle.digest(\"SHA-256\", message));\n return sha256(message);\n}\n\nexport default Message;\n", "import * as secp256k1 from \"@noble/secp256k1\";\n\nexport class Signature {\n readonly #signature: secp256k1.Signature;\n\n private constructor(signature: secp256k1.Signature) {\n if (signature.hasHighS())\n throw new RangeError(\n \"A signature with high S is unsupported; \" +\n \"normalize it to get rid of high S\",\n );\n this.#signature = signature;\n }\n\n static fromBytes(bytes: Uint8Array): Signature {\n // NOTE: We decided to distinguish fromBytes from fromHex, although they\n // call the same function in @noble/secp256k1 which takes both a hex string\n // and a Uint8Array.\n return new Signature(secp256k1.Signature.fromDER(bytes));\n }\n\n static fromHex(hex: string): Signature {\n // NOTE: We decided to distinguish fromBytes from fromHex, although they\n // call the same function in @noble/secp256k1 which takes both a hex string\n // and a Uint8Array.\n return new Signature(secp256k1.Signature.fromDER(hex));\n }\n\n toBytes(): Uint8Array {\n return this.#signature.toDERRawBytes();\n }\n\n toHex(): string {\n return this.#signature.toDERHex();\n }\n\n toString(): string {\n return this.toHex();\n }\n\n [Symbol.for(\"nodejs.util.inspect.custom\")]() {\n return `Signature { ${this.toHex()} }`;\n }\n}\n\nexport default Signature;\n", "import { Buffer } from \"buffer\";\nimport * as secp256k1 from \"@noble/secp256k1\";\nimport Address from \"./Address.js\";\nimport { Message, hashMessage } from \"./Message.js\";\nimport PublicKey from \"./PublicKey.js\";\nimport Signature from \"./Signature.js\";\n\nexport class RawPrivateKey {\n readonly #privatePart: Uint8Array;\n #publicPart?: PublicKey;\n\n private constructor(privatePart: Uint8Array) {\n this.#privatePart = privatePart;\n }\n\n static fromBytes(bytes: Uint8Array): RawPrivateKey {\n if (!(bytes instanceof Uint8Array)) {\n throw new Error(`Expected Uint8Array, but got ${typeof bytes}`);\n } else if (bytes.length !== 32) {\n throw new Error(\n `Incorrect private key length; expected 32 bytes, but got ${bytes.length} bytes`\n );\n } else if (!secp256k1.utils.isValidPrivateKey(bytes)) {\n throw new Error(\"Invalid private key\");\n }\n\n // NOTE: The bytes should be copied because the original array can be\n // mutated after the key is created.\n return new RawPrivateKey(new Uint8Array(bytes));\n }\n\n static fromHex(hex: string): RawPrivateKey {\n if (typeof hex !== \"string\") {\n throw new Error(`Expected string, but got ${typeof hex}`);\n } else if (hex.length !== 64) {\n throw new Error(\n `Incorrect private key length; expected 64 hexadigits, but got ${hex.length} hexadigits`\n );\n }\n const bytes = new Uint8Array(Buffer.from(hex, \"hex\"));\n if (!secp256k1.utils.isValidPrivateKey(bytes)) {\n throw new Error(\"Invalid private key\");\n }\n\n return new RawPrivateKey(bytes);\n }\n\n static generate(): RawPrivateKey {\n return this.fromBytes(secp256k1.utils.randomPrivateKey());\n }\n\n getAddress(): Promise<Address> {\n return Promise.resolve(Address.deriveFrom(this.publicKey));\n }\n\n /**\n * @deprecated Use {@link getPublicKey()} instead.\n */\n get publicKey(): PublicKey {\n // TODO: This attribute is deprecated. We should remove it and make\n // getPublicKey() method the only choice in the future.\n if (typeof this.#publicPart === \"undefined\") {\n this.#publicPart = PublicKey.fromBytes(\n secp256k1.getPublicKey(this.#privatePart),\n \"uncompressed\"\n );\n }\n\n return this.#publicPart;\n }\n\n getPublicKey(): Promise<PublicKey> {\n return Promise.resolve(this.publicKey);\n }\n\n async sign(message: Message): Promise<Signature> {\n const sig = await secp256k1.sign(\n await hashMessage(message),\n this.#privatePart,\n { der: true }\n );\n return Signature.fromBytes(sig);\n }\n\n exportPrivateKey(): Promise<RawPrivateKey> {\n return Promise.resolve(this);\n }\n\n toBytes(): Uint8Array {\n // NOTE: The #privatePart should be copied because the returned reference\n // can be mutated after this method is called.\n return new Uint8Array(this.#privatePart);\n }\n}\n\nexport default RawPrivateKey;\n"],
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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