@secondlayer/stacks 0.0.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/README.md +92 -0
- package/dist/shared/stacks-02actsrx.cjs +17 -0
- package/dist/shared/stacks-02actsrx.cjs.map +10 -0
- package/dist/shared/stacks-1aqm7c2h.cjs +110 -0
- package/dist/shared/stacks-1aqm7c2h.cjs.map +11 -0
- package/dist/shared/stacks-24h5k94q.cjs +74 -0
- package/dist/shared/stacks-24h5k94q.cjs.map +11 -0
- package/dist/shared/stacks-2ar4prfz.cjs +328 -0
- package/dist/shared/stacks-2ar4prfz.cjs.map +11 -0
- package/dist/shared/stacks-4py5pm0r.cjs +237 -0
- package/dist/shared/stacks-4py5pm0r.cjs.map +10 -0
- package/dist/shared/stacks-5tprhns9.cjs +54 -0
- package/dist/shared/stacks-5tprhns9.cjs.map +11 -0
- package/dist/shared/stacks-61rvzkz1.cjs +132 -0
- package/dist/shared/stacks-61rvzkz1.cjs.map +17 -0
- package/dist/shared/stacks-709tra19.js +30 -0
- package/dist/shared/stacks-709tra19.js.map +10 -0
- package/dist/shared/stacks-74k8cxgb.cjs +567 -0
- package/dist/shared/stacks-74k8cxgb.cjs.map +13 -0
- package/dist/shared/stacks-8m9byk2j.js +7 -0
- package/dist/shared/stacks-8m9byk2j.js.map +9 -0
- package/dist/shared/stacks-8yykgdww.js +125 -0
- package/dist/shared/stacks-8yykgdww.js.map +11 -0
- package/dist/shared/stacks-9g0jhab3.cjs +40 -0
- package/dist/shared/stacks-9g0jhab3.cjs.map +10 -0
- package/dist/shared/stacks-an5k8n4t.cjs +291 -0
- package/dist/shared/stacks-an5k8n4t.cjs.map +23 -0
- package/dist/shared/stacks-b008c3w8.cjs +214 -0
- package/dist/shared/stacks-b008c3w8.cjs.map +11 -0
- package/dist/shared/stacks-bnvfmt7y.cjs +31 -0
- package/dist/shared/stacks-bnvfmt7y.cjs.map +9 -0
- package/dist/shared/stacks-bycy6t9k.js +22 -0
- package/dist/shared/stacks-bycy6t9k.js.map +10 -0
- package/dist/shared/stacks-d1fmkv3p.js +258 -0
- package/dist/shared/stacks-d1fmkv3p.js.map +13 -0
- package/dist/shared/stacks-dr5en54r.cjs +119 -0
- package/dist/shared/stacks-dr5en54r.cjs.map +10 -0
- package/dist/shared/stacks-dxhntr76.js +278 -0
- package/dist/shared/stacks-dxhntr76.js.map +10 -0
- package/dist/shared/stacks-evnzth1q.cjs +35 -0
- package/dist/shared/stacks-evnzth1q.cjs.map +10 -0
- package/dist/shared/stacks-f3tk2k5s.js +27 -0
- package/dist/shared/stacks-f3tk2k5s.js.map +9 -0
- package/dist/shared/stacks-f7wdrzs3.js +285 -0
- package/dist/shared/stacks-f7wdrzs3.js.map +11 -0
- package/dist/shared/stacks-fcaefc5b.cjs +16 -0
- package/dist/shared/stacks-fcaefc5b.cjs.map +10 -0
- package/dist/shared/stacks-g9mcjcqg.cjs +3 -0
- package/dist/shared/stacks-g9mcjcqg.cjs.map +9 -0
- package/dist/shared/stacks-gck1sq7h.cjs +28 -0
- package/dist/shared/stacks-gck1sq7h.cjs.map +10 -0
- package/dist/shared/stacks-gjvbq6w7.js +46 -0
- package/dist/shared/stacks-gjvbq6w7.js.map +10 -0
- package/dist/shared/stacks-j2cy7qtt.js +237 -0
- package/dist/shared/stacks-j2cy7qtt.js.map +11 -0
- package/dist/shared/stacks-k08tgzyp.cjs +232 -0
- package/dist/shared/stacks-k08tgzyp.cjs.map +13 -0
- package/dist/shared/stacks-k2p5tv6x.js +37 -0
- package/dist/shared/stacks-k2p5tv6x.js.map +10 -0
- package/dist/shared/stacks-k58k970n.js +234 -0
- package/dist/shared/stacks-k58k970n.js.map +10 -0
- package/dist/shared/stacks-n2g56wgg.js +338 -0
- package/dist/shared/stacks-n2g56wgg.js.map +23 -0
- package/dist/shared/stacks-nqytwfcc.js +243 -0
- package/dist/shared/stacks-nqytwfcc.js.map +11 -0
- package/dist/shared/stacks-qcae5852.js +19 -0
- package/dist/shared/stacks-qcae5852.js.map +10 -0
- package/dist/shared/stacks-qt8ehebn.js +76 -0
- package/dist/shared/stacks-qt8ehebn.js.map +11 -0
- package/dist/shared/stacks-qvg7c24g.cjs +232 -0
- package/dist/shared/stacks-qvg7c24g.cjs.map +10 -0
- package/dist/shared/stacks-r1t6g3c3.cjs +241 -0
- package/dist/shared/stacks-r1t6g3c3.cjs.map +11 -0
- package/dist/shared/stacks-tjxmrssa.js +282 -0
- package/dist/shared/stacks-tjxmrssa.js.map +11 -0
- package/dist/shared/stacks-v9jqcpd4.js +18 -0
- package/dist/shared/stacks-v9jqcpd4.js.map +10 -0
- package/dist/shared/stacks-vdfag81a.cjs +121 -0
- package/dist/shared/stacks-vdfag81a.cjs.map +10 -0
- package/dist/shared/stacks-vdfs3e5v.js +134 -0
- package/dist/shared/stacks-vdfs3e5v.js.map +10 -0
- package/dist/shared/stacks-y3dh7hv1.js +60 -0
- package/dist/shared/stacks-y3dh7hv1.js.map +11 -0
- package/dist/shared/stacks-ya3x01yd.cjs +16 -0
- package/dist/shared/stacks-ya3x01yd.cjs.map +10 -0
- package/dist/shared/stacks-yfgsm6ap.js +599 -0
- package/dist/shared/stacks-yfgsm6ap.js.map +13 -0
- package/dist/shared/stacks-yfveb68e.js +121 -0
- package/dist/shared/stacks-yfveb68e.js.map +10 -0
- package/dist/shared/stacks-zm0b3tgy.js +160 -0
- package/dist/shared/stacks-zm0b3tgy.js.map +17 -0
- package/dist/shared/stacks-zyv9qqme.cjs +249 -0
- package/dist/shared/stacks-zyv9qqme.cjs.map +11 -0
- package/dist/src/accounts/index.cjs +90 -0
- package/dist/src/accounts/index.cjs.map +12 -0
- package/dist/src/accounts/index.d.cts +47 -0
- package/dist/src/accounts/index.d.ts +47 -0
- package/dist/src/accounts/index.js +104 -0
- package/dist/src/accounts/index.js.map +12 -0
- package/dist/src/actions/index.cjs +36 -0
- package/dist/src/actions/index.cjs.map +9 -0
- package/dist/src/actions/index.d.cts +886 -0
- package/dist/src/actions/index.d.ts +886 -0
- package/dist/src/actions/index.js +81 -0
- package/dist/src/actions/index.js.map +9 -0
- package/dist/src/bns/index.cjs +590 -0
- package/dist/src/bns/index.cjs.map +15 -0
- package/dist/src/bns/index.d.cts +241 -0
- package/dist/src/bns/index.d.ts +241 -0
- package/dist/src/bns/index.js +611 -0
- package/dist/src/bns/index.js.map +15 -0
- package/dist/src/chains/index.cjs +13 -0
- package/dist/src/chains/index.cjs.map +9 -0
- package/dist/src/chains/index.d.cts +53 -0
- package/dist/src/chains/index.d.ts +53 -0
- package/dist/src/chains/index.js +18 -0
- package/dist/src/chains/index.js.map +9 -0
- package/dist/src/clarity/index.cjs +3 -0
- package/dist/src/clarity/index.cjs.map +9 -0
- package/dist/src/clarity/index.d.cts +821 -0
- package/dist/src/clarity/index.d.ts +821 -0
- package/dist/src/clarity/index.js +145 -0
- package/dist/src/clarity/index.js.map +9 -0
- package/dist/src/connect/index.cjs +480 -0
- package/dist/src/connect/index.cjs.map +19 -0
- package/dist/src/connect/index.d.cts +110 -0
- package/dist/src/connect/index.d.ts +110 -0
- package/dist/src/connect/index.js +448 -0
- package/dist/src/connect/index.js.map +19 -0
- package/dist/src/connect/walletconnect/index.cjs +1322 -0
- package/dist/src/connect/walletconnect/index.cjs.map +18 -0
- package/dist/src/connect/walletconnect/index.d.cts +132 -0
- package/dist/src/connect/walletconnect/index.d.ts +132 -0
- package/dist/src/connect/walletconnect/index.js +1290 -0
- package/dist/src/connect/walletconnect/index.js.map +18 -0
- package/dist/src/index.cjs +557 -0
- package/dist/src/index.cjs.map +21 -0
- package/dist/src/index.d.cts +847 -0
- package/dist/src/index.d.ts +847 -0
- package/dist/src/index.js +629 -0
- package/dist/src/index.js.map +21 -0
- package/dist/src/postconditions/index.cjs +3 -0
- package/dist/src/postconditions/index.cjs.map +9 -0
- package/dist/src/postconditions/index.d.cts +91 -0
- package/dist/src/postconditions/index.d.ts +91 -0
- package/dist/src/postconditions/index.js +12 -0
- package/dist/src/postconditions/index.js.map +9 -0
- package/dist/src/pox/index.cjs +860 -0
- package/dist/src/pox/index.cjs.map +15 -0
- package/dist/src/pox/index.d.cts +244 -0
- package/dist/src/pox/index.d.ts +244 -0
- package/dist/src/pox/index.js +877 -0
- package/dist/src/pox/index.js.map +15 -0
- package/dist/src/stackingdao/index.cjs +300 -0
- package/dist/src/stackingdao/index.cjs.map +13 -0
- package/dist/src/stackingdao/index.d.cts +179 -0
- package/dist/src/stackingdao/index.d.ts +179 -0
- package/dist/src/stackingdao/index.js +318 -0
- package/dist/src/stackingdao/index.js.map +13 -0
- package/dist/src/subscriptions/index.cjs +14 -0
- package/dist/src/subscriptions/index.cjs.map +9 -0
- package/dist/src/subscriptions/index.d.cts +250 -0
- package/dist/src/subscriptions/index.d.ts +250 -0
- package/dist/src/subscriptions/index.js +21 -0
- package/dist/src/subscriptions/index.js.map +9 -0
- package/dist/src/transactions/index.cjs +50 -0
- package/dist/src/transactions/index.cjs.map +9 -0
- package/dist/src/transactions/index.d.cts +412 -0
- package/dist/src/transactions/index.d.ts +412 -0
- package/dist/src/transactions/index.js +101 -0
- package/dist/src/transactions/index.js.map +9 -0
- package/dist/src/utils/index.cjs +168 -0
- package/dist/src/utils/index.cjs.map +11 -0
- package/dist/src/utils/index.d.cts +140 -0
- package/dist/src/utils/index.d.ts +140 -0
- package/dist/src/utils/index.js +222 -0
- package/dist/src/utils/index.js.map +11 -0
- package/package.json +105 -0
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/utils/signature.ts", "../src/utils/keys.ts"],
|
|
4
|
+
"sourcesContent": [
|
|
5
|
+
"import { Signature as NobleSignature, verify, Point } from \"@noble/secp256k1\";\nimport { sha256 } from \"@noble/hashes/sha2.js\";\nimport { bytesToHex, hexToBytes, concatBytes, utf8ToBytes } from \"./encoding.ts\";\nimport { hash160, hashP2PKH } from \"./hash.ts\";\nimport { c32address } from \"./address.ts\";\nimport { AddressVersion } from \"./constants.ts\";\n\nexport interface RecoverableSignature {\n /** Recovery id (0–3) */\n recovery: number;\n /** 32-byte r value as hex */\n r: string;\n /** 32-byte s value as hex */\n s: string;\n}\n\n// --- Format conversion ---\n\n/**\n * Parse a 65-byte VRS hex signature into components.\n * VRS format: recovery (1 byte) + r (32 bytes) + s (32 bytes)\n */\nexport function parseSignature(hex: string): RecoverableSignature {\n const clean = hex.startsWith(\"0x\") ? hex.slice(2) : hex;\n if (clean.length !== 130) {\n throw new Error(`Invalid signature length: expected 130 hex chars, got ${clean.length}`);\n }\n return {\n recovery: parseInt(clean.slice(0, 2), 16),\n r: clean.slice(2, 66),\n s: clean.slice(66, 130),\n };\n}\n\n/**\n * Serialize a recoverable signature to 65-byte VRS hex (130 chars).\n */\nexport function serializeSignature(sig: RecoverableSignature): string {\n const v = sig.recovery.toString(16).padStart(2, \"0\");\n return v + sig.r + sig.s;\n}\n\n/** Convert VRS hex to RSV hex: r+s (128 chars) + recovery (2 chars). */\nexport function signatureVrsToRsv(vrs: string): string {\n const clean = vrs.startsWith(\"0x\") ? vrs.slice(2) : vrs;\n return clean.slice(2) + clean.slice(0, 2);\n}\n\n/** Convert RSV hex to VRS hex: recovery (2 chars) + r+s (128 chars). */\nexport function signatureRsvToVrs(rsv: string): string {\n const clean = rsv.startsWith(\"0x\") ? rsv.slice(2) : rsv;\n return clean.slice(-2) + clean.slice(0, -2);\n}\n\n// --- Recovery ---\n\n/**\n * Recover a public key from a message hash and VRS signature.\n * @returns hex-encoded public key (33 bytes compressed, or 65 bytes uncompressed)\n */\nexport function recoverPublicKey(\n hash: Uint8Array | string,\n signature: string,\n compressed = true\n): string {\n const parsed = parseSignature(signature);\n const rs = parsed.r + parsed.s;\n const sig = NobleSignature.fromCompact(rs).addRecoveryBit(parsed.recovery);\n const msgHash = typeof hash === \"string\" ? hexToBytes(hash) : hash;\n const point = sig.recoverPublicKey(msgHash);\n return point.toHex(compressed);\n}\n\n/**\n * Recover a Stacks address from a message hash and VRS signature.\n * @param addressVersion defaults to MainnetSingleSig (22)\n */\nexport function recoverAddress(\n hash: Uint8Array | string,\n signature: string,\n addressVersion: number = AddressVersion.MainnetSingleSig\n): string {\n const pubkey = recoverPublicKey(hash, signature, true);\n const pubkeyHash = hashP2PKH(hexToBytes(pubkey));\n return c32address(addressVersion, pubkeyHash);\n}\n\n// --- Verification ---\n\n/**\n * Verify an ECDSA signature against a message hash and public key.\n * Accepts compact (64-byte) signature as hex or Uint8Array.\n */\nexport function verifySignature(\n hash: Uint8Array | string,\n signature: string | Uint8Array,\n publicKey: string | Uint8Array\n): boolean {\n return verify(signature, hash, publicKey, { lowS: false });\n}\n\n/** Bitcoin-style varint encoding for message length prefix. */\nfunction encodeVarint(n: number): Uint8Array {\n if (n < 0xfd) return new Uint8Array([n]);\n if (n <= 0xffff) {\n const buf = new Uint8Array(3);\n buf[0] = 0xfd;\n buf[1] = n & 0xff;\n buf[2] = (n >> 8) & 0xff;\n return buf;\n }\n const buf = new Uint8Array(5);\n buf[0] = 0xfe;\n buf[1] = n & 0xff;\n buf[2] = (n >> 8) & 0xff;\n buf[3] = (n >> 16) & 0xff;\n buf[4] = (n >> 24) & 0xff;\n return buf;\n}\n\nconst STACKS_MESSAGE_PREFIX = \"\\x17Stacks Signed Message:\\n\";\nconst LEGACY_MESSAGE_PREFIX = \"\\x18Stacks Message Signing:\\n\";\n\n/** Hash a message with the Stacks structured message prefix. */\nfunction hashMessage(message: string | Uint8Array, prefix: string): Uint8Array {\n const messageBytes = typeof message === \"string\" ? utf8ToBytes(message) : message;\n const prefixBytes = utf8ToBytes(prefix);\n const lengthBytes = encodeVarint(messageBytes.length);\n return sha256(concatBytes(prefixBytes, lengthBytes, messageBytes));\n}\n\n/**\n * Verify a signed Stacks message.\n * Parses a VRS signature, extracts r+s for verification.\n * Falls back to legacy prefix if standard prefix fails.\n */\nexport function verifyMessageSignature(\n message: string | Uint8Array,\n signature: string,\n publicKey: string\n): boolean {\n const parsed = parseSignature(signature);\n const compactSig = parsed.r + parsed.s;\n\n const msgHash = hashMessage(message, STACKS_MESSAGE_PREFIX);\n if (verify(compactSig, msgHash, publicKey, { lowS: false })) return true;\n\n // Fallback to legacy prefix\n if (typeof message === \"string\") {\n const legacyHash = hashMessage(message, LEGACY_MESSAGE_PREFIX);\n if (verify(compactSig, legacyHash, publicKey, { lowS: false })) return true;\n }\n\n return false;\n}\n",
|
|
6
|
+
"import { Point, etc } from \"@noble/secp256k1\";\nimport { bytesToHex, hexToBytes } from \"./encoding.ts\";\n\n/** Compress a public key to 33 bytes (hex). */\nexport function compressPublicKey(publicKey: string | Uint8Array): string {\n const hex = typeof publicKey === \"string\" ? publicKey : bytesToHex(publicKey);\n return Point.fromHex(hex).toHex(true);\n}\n\n/** Uncompress a public key to 65 bytes (hex). */\nexport function uncompressPublicKey(publicKey: string | Uint8Array): string {\n const hex = typeof publicKey === \"string\" ? publicKey : bytesToHex(publicKey);\n return Point.fromHex(hex).toHex(false);\n}\n\n/** Check if a public key is in compressed format (starts with 0x02 or 0x03). */\nexport function isCompressedPublicKey(publicKey: string | Uint8Array): boolean {\n const bytes = typeof publicKey === \"string\" ? hexToBytes(publicKey) : publicKey;\n return bytes.length === 33 && (bytes[0] === 0x02 || bytes[0] === 0x03);\n}\n\n/** Generate cryptographically secure random bytes. Defaults to 32 bytes. */\nexport function randomBytes(length?: number): Uint8Array {\n return etc.randomBytes(length ?? 32);\n}\n"
|
|
7
|
+
],
|
|
8
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAA2D,IAA3D;AACuB,IAAvB;AAqBO,SAAS,cAAc,CAAC,KAAmC;AAAA,EAChE,MAAM,QAAQ,IAAI,WAAW,IAAI,IAAI,IAAI,MAAM,CAAC,IAAI;AAAA,EACpD,IAAI,MAAM,WAAW,KAAK;AAAA,IACxB,MAAM,IAAI,MAAM,yDAAyD,MAAM,QAAQ;AAAA,EACzF;AAAA,EACA,O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aAAa,YAAY,SAAS,qBAAqB;AAAA,IAC7D,IAAI,wBAAO,YAAY,YAAY,WAAW,EAAE,MAAM,MAAM,CAAC;AAAA,MAAG,OAAO;AAAA,EACzE;AAAA,EAEA,OAAO;AAAA;;ACzJkB,IAA3B;AAIO,SAAS,iBAAiB,CAAC,WAAwC;AAAA,EACxE,MAAM,MAAM,OAAO,cAAc,WAAW,YAAY,WAAW,SAAS;AAAA,EAC5E,OAAO,wBAAM,QAAQ,GAAG,EAAE,MAAM,IAAI;AAAA;AAI/B,SAAS,mBAAmB,CAAC,WAAwC;AAAA,EAC1E,MAAM,MAAM,OAAO,cAAc,WAAW,YAAY,WAAW,SAAS;AAAA,EAC5E,OAAO,wBAAM,QAAQ,GAAG,EAAE,MAAM,KAAK;AAAA;AAIhC,SAAS,qBAAqB,CAAC,WAAyC;AAAA,EAC7E,MAAM,QAAQ,OAAO,cAAc,WAAW,WAAW,SAAS,IAAI;AAAA,EACtE,OAAO,MAAM,WAAW,OAAO,MAAM,OAAO,KAAQ,MAAM,OAAO;AAAA;AAI5D,SAAS,WAAW,CAAC,QAA6B;AAAA,EACvD,OAAO,sBAAI,YAAY,UAAU,EAAE;AAAA;",
|
|
9
|
+
"debugId": "F1D67D47267AF34764756E2164756E21",
|
|
10
|
+
"names": []
|
|
11
|
+
}
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
declare function bytesToHex(bytes: Uint8Array): string;
|
|
2
|
+
declare function hexToBytes(hex: string): Uint8Array;
|
|
3
|
+
declare function with0x(value: string): string;
|
|
4
|
+
declare function without0x(value: string): string;
|
|
5
|
+
declare function utf8ToBytes(str: string): Uint8Array;
|
|
6
|
+
declare function bytesToUtf8(bytes: Uint8Array): string;
|
|
7
|
+
declare function asciiToBytes(str: string): Uint8Array;
|
|
8
|
+
declare function bytesToAscii(bytes: Uint8Array): string;
|
|
9
|
+
declare function concatBytes(...arrays: Uint8Array[]): Uint8Array;
|
|
10
|
+
type IntegerType = number | string | bigint | Uint8Array;
|
|
11
|
+
declare function intToBigInt(value: IntegerType): bigint;
|
|
12
|
+
declare function intToBytes(value: IntegerType, byteLength: number): Uint8Array;
|
|
13
|
+
declare function bigIntToBytes(value: bigint, length?: number): Uint8Array;
|
|
14
|
+
declare function intToHex(integer: IntegerType, byteLength?: number): string;
|
|
15
|
+
declare function toTwos(value: bigint, width: bigint): bigint;
|
|
16
|
+
declare function fromTwos(value: bigint, width: bigint): bigint;
|
|
17
|
+
declare function bytesToTwosBigInt(bytes: Uint8Array): bigint;
|
|
18
|
+
declare function writeUInt32BE(value: number): Uint8Array;
|
|
19
|
+
declare function readUInt32BE(bytes: Uint8Array, offset?: number): number;
|
|
20
|
+
declare function writeUInt16BE(value: number): Uint8Array;
|
|
21
|
+
declare function readUInt16BE(bytes: Uint8Array, offset?: number): number;
|
|
22
|
+
declare function writeUInt8(value: number): Uint8Array;
|
|
23
|
+
import { ripemd160 } from "@noble/hashes/legacy";
|
|
24
|
+
import { sha256 } from "@noble/hashes/sha2";
|
|
25
|
+
import { sha512_256 } from "@noble/hashes/sha2";
|
|
26
|
+
/** RIPEMD160(SHA256(input)) — standard Bitcoin/Stacks address hash */
|
|
27
|
+
declare function hash160(input: Uint8Array): Uint8Array;
|
|
28
|
+
/** Hash used for transaction IDs */
|
|
29
|
+
declare function txidFromBytes(data: Uint8Array): string;
|
|
30
|
+
/** hash160 as hex — used for P2PKH address derivation */
|
|
31
|
+
declare function hashP2PKH(input: Uint8Array): string;
|
|
32
|
+
declare function c32address(version: number, hash160hex: string): string;
|
|
33
|
+
declare function c32addressDecode(c32addr: string): [number, string];
|
|
34
|
+
declare function validateStacksAddress(address: string): boolean;
|
|
35
|
+
/** Alias for validateStacksAddress — matches future.md naming. */
|
|
36
|
+
declare const isValidAddress: unknown;
|
|
37
|
+
declare function parseContractId(contractId: string): [string, string];
|
|
38
|
+
declare function isClarityName(name: string): boolean;
|
|
39
|
+
/**
|
|
40
|
+
* Compare two Stacks addresses for equality (case-insensitive, version-aware).
|
|
41
|
+
* Throws if either address is invalid.
|
|
42
|
+
*/
|
|
43
|
+
declare function isAddressEqual(a: string, b: string): boolean;
|
|
44
|
+
/** Extract the version byte from a Stacks address (22, 20, 26, or 21). */
|
|
45
|
+
declare function addressToVersion(address: string): number;
|
|
46
|
+
/**
|
|
47
|
+
* Build a contract address from deployer + contract name.
|
|
48
|
+
* Validates both parts; returns `deployer.contractName`.
|
|
49
|
+
*/
|
|
50
|
+
declare function getContractAddress(deployer: string, contractName: string): string;
|
|
51
|
+
declare const MAX_U128: unknown;
|
|
52
|
+
declare const MAX_I128: unknown;
|
|
53
|
+
declare const MIN_I128: unknown;
|
|
54
|
+
/** C32-encoded address version bytes for single-sig and multi-sig on each network. */
|
|
55
|
+
declare const AddressVersion: {
|
|
56
|
+
readonly MainnetSingleSig: 22
|
|
57
|
+
readonly MainnetMultiSig: 20
|
|
58
|
+
readonly TestnetSingleSig: 26
|
|
59
|
+
readonly TestnetMultiSig: 21
|
|
60
|
+
};
|
|
61
|
+
type AddressVersion = (typeof AddressVersion)[keyof typeof AddressVersion];
|
|
62
|
+
/** Mainnet burn address (all-zero hash160). */
|
|
63
|
+
declare const ZERO_ADDRESS = "SP000000000000000000002Q6VF78";
|
|
64
|
+
/** Testnet burn address (all-zero hash160). */
|
|
65
|
+
declare const TESTNET_ZERO_ADDRESS = "ST000000000000000000002AMW42H";
|
|
66
|
+
/** Number of microSTX per 1 STX (10^6). */
|
|
67
|
+
declare const MICROSTX_PER_STX = 1000000n;
|
|
68
|
+
/**
|
|
69
|
+
* Format a bigint value with decimal places.
|
|
70
|
+
* @example formatUnits(1000000n, 6) → "1.0"
|
|
71
|
+
* @example formatUnits(1500000n, 6) → "1.5"
|
|
72
|
+
*/
|
|
73
|
+
declare function formatUnits(value: bigint | number | string, decimals: number): string;
|
|
74
|
+
/**
|
|
75
|
+
* Parse a decimal string into a bigint with the given number of decimals.
|
|
76
|
+
* @example parseUnits("1.5", 6) → 1500000n
|
|
77
|
+
* @example parseUnits("1", 6) → 1000000n
|
|
78
|
+
*/
|
|
79
|
+
declare function parseUnits(value: string | number, decimals: number): bigint;
|
|
80
|
+
/**
|
|
81
|
+
* Format microSTX to STX string (6 decimals).
|
|
82
|
+
* @example formatStx(1000000n) → "1.0"
|
|
83
|
+
*/
|
|
84
|
+
declare function formatStx(microStx: bigint | number | string): string;
|
|
85
|
+
/**
|
|
86
|
+
* Parse STX string to microSTX bigint (6 decimals).
|
|
87
|
+
* @example parseStx("1.5") → 1500000n
|
|
88
|
+
*/
|
|
89
|
+
declare function parseStx(stx: string | number): bigint;
|
|
90
|
+
interface RecoverableSignature {
|
|
91
|
+
/** Recovery id (0–3) */
|
|
92
|
+
recovery: number;
|
|
93
|
+
/** 32-byte r value as hex */
|
|
94
|
+
r: string;
|
|
95
|
+
/** 32-byte s value as hex */
|
|
96
|
+
s: string;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Parse a 65-byte VRS hex signature into components.
|
|
100
|
+
* VRS format: recovery (1 byte) + r (32 bytes) + s (32 bytes)
|
|
101
|
+
*/
|
|
102
|
+
declare function parseSignature(hex: string): RecoverableSignature;
|
|
103
|
+
/**
|
|
104
|
+
* Serialize a recoverable signature to 65-byte VRS hex (130 chars).
|
|
105
|
+
*/
|
|
106
|
+
declare function serializeSignature(sig: RecoverableSignature): string;
|
|
107
|
+
/** Convert VRS hex to RSV hex: r+s (128 chars) + recovery (2 chars). */
|
|
108
|
+
declare function signatureVrsToRsv(vrs: string): string;
|
|
109
|
+
/** Convert RSV hex to VRS hex: recovery (2 chars) + r+s (128 chars). */
|
|
110
|
+
declare function signatureRsvToVrs(rsv: string): string;
|
|
111
|
+
/**
|
|
112
|
+
* Recover a public key from a message hash and VRS signature.
|
|
113
|
+
* @returns hex-encoded public key (33 bytes compressed, or 65 bytes uncompressed)
|
|
114
|
+
*/
|
|
115
|
+
declare function recoverPublicKey(hash: Uint8Array | string, signature: string, compressed?: boolean): string;
|
|
116
|
+
/**
|
|
117
|
+
* Recover a Stacks address from a message hash and VRS signature.
|
|
118
|
+
* @param addressVersion defaults to MainnetSingleSig (22)
|
|
119
|
+
*/
|
|
120
|
+
declare function recoverAddress(hash: Uint8Array | string, signature: string, addressVersion?: number): string;
|
|
121
|
+
/**
|
|
122
|
+
* Verify an ECDSA signature against a message hash and public key.
|
|
123
|
+
* Accepts compact (64-byte) signature as hex or Uint8Array.
|
|
124
|
+
*/
|
|
125
|
+
declare function verifySignature(hash: Uint8Array | string, signature: string | Uint8Array, publicKey: string | Uint8Array): boolean;
|
|
126
|
+
/**
|
|
127
|
+
* Verify a signed Stacks message.
|
|
128
|
+
* Parses a VRS signature, extracts r+s for verification.
|
|
129
|
+
* Falls back to legacy prefix if standard prefix fails.
|
|
130
|
+
*/
|
|
131
|
+
declare function verifyMessageSignature(message: string | Uint8Array, signature: string, publicKey: string): boolean;
|
|
132
|
+
/** Compress a public key to 33 bytes (hex). */
|
|
133
|
+
declare function compressPublicKey(publicKey: string | Uint8Array): string;
|
|
134
|
+
/** Uncompress a public key to 65 bytes (hex). */
|
|
135
|
+
declare function uncompressPublicKey(publicKey: string | Uint8Array): string;
|
|
136
|
+
/** Check if a public key is in compressed format (starts with 0x02 or 0x03). */
|
|
137
|
+
declare function isCompressedPublicKey(publicKey: string | Uint8Array): boolean;
|
|
138
|
+
/** Generate cryptographically secure random bytes. Defaults to 32 bytes. */
|
|
139
|
+
declare function randomBytes(length?: number): Uint8Array;
|
|
140
|
+
export { writeUInt8, writeUInt32BE, writeUInt16BE, without0x, with0x, verifySignature, verifyMessageSignature, validateStacksAddress, utf8ToBytes, uncompressPublicKey, txidFromBytes, toTwos, signatureVrsToRsv, signatureRsvToVrs, sha512_256, sha256, serializeSignature, ripemd160, recoverPublicKey, recoverAddress, readUInt32BE, readUInt16BE, randomBytes, parseUnits, parseStx, parseSignature, parseContractId, isValidAddress, isCompressedPublicKey, isClarityName, isAddressEqual, intToHex, intToBytes, intToBigInt, hexToBytes, hashP2PKH, hash160, getContractAddress, fromTwos, formatUnits, formatStx, concatBytes, compressPublicKey, c32addressDecode, c32address, bytesToUtf8, bytesToTwosBigInt, bytesToHex, bytesToAscii, bigIntToBytes, asciiToBytes, addressToVersion, ZERO_ADDRESS, TESTNET_ZERO_ADDRESS, RecoverableSignature, MIN_I128, MICROSTX_PER_STX, MAX_U128, MAX_I128, IntegerType, AddressVersion };
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
declare function bytesToHex(bytes: Uint8Array): string;
|
|
2
|
+
declare function hexToBytes(hex: string): Uint8Array;
|
|
3
|
+
declare function with0x(value: string): string;
|
|
4
|
+
declare function without0x(value: string): string;
|
|
5
|
+
declare function utf8ToBytes(str: string): Uint8Array;
|
|
6
|
+
declare function bytesToUtf8(bytes: Uint8Array): string;
|
|
7
|
+
declare function asciiToBytes(str: string): Uint8Array;
|
|
8
|
+
declare function bytesToAscii(bytes: Uint8Array): string;
|
|
9
|
+
declare function concatBytes(...arrays: Uint8Array[]): Uint8Array;
|
|
10
|
+
type IntegerType = number | string | bigint | Uint8Array;
|
|
11
|
+
declare function intToBigInt(value: IntegerType): bigint;
|
|
12
|
+
declare function intToBytes(value: IntegerType, byteLength: number): Uint8Array;
|
|
13
|
+
declare function bigIntToBytes(value: bigint, length?: number): Uint8Array;
|
|
14
|
+
declare function intToHex(integer: IntegerType, byteLength?: number): string;
|
|
15
|
+
declare function toTwos(value: bigint, width: bigint): bigint;
|
|
16
|
+
declare function fromTwos(value: bigint, width: bigint): bigint;
|
|
17
|
+
declare function bytesToTwosBigInt(bytes: Uint8Array): bigint;
|
|
18
|
+
declare function writeUInt32BE(value: number): Uint8Array;
|
|
19
|
+
declare function readUInt32BE(bytes: Uint8Array, offset?: number): number;
|
|
20
|
+
declare function writeUInt16BE(value: number): Uint8Array;
|
|
21
|
+
declare function readUInt16BE(bytes: Uint8Array, offset?: number): number;
|
|
22
|
+
declare function writeUInt8(value: number): Uint8Array;
|
|
23
|
+
import { ripemd160 } from "@noble/hashes/legacy";
|
|
24
|
+
import { sha256 } from "@noble/hashes/sha2";
|
|
25
|
+
import { sha512_256 } from "@noble/hashes/sha2";
|
|
26
|
+
/** RIPEMD160(SHA256(input)) — standard Bitcoin/Stacks address hash */
|
|
27
|
+
declare function hash160(input: Uint8Array): Uint8Array;
|
|
28
|
+
/** Hash used for transaction IDs */
|
|
29
|
+
declare function txidFromBytes(data: Uint8Array): string;
|
|
30
|
+
/** hash160 as hex — used for P2PKH address derivation */
|
|
31
|
+
declare function hashP2PKH(input: Uint8Array): string;
|
|
32
|
+
declare function c32address(version: number, hash160hex: string): string;
|
|
33
|
+
declare function c32addressDecode(c32addr: string): [number, string];
|
|
34
|
+
declare function validateStacksAddress(address: string): boolean;
|
|
35
|
+
/** Alias for validateStacksAddress — matches future.md naming. */
|
|
36
|
+
declare const isValidAddress: unknown;
|
|
37
|
+
declare function parseContractId(contractId: string): [string, string];
|
|
38
|
+
declare function isClarityName(name: string): boolean;
|
|
39
|
+
/**
|
|
40
|
+
* Compare two Stacks addresses for equality (case-insensitive, version-aware).
|
|
41
|
+
* Throws if either address is invalid.
|
|
42
|
+
*/
|
|
43
|
+
declare function isAddressEqual(a: string, b: string): boolean;
|
|
44
|
+
/** Extract the version byte from a Stacks address (22, 20, 26, or 21). */
|
|
45
|
+
declare function addressToVersion(address: string): number;
|
|
46
|
+
/**
|
|
47
|
+
* Build a contract address from deployer + contract name.
|
|
48
|
+
* Validates both parts; returns `deployer.contractName`.
|
|
49
|
+
*/
|
|
50
|
+
declare function getContractAddress(deployer: string, contractName: string): string;
|
|
51
|
+
declare const MAX_U128: unknown;
|
|
52
|
+
declare const MAX_I128: unknown;
|
|
53
|
+
declare const MIN_I128: unknown;
|
|
54
|
+
/** C32-encoded address version bytes for single-sig and multi-sig on each network. */
|
|
55
|
+
declare const AddressVersion: {
|
|
56
|
+
readonly MainnetSingleSig: 22
|
|
57
|
+
readonly MainnetMultiSig: 20
|
|
58
|
+
readonly TestnetSingleSig: 26
|
|
59
|
+
readonly TestnetMultiSig: 21
|
|
60
|
+
};
|
|
61
|
+
type AddressVersion = (typeof AddressVersion)[keyof typeof AddressVersion];
|
|
62
|
+
/** Mainnet burn address (all-zero hash160). */
|
|
63
|
+
declare const ZERO_ADDRESS = "SP000000000000000000002Q6VF78";
|
|
64
|
+
/** Testnet burn address (all-zero hash160). */
|
|
65
|
+
declare const TESTNET_ZERO_ADDRESS = "ST000000000000000000002AMW42H";
|
|
66
|
+
/** Number of microSTX per 1 STX (10^6). */
|
|
67
|
+
declare const MICROSTX_PER_STX = 1000000n;
|
|
68
|
+
/**
|
|
69
|
+
* Format a bigint value with decimal places.
|
|
70
|
+
* @example formatUnits(1000000n, 6) → "1.0"
|
|
71
|
+
* @example formatUnits(1500000n, 6) → "1.5"
|
|
72
|
+
*/
|
|
73
|
+
declare function formatUnits(value: bigint | number | string, decimals: number): string;
|
|
74
|
+
/**
|
|
75
|
+
* Parse a decimal string into a bigint with the given number of decimals.
|
|
76
|
+
* @example parseUnits("1.5", 6) → 1500000n
|
|
77
|
+
* @example parseUnits("1", 6) → 1000000n
|
|
78
|
+
*/
|
|
79
|
+
declare function parseUnits(value: string | number, decimals: number): bigint;
|
|
80
|
+
/**
|
|
81
|
+
* Format microSTX to STX string (6 decimals).
|
|
82
|
+
* @example formatStx(1000000n) → "1.0"
|
|
83
|
+
*/
|
|
84
|
+
declare function formatStx(microStx: bigint | number | string): string;
|
|
85
|
+
/**
|
|
86
|
+
* Parse STX string to microSTX bigint (6 decimals).
|
|
87
|
+
* @example parseStx("1.5") → 1500000n
|
|
88
|
+
*/
|
|
89
|
+
declare function parseStx(stx: string | number): bigint;
|
|
90
|
+
interface RecoverableSignature {
|
|
91
|
+
/** Recovery id (0–3) */
|
|
92
|
+
recovery: number;
|
|
93
|
+
/** 32-byte r value as hex */
|
|
94
|
+
r: string;
|
|
95
|
+
/** 32-byte s value as hex */
|
|
96
|
+
s: string;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Parse a 65-byte VRS hex signature into components.
|
|
100
|
+
* VRS format: recovery (1 byte) + r (32 bytes) + s (32 bytes)
|
|
101
|
+
*/
|
|
102
|
+
declare function parseSignature(hex: string): RecoverableSignature;
|
|
103
|
+
/**
|
|
104
|
+
* Serialize a recoverable signature to 65-byte VRS hex (130 chars).
|
|
105
|
+
*/
|
|
106
|
+
declare function serializeSignature(sig: RecoverableSignature): string;
|
|
107
|
+
/** Convert VRS hex to RSV hex: r+s (128 chars) + recovery (2 chars). */
|
|
108
|
+
declare function signatureVrsToRsv(vrs: string): string;
|
|
109
|
+
/** Convert RSV hex to VRS hex: recovery (2 chars) + r+s (128 chars). */
|
|
110
|
+
declare function signatureRsvToVrs(rsv: string): string;
|
|
111
|
+
/**
|
|
112
|
+
* Recover a public key from a message hash and VRS signature.
|
|
113
|
+
* @returns hex-encoded public key (33 bytes compressed, or 65 bytes uncompressed)
|
|
114
|
+
*/
|
|
115
|
+
declare function recoverPublicKey(hash: Uint8Array | string, signature: string, compressed?: boolean): string;
|
|
116
|
+
/**
|
|
117
|
+
* Recover a Stacks address from a message hash and VRS signature.
|
|
118
|
+
* @param addressVersion defaults to MainnetSingleSig (22)
|
|
119
|
+
*/
|
|
120
|
+
declare function recoverAddress(hash: Uint8Array | string, signature: string, addressVersion?: number): string;
|
|
121
|
+
/**
|
|
122
|
+
* Verify an ECDSA signature against a message hash and public key.
|
|
123
|
+
* Accepts compact (64-byte) signature as hex or Uint8Array.
|
|
124
|
+
*/
|
|
125
|
+
declare function verifySignature(hash: Uint8Array | string, signature: string | Uint8Array, publicKey: string | Uint8Array): boolean;
|
|
126
|
+
/**
|
|
127
|
+
* Verify a signed Stacks message.
|
|
128
|
+
* Parses a VRS signature, extracts r+s for verification.
|
|
129
|
+
* Falls back to legacy prefix if standard prefix fails.
|
|
130
|
+
*/
|
|
131
|
+
declare function verifyMessageSignature(message: string | Uint8Array, signature: string, publicKey: string): boolean;
|
|
132
|
+
/** Compress a public key to 33 bytes (hex). */
|
|
133
|
+
declare function compressPublicKey(publicKey: string | Uint8Array): string;
|
|
134
|
+
/** Uncompress a public key to 65 bytes (hex). */
|
|
135
|
+
declare function uncompressPublicKey(publicKey: string | Uint8Array): string;
|
|
136
|
+
/** Check if a public key is in compressed format (starts with 0x02 or 0x03). */
|
|
137
|
+
declare function isCompressedPublicKey(publicKey: string | Uint8Array): boolean;
|
|
138
|
+
/** Generate cryptographically secure random bytes. Defaults to 32 bytes. */
|
|
139
|
+
declare function randomBytes(length?: number): Uint8Array;
|
|
140
|
+
export { writeUInt8, writeUInt32BE, writeUInt16BE, without0x, with0x, verifySignature, verifyMessageSignature, validateStacksAddress, utf8ToBytes, uncompressPublicKey, txidFromBytes, toTwos, signatureVrsToRsv, signatureRsvToVrs, sha512_256, sha256, serializeSignature, ripemd160, recoverPublicKey, recoverAddress, readUInt32BE, readUInt16BE, randomBytes, parseUnits, parseStx, parseSignature, parseContractId, isValidAddress, isCompressedPublicKey, isClarityName, isAddressEqual, intToHex, intToBytes, intToBigInt, hexToBytes, hashP2PKH, hash160, getContractAddress, fromTwos, formatUnits, formatStx, concatBytes, compressPublicKey, c32addressDecode, c32address, bytesToUtf8, bytesToTwosBigInt, bytesToHex, bytesToAscii, bigIntToBytes, asciiToBytes, addressToVersion, ZERO_ADDRESS, TESTNET_ZERO_ADDRESS, RecoverableSignature, MIN_I128, MICROSTX_PER_STX, MAX_U128, MAX_I128, IntegerType, AddressVersion };
|
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
import {
|
|
2
|
+
formatStx,
|
|
3
|
+
formatUnits,
|
|
4
|
+
parseStx,
|
|
5
|
+
parseUnits
|
|
6
|
+
} from "../../shared/stacks-k2p5tv6x.js";
|
|
7
|
+
import {
|
|
8
|
+
AddressVersion,
|
|
9
|
+
MAX_I128,
|
|
10
|
+
MAX_U128,
|
|
11
|
+
MICROSTX_PER_STX,
|
|
12
|
+
MIN_I128,
|
|
13
|
+
TESTNET_ZERO_ADDRESS,
|
|
14
|
+
ZERO_ADDRESS
|
|
15
|
+
} from "../../shared/stacks-v9jqcpd4.js";
|
|
16
|
+
import {
|
|
17
|
+
hash160,
|
|
18
|
+
hashP2PKH,
|
|
19
|
+
ripemd160,
|
|
20
|
+
sha256,
|
|
21
|
+
sha512_256,
|
|
22
|
+
txidFromBytes
|
|
23
|
+
} from "../../shared/stacks-bycy6t9k.js";
|
|
24
|
+
import {
|
|
25
|
+
addressToVersion,
|
|
26
|
+
getContractAddress,
|
|
27
|
+
isAddressEqual,
|
|
28
|
+
isClarityName,
|
|
29
|
+
isValidAddress,
|
|
30
|
+
parseContractId,
|
|
31
|
+
validateStacksAddress
|
|
32
|
+
} from "../../shared/stacks-gjvbq6w7.js";
|
|
33
|
+
import {
|
|
34
|
+
asciiToBytes,
|
|
35
|
+
bigIntToBytes,
|
|
36
|
+
bytesToAscii,
|
|
37
|
+
bytesToHex,
|
|
38
|
+
bytesToTwosBigInt,
|
|
39
|
+
bytesToUtf8,
|
|
40
|
+
c32address,
|
|
41
|
+
c32addressDecode,
|
|
42
|
+
concatBytes,
|
|
43
|
+
fromTwos,
|
|
44
|
+
hexToBytes,
|
|
45
|
+
intToBigInt,
|
|
46
|
+
intToBytes,
|
|
47
|
+
intToHex,
|
|
48
|
+
readUInt16BE,
|
|
49
|
+
readUInt32BE,
|
|
50
|
+
toTwos,
|
|
51
|
+
utf8ToBytes,
|
|
52
|
+
with0x,
|
|
53
|
+
without0x,
|
|
54
|
+
writeUInt16BE,
|
|
55
|
+
writeUInt32BE,
|
|
56
|
+
writeUInt8
|
|
57
|
+
} from "../../shared/stacks-nqytwfcc.js";
|
|
58
|
+
import"../../shared/stacks-8m9byk2j.js";
|
|
59
|
+
// src/utils/signature.ts
|
|
60
|
+
import { Signature as NobleSignature, verify } from "@noble/secp256k1";
|
|
61
|
+
import { sha256 as sha2562 } from "@noble/hashes/sha2.js";
|
|
62
|
+
function parseSignature(hex) {
|
|
63
|
+
const clean = hex.startsWith("0x") ? hex.slice(2) : hex;
|
|
64
|
+
if (clean.length !== 130) {
|
|
65
|
+
throw new Error(`Invalid signature length: expected 130 hex chars, got ${clean.length}`);
|
|
66
|
+
}
|
|
67
|
+
return {
|
|
68
|
+
recovery: parseInt(clean.slice(0, 2), 16),
|
|
69
|
+
r: clean.slice(2, 66),
|
|
70
|
+
s: clean.slice(66, 130)
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
function serializeSignature(sig) {
|
|
74
|
+
const v = sig.recovery.toString(16).padStart(2, "0");
|
|
75
|
+
return v + sig.r + sig.s;
|
|
76
|
+
}
|
|
77
|
+
function signatureVrsToRsv(vrs) {
|
|
78
|
+
const clean = vrs.startsWith("0x") ? vrs.slice(2) : vrs;
|
|
79
|
+
return clean.slice(2) + clean.slice(0, 2);
|
|
80
|
+
}
|
|
81
|
+
function signatureRsvToVrs(rsv) {
|
|
82
|
+
const clean = rsv.startsWith("0x") ? rsv.slice(2) : rsv;
|
|
83
|
+
return clean.slice(-2) + clean.slice(0, -2);
|
|
84
|
+
}
|
|
85
|
+
function recoverPublicKey(hash, signature, compressed = true) {
|
|
86
|
+
const parsed = parseSignature(signature);
|
|
87
|
+
const rs = parsed.r + parsed.s;
|
|
88
|
+
const sig = NobleSignature.fromCompact(rs).addRecoveryBit(parsed.recovery);
|
|
89
|
+
const msgHash = typeof hash === "string" ? hexToBytes(hash) : hash;
|
|
90
|
+
const point = sig.recoverPublicKey(msgHash);
|
|
91
|
+
return point.toHex(compressed);
|
|
92
|
+
}
|
|
93
|
+
function recoverAddress(hash, signature, addressVersion = AddressVersion.MainnetSingleSig) {
|
|
94
|
+
const pubkey = recoverPublicKey(hash, signature, true);
|
|
95
|
+
const pubkeyHash = hashP2PKH(hexToBytes(pubkey));
|
|
96
|
+
return c32address(addressVersion, pubkeyHash);
|
|
97
|
+
}
|
|
98
|
+
function verifySignature(hash, signature, publicKey) {
|
|
99
|
+
return verify(signature, hash, publicKey, { lowS: false });
|
|
100
|
+
}
|
|
101
|
+
function encodeVarint(n) {
|
|
102
|
+
if (n < 253)
|
|
103
|
+
return new Uint8Array([n]);
|
|
104
|
+
if (n <= 65535) {
|
|
105
|
+
const buf2 = new Uint8Array(3);
|
|
106
|
+
buf2[0] = 253;
|
|
107
|
+
buf2[1] = n & 255;
|
|
108
|
+
buf2[2] = n >> 8 & 255;
|
|
109
|
+
return buf2;
|
|
110
|
+
}
|
|
111
|
+
const buf = new Uint8Array(5);
|
|
112
|
+
buf[0] = 254;
|
|
113
|
+
buf[1] = n & 255;
|
|
114
|
+
buf[2] = n >> 8 & 255;
|
|
115
|
+
buf[3] = n >> 16 & 255;
|
|
116
|
+
buf[4] = n >> 24 & 255;
|
|
117
|
+
return buf;
|
|
118
|
+
}
|
|
119
|
+
var STACKS_MESSAGE_PREFIX = `\x17Stacks Signed Message:
|
|
120
|
+
`;
|
|
121
|
+
var LEGACY_MESSAGE_PREFIX = `\x18Stacks Message Signing:
|
|
122
|
+
`;
|
|
123
|
+
function hashMessage(message, prefix) {
|
|
124
|
+
const messageBytes = typeof message === "string" ? utf8ToBytes(message) : message;
|
|
125
|
+
const prefixBytes = utf8ToBytes(prefix);
|
|
126
|
+
const lengthBytes = encodeVarint(messageBytes.length);
|
|
127
|
+
return sha2562(concatBytes(prefixBytes, lengthBytes, messageBytes));
|
|
128
|
+
}
|
|
129
|
+
function verifyMessageSignature(message, signature, publicKey) {
|
|
130
|
+
const parsed = parseSignature(signature);
|
|
131
|
+
const compactSig = parsed.r + parsed.s;
|
|
132
|
+
const msgHash = hashMessage(message, STACKS_MESSAGE_PREFIX);
|
|
133
|
+
if (verify(compactSig, msgHash, publicKey, { lowS: false }))
|
|
134
|
+
return true;
|
|
135
|
+
if (typeof message === "string") {
|
|
136
|
+
const legacyHash = hashMessage(message, LEGACY_MESSAGE_PREFIX);
|
|
137
|
+
if (verify(compactSig, legacyHash, publicKey, { lowS: false }))
|
|
138
|
+
return true;
|
|
139
|
+
}
|
|
140
|
+
return false;
|
|
141
|
+
}
|
|
142
|
+
// src/utils/keys.ts
|
|
143
|
+
import { Point as Point2, etc } from "@noble/secp256k1";
|
|
144
|
+
function compressPublicKey(publicKey) {
|
|
145
|
+
const hex = typeof publicKey === "string" ? publicKey : bytesToHex(publicKey);
|
|
146
|
+
return Point2.fromHex(hex).toHex(true);
|
|
147
|
+
}
|
|
148
|
+
function uncompressPublicKey(publicKey) {
|
|
149
|
+
const hex = typeof publicKey === "string" ? publicKey : bytesToHex(publicKey);
|
|
150
|
+
return Point2.fromHex(hex).toHex(false);
|
|
151
|
+
}
|
|
152
|
+
function isCompressedPublicKey(publicKey) {
|
|
153
|
+
const bytes = typeof publicKey === "string" ? hexToBytes(publicKey) : publicKey;
|
|
154
|
+
return bytes.length === 33 && (bytes[0] === 2 || bytes[0] === 3);
|
|
155
|
+
}
|
|
156
|
+
function randomBytes(length) {
|
|
157
|
+
return etc.randomBytes(length ?? 32);
|
|
158
|
+
}
|
|
159
|
+
export {
|
|
160
|
+
writeUInt8,
|
|
161
|
+
writeUInt32BE,
|
|
162
|
+
writeUInt16BE,
|
|
163
|
+
without0x,
|
|
164
|
+
with0x,
|
|
165
|
+
verifySignature,
|
|
166
|
+
verifyMessageSignature,
|
|
167
|
+
validateStacksAddress,
|
|
168
|
+
utf8ToBytes,
|
|
169
|
+
uncompressPublicKey,
|
|
170
|
+
txidFromBytes,
|
|
171
|
+
toTwos,
|
|
172
|
+
signatureVrsToRsv,
|
|
173
|
+
signatureRsvToVrs,
|
|
174
|
+
sha512_256,
|
|
175
|
+
sha256,
|
|
176
|
+
serializeSignature,
|
|
177
|
+
ripemd160,
|
|
178
|
+
recoverPublicKey,
|
|
179
|
+
recoverAddress,
|
|
180
|
+
readUInt32BE,
|
|
181
|
+
readUInt16BE,
|
|
182
|
+
randomBytes,
|
|
183
|
+
parseUnits,
|
|
184
|
+
parseStx,
|
|
185
|
+
parseSignature,
|
|
186
|
+
parseContractId,
|
|
187
|
+
isValidAddress,
|
|
188
|
+
isCompressedPublicKey,
|
|
189
|
+
isClarityName,
|
|
190
|
+
isAddressEqual,
|
|
191
|
+
intToHex,
|
|
192
|
+
intToBytes,
|
|
193
|
+
intToBigInt,
|
|
194
|
+
hexToBytes,
|
|
195
|
+
hashP2PKH,
|
|
196
|
+
hash160,
|
|
197
|
+
getContractAddress,
|
|
198
|
+
fromTwos,
|
|
199
|
+
formatUnits,
|
|
200
|
+
formatStx,
|
|
201
|
+
concatBytes,
|
|
202
|
+
compressPublicKey,
|
|
203
|
+
c32addressDecode,
|
|
204
|
+
c32address,
|
|
205
|
+
bytesToUtf8,
|
|
206
|
+
bytesToTwosBigInt,
|
|
207
|
+
bytesToHex,
|
|
208
|
+
bytesToAscii,
|
|
209
|
+
bigIntToBytes,
|
|
210
|
+
asciiToBytes,
|
|
211
|
+
addressToVersion,
|
|
212
|
+
ZERO_ADDRESS,
|
|
213
|
+
TESTNET_ZERO_ADDRESS,
|
|
214
|
+
MIN_I128,
|
|
215
|
+
MICROSTX_PER_STX,
|
|
216
|
+
MAX_U128,
|
|
217
|
+
MAX_I128,
|
|
218
|
+
AddressVersion
|
|
219
|
+
};
|
|
220
|
+
|
|
221
|
+
//# debugId=5ED999593A751F3B64756E2164756E21
|
|
222
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/utils/signature.ts", "../src/utils/keys.ts"],
|
|
4
|
+
"sourcesContent": [
|
|
5
|
+
"import { Signature as NobleSignature, verify, Point } from \"@noble/secp256k1\";\nimport { sha256 } from \"@noble/hashes/sha2.js\";\nimport { bytesToHex, hexToBytes, concatBytes, utf8ToBytes } from \"./encoding.ts\";\nimport { hash160, hashP2PKH } from \"./hash.ts\";\nimport { c32address } from \"./address.ts\";\nimport { AddressVersion } from \"./constants.ts\";\n\nexport interface RecoverableSignature {\n /** Recovery id (0–3) */\n recovery: number;\n /** 32-byte r value as hex */\n r: string;\n /** 32-byte s value as hex */\n s: string;\n}\n\n// --- Format conversion ---\n\n/**\n * Parse a 65-byte VRS hex signature into components.\n * VRS format: recovery (1 byte) + r (32 bytes) + s (32 bytes)\n */\nexport function parseSignature(hex: string): RecoverableSignature {\n const clean = hex.startsWith(\"0x\") ? hex.slice(2) : hex;\n if (clean.length !== 130) {\n throw new Error(`Invalid signature length: expected 130 hex chars, got ${clean.length}`);\n }\n return {\n recovery: parseInt(clean.slice(0, 2), 16),\n r: clean.slice(2, 66),\n s: clean.slice(66, 130),\n };\n}\n\n/**\n * Serialize a recoverable signature to 65-byte VRS hex (130 chars).\n */\nexport function serializeSignature(sig: RecoverableSignature): string {\n const v = sig.recovery.toString(16).padStart(2, \"0\");\n return v + sig.r + sig.s;\n}\n\n/** Convert VRS hex to RSV hex: r+s (128 chars) + recovery (2 chars). */\nexport function signatureVrsToRsv(vrs: string): string {\n const clean = vrs.startsWith(\"0x\") ? vrs.slice(2) : vrs;\n return clean.slice(2) + clean.slice(0, 2);\n}\n\n/** Convert RSV hex to VRS hex: recovery (2 chars) + r+s (128 chars). */\nexport function signatureRsvToVrs(rsv: string): string {\n const clean = rsv.startsWith(\"0x\") ? rsv.slice(2) : rsv;\n return clean.slice(-2) + clean.slice(0, -2);\n}\n\n// --- Recovery ---\n\n/**\n * Recover a public key from a message hash and VRS signature.\n * @returns hex-encoded public key (33 bytes compressed, or 65 bytes uncompressed)\n */\nexport function recoverPublicKey(\n hash: Uint8Array | string,\n signature: string,\n compressed = true\n): string {\n const parsed = parseSignature(signature);\n const rs = parsed.r + parsed.s;\n const sig = NobleSignature.fromCompact(rs).addRecoveryBit(parsed.recovery);\n const msgHash = typeof hash === \"string\" ? hexToBytes(hash) : hash;\n const point = sig.recoverPublicKey(msgHash);\n return point.toHex(compressed);\n}\n\n/**\n * Recover a Stacks address from a message hash and VRS signature.\n * @param addressVersion defaults to MainnetSingleSig (22)\n */\nexport function recoverAddress(\n hash: Uint8Array | string,\n signature: string,\n addressVersion: number = AddressVersion.MainnetSingleSig\n): string {\n const pubkey = recoverPublicKey(hash, signature, true);\n const pubkeyHash = hashP2PKH(hexToBytes(pubkey));\n return c32address(addressVersion, pubkeyHash);\n}\n\n// --- Verification ---\n\n/**\n * Verify an ECDSA signature against a message hash and public key.\n * Accepts compact (64-byte) signature as hex or Uint8Array.\n */\nexport function verifySignature(\n hash: Uint8Array | string,\n signature: string | Uint8Array,\n publicKey: string | Uint8Array\n): boolean {\n return verify(signature, hash, publicKey, { lowS: false });\n}\n\n/** Bitcoin-style varint encoding for message length prefix. */\nfunction encodeVarint(n: number): Uint8Array {\n if (n < 0xfd) return new Uint8Array([n]);\n if (n <= 0xffff) {\n const buf = new Uint8Array(3);\n buf[0] = 0xfd;\n buf[1] = n & 0xff;\n buf[2] = (n >> 8) & 0xff;\n return buf;\n }\n const buf = new Uint8Array(5);\n buf[0] = 0xfe;\n buf[1] = n & 0xff;\n buf[2] = (n >> 8) & 0xff;\n buf[3] = (n >> 16) & 0xff;\n buf[4] = (n >> 24) & 0xff;\n return buf;\n}\n\nconst STACKS_MESSAGE_PREFIX = \"\\x17Stacks Signed Message:\\n\";\nconst LEGACY_MESSAGE_PREFIX = \"\\x18Stacks Message Signing:\\n\";\n\n/** Hash a message with the Stacks structured message prefix. */\nfunction hashMessage(message: string | Uint8Array, prefix: string): Uint8Array {\n const messageBytes = typeof message === \"string\" ? utf8ToBytes(message) : message;\n const prefixBytes = utf8ToBytes(prefix);\n const lengthBytes = encodeVarint(messageBytes.length);\n return sha256(concatBytes(prefixBytes, lengthBytes, messageBytes));\n}\n\n/**\n * Verify a signed Stacks message.\n * Parses a VRS signature, extracts r+s for verification.\n * Falls back to legacy prefix if standard prefix fails.\n */\nexport function verifyMessageSignature(\n message: string | Uint8Array,\n signature: string,\n publicKey: string\n): boolean {\n const parsed = parseSignature(signature);\n const compactSig = parsed.r + parsed.s;\n\n const msgHash = hashMessage(message, STACKS_MESSAGE_PREFIX);\n if (verify(compactSig, msgHash, publicKey, { lowS: false })) return true;\n\n // Fallback to legacy prefix\n if (typeof message === \"string\") {\n const legacyHash = hashMessage(message, LEGACY_MESSAGE_PREFIX);\n if (verify(compactSig, legacyHash, publicKey, { lowS: false })) return true;\n }\n\n return false;\n}\n",
|
|
6
|
+
"import { Point, etc } from \"@noble/secp256k1\";\nimport { bytesToHex, hexToBytes } from \"./encoding.ts\";\n\n/** Compress a public key to 33 bytes (hex). */\nexport function compressPublicKey(publicKey: string | Uint8Array): string {\n const hex = typeof publicKey === \"string\" ? publicKey : bytesToHex(publicKey);\n return Point.fromHex(hex).toHex(true);\n}\n\n/** Uncompress a public key to 65 bytes (hex). */\nexport function uncompressPublicKey(publicKey: string | Uint8Array): string {\n const hex = typeof publicKey === \"string\" ? publicKey : bytesToHex(publicKey);\n return Point.fromHex(hex).toHex(false);\n}\n\n/** Check if a public key is in compressed format (starts with 0x02 or 0x03). */\nexport function isCompressedPublicKey(publicKey: string | Uint8Array): boolean {\n const bytes = typeof publicKey === \"string\" ? hexToBytes(publicKey) : publicKey;\n return bytes.length === 33 && (bytes[0] === 0x02 || bytes[0] === 0x03);\n}\n\n/** Generate cryptographically secure random bytes. Defaults to 32 bytes. */\nexport function randomBytes(length?: number): Uint8Array {\n return etc.randomBytes(length ?? 32);\n}\n"
|
|
7
|
+
],
|
|
8
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,sBAAS;AACT,mBAAS;AAqBF,SAAS,cAAc,CAAC,KAAmC;AAAA,EAChE,MAAM,QAAQ,IAAI,WAAW,IAAI,IAAI,IAAI,MAAM,CAAC,IAAI;AAAA,EACpD,IAAI,MAAM,WAAW,KAAK;AAAA,IACxB,MAAM,IAAI,MAAM,yDAAyD,MAAM,QAAQ;AAAA,EACzF;AAAA,EACA,OAAO;AAAA,IACL,UAAU,SAAS,MAAM,MAAM,GAAG,CAAC,GAAG,EAAE;AAAA,IACxC,GAAG,MAAM,MAAM,GAAG,EAAE;AAAA,IACpB,GAAG,MAAM,MAAM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O;AAAA;;ACzJT,kBAAS;AAIF,SAAS,iBAAiB,CAAC,WAAwC;AAAA,EACxE,MAAM,MAAM,OAAO,cAAc,WAAW,YAAY,WAAW,SAAS;AAAA,EAC5E,OAAO,OAAM,QAAQ,GAAG,EAAE,MAAM,IAAI;AAAA;AAI/B,SAAS,mBAAmB,CAAC,WAAwC;AAAA,EAC1E,MAAM,MAAM,OAAO,cAAc,WAAW,YAAY,WAAW,SAAS;AAAA,EAC5E,OAAO,OAAM,QAAQ,GAAG,EAAE,MAAM,KAAK;AAAA;AAIhC,SAAS,qBAAqB,CAAC,WAAyC;AAAA,EAC7E,MAAM,QAAQ,OAAO,cAAc,WAAW,WAAW,SAAS,IAAI;AAAA,EACtE,OAAO,MAAM,WAAW,OAAO,MAAM,OAAO,KAAQ,MAAM,OAAO;AAAA;AAI5D,SAAS,WAAW,CAAC,QAA6B;AAAA,EACvD,OAAO,IAAI,YAAY,UAAU,EAAE;AAAA;",
|
|
9
|
+
"debugId": "5ED999593A751F3B64756E2164756E21",
|
|
10
|
+
"names": []
|
|
11
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@secondlayer/stacks",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "A viem-style SDK for the Stacks blockchain",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/src/index.cjs",
|
|
7
|
+
"module": "./dist/src/index.js",
|
|
8
|
+
"types": "./dist/src/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/src/index.d.ts",
|
|
12
|
+
"import": "./dist/src/index.js",
|
|
13
|
+
"require": "./dist/src/index.cjs"
|
|
14
|
+
},
|
|
15
|
+
"./accounts": {
|
|
16
|
+
"types": "./dist/src/accounts/index.d.ts",
|
|
17
|
+
"import": "./dist/src/accounts/index.js",
|
|
18
|
+
"require": "./dist/src/accounts/index.cjs"
|
|
19
|
+
},
|
|
20
|
+
"./chains": {
|
|
21
|
+
"types": "./dist/src/chains/index.d.ts",
|
|
22
|
+
"import": "./dist/src/chains/index.js",
|
|
23
|
+
"require": "./dist/src/chains/index.cjs"
|
|
24
|
+
},
|
|
25
|
+
"./clarity": {
|
|
26
|
+
"types": "./dist/src/clarity/index.d.ts",
|
|
27
|
+
"import": "./dist/src/clarity/index.js",
|
|
28
|
+
"require": "./dist/src/clarity/index.cjs"
|
|
29
|
+
},
|
|
30
|
+
"./actions": {
|
|
31
|
+
"types": "./dist/src/actions/index.d.ts",
|
|
32
|
+
"import": "./dist/src/actions/index.js",
|
|
33
|
+
"require": "./dist/src/actions/index.cjs"
|
|
34
|
+
},
|
|
35
|
+
"./postconditions": {
|
|
36
|
+
"types": "./dist/src/postconditions/index.d.ts",
|
|
37
|
+
"import": "./dist/src/postconditions/index.js",
|
|
38
|
+
"require": "./dist/src/postconditions/index.cjs"
|
|
39
|
+
},
|
|
40
|
+
"./transactions": {
|
|
41
|
+
"types": "./dist/src/transactions/index.d.ts",
|
|
42
|
+
"import": "./dist/src/transactions/index.js",
|
|
43
|
+
"require": "./dist/src/transactions/index.cjs"
|
|
44
|
+
},
|
|
45
|
+
"./utils": {
|
|
46
|
+
"types": "./dist/src/utils/index.d.ts",
|
|
47
|
+
"import": "./dist/src/utils/index.js",
|
|
48
|
+
"require": "./dist/src/utils/index.cjs"
|
|
49
|
+
},
|
|
50
|
+
"./connect": {
|
|
51
|
+
"types": "./dist/src/connect/index.d.ts",
|
|
52
|
+
"import": "./dist/src/connect/index.js",
|
|
53
|
+
"require": "./dist/src/connect/index.cjs"
|
|
54
|
+
},
|
|
55
|
+
"./bns": {
|
|
56
|
+
"types": "./dist/src/bns/index.d.ts",
|
|
57
|
+
"import": "./dist/src/bns/index.js",
|
|
58
|
+
"require": "./dist/src/bns/index.cjs"
|
|
59
|
+
},
|
|
60
|
+
"./pox": {
|
|
61
|
+
"types": "./dist/src/pox/index.d.ts",
|
|
62
|
+
"import": "./dist/src/pox/index.js",
|
|
63
|
+
"require": "./dist/src/pox/index.cjs"
|
|
64
|
+
},
|
|
65
|
+
"./stackingdao": {
|
|
66
|
+
"types": "./dist/src/stackingdao/index.d.ts",
|
|
67
|
+
"import": "./dist/src/stackingdao/index.js",
|
|
68
|
+
"require": "./dist/src/stackingdao/index.cjs"
|
|
69
|
+
},
|
|
70
|
+
"./subscriptions": {
|
|
71
|
+
"types": "./dist/src/subscriptions/index.d.ts",
|
|
72
|
+
"import": "./dist/src/subscriptions/index.js",
|
|
73
|
+
"require": "./dist/src/subscriptions/index.cjs"
|
|
74
|
+
},
|
|
75
|
+
"./connect/walletconnect": {
|
|
76
|
+
"types": "./dist/src/connect/walletconnect/index.d.ts",
|
|
77
|
+
"import": "./dist/src/connect/walletconnect/index.js",
|
|
78
|
+
"require": "./dist/src/connect/walletconnect/index.cjs"
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
"files": ["dist"],
|
|
82
|
+
"scripts": {
|
|
83
|
+
"build": "bunup",
|
|
84
|
+
"test": "bun test",
|
|
85
|
+
"typecheck": "tsc --noEmit",
|
|
86
|
+
"prepublishOnly": "bun run build"
|
|
87
|
+
},
|
|
88
|
+
"publishConfig": {
|
|
89
|
+
"access": "public"
|
|
90
|
+
},
|
|
91
|
+
"devDependencies": {
|
|
92
|
+
"@types/bun": "latest"
|
|
93
|
+
},
|
|
94
|
+
"peerDependencies": {
|
|
95
|
+
"typescript": "^5"
|
|
96
|
+
},
|
|
97
|
+
"dependencies": {
|
|
98
|
+
"@noble/hashes": "2.0.1",
|
|
99
|
+
"@noble/secp256k1": "2.3.0",
|
|
100
|
+
"@scure/bip32": "2.0.1",
|
|
101
|
+
"@noble/ciphers": "2.1.1",
|
|
102
|
+
"@noble/curves": "2.0.1",
|
|
103
|
+
"@scure/bip39": "2.0.1"
|
|
104
|
+
}
|
|
105
|
+
}
|