From a1d9a680e1a6b3947449967238d021098a9edbe6 Mon Sep 17 00:00:00 2001 From: RGGH Date: Mon, 4 Nov 2024 16:01:40 +0000 Subject: [PATCH] stop 2 hash fn from being pub with wasm --- pkg/bitcoin_hashing_wasm.d.ts | 14 +---- pkg/bitcoin_hashing_wasm.js | 73 ++++---------------------- pkg/bitcoin_hashing_wasm_bg.wasm | Bin 44928 -> 44629 bytes pkg/bitcoin_hashing_wasm_bg.wasm.d.ts | 4 +- web/index.html | 17 +++++- 5 files changed, 28 insertions(+), 80 deletions(-) diff --git a/pkg/bitcoin_hashing_wasm.d.ts b/pkg/bitcoin_hashing_wasm.d.ts index 61c79d7..a00991c 100644 --- a/pkg/bitcoin_hashing_wasm.d.ts +++ b/pkg/bitcoin_hashing_wasm.d.ts @@ -1,15 +1,5 @@ /* tslint:disable */ /* eslint-disable */ -/** - * @param {Uint8Array} input - * @returns {Uint8Array} - */ -export function sha256(input: Uint8Array): Uint8Array; -/** - * @param {Uint8Array} input - * @returns {Uint8Array} - */ -export function ripemd160(input: Uint8Array): Uint8Array; /** * @param {string} public_key_hex * @returns {string} @@ -20,13 +10,11 @@ export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembl export interface InitOutput { readonly memory: WebAssembly.Memory; - readonly sha256: (a: number, b: number, c: number) => void; - readonly ripemd160: (a: number, b: number, c: number) => void; readonly generate_bitcoin_address: (a: number, b: number, c: number) => void; readonly __wbindgen_add_to_stack_pointer: (a: number) => number; readonly __wbindgen_malloc: (a: number, b: number) => number; - readonly __wbindgen_free: (a: number, b: number, c: number) => void; readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number; + readonly __wbindgen_free: (a: number, b: number, c: number) => void; } export type SyncInitInput = BufferSource | WebAssembly.Module; diff --git a/pkg/bitcoin_hashing_wasm.js b/pkg/bitcoin_hashing_wasm.js index 63ed5af..feb0abd 100644 --- a/pkg/bitcoin_hashing_wasm.js +++ b/pkg/bitcoin_hashing_wasm.js @@ -1,5 +1,7 @@ let wasm; +let WASM_VECTOR_LEN = 0; + let cachedUint8ArrayMemory0 = null; function getUint8ArrayMemory0() { @@ -9,68 +11,6 @@ function getUint8ArrayMemory0() { return cachedUint8ArrayMemory0; } -let WASM_VECTOR_LEN = 0; - -function passArray8ToWasm0(arg, malloc) { - const ptr = malloc(arg.length * 1, 1) >>> 0; - getUint8ArrayMemory0().set(arg, ptr / 1); - WASM_VECTOR_LEN = arg.length; - return ptr; -} - -let cachedDataViewMemory0 = null; - -function getDataViewMemory0() { - if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) { - cachedDataViewMemory0 = new DataView(wasm.memory.buffer); - } - return cachedDataViewMemory0; -} - -function getArrayU8FromWasm0(ptr, len) { - ptr = ptr >>> 0; - return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len); -} -/** - * @param {Uint8Array} input - * @returns {Uint8Array} - */ -export function sha256(input) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - const ptr0 = passArray8ToWasm0(input, wasm.__wbindgen_malloc); - const len0 = WASM_VECTOR_LEN; - wasm.sha256(retptr, ptr0, len0); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var v2 = getArrayU8FromWasm0(r0, r1).slice(); - wasm.__wbindgen_free(r0, r1 * 1, 1); - return v2; - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } -} - -/** - * @param {Uint8Array} input - * @returns {Uint8Array} - */ -export function ripemd160(input) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - const ptr0 = passArray8ToWasm0(input, wasm.__wbindgen_malloc); - const len0 = WASM_VECTOR_LEN; - wasm.ripemd160(retptr, ptr0, len0); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var v2 = getArrayU8FromWasm0(r0, r1).slice(); - wasm.__wbindgen_free(r0, r1 * 1, 1); - return v2; - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } -} - const cachedTextEncoder = (typeof TextEncoder !== 'undefined' ? new TextEncoder('utf-8') : { encode: () => { throw Error('TextEncoder not available') } } ); const encodeString = (typeof cachedTextEncoder.encodeInto === 'function' @@ -125,6 +65,15 @@ function passStringToWasm0(arg, malloc, realloc) { return ptr; } +let cachedDataViewMemory0 = null; + +function getDataViewMemory0() { + if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) { + cachedDataViewMemory0 = new DataView(wasm.memory.buffer); + } + return cachedDataViewMemory0; +} + const cachedTextDecoder = (typeof TextDecoder !== 'undefined' ? new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }) : { decode: () => { throw Error('TextDecoder not available') } } ); if (typeof TextDecoder !== 'undefined') { cachedTextDecoder.decode(); }; diff --git a/pkg/bitcoin_hashing_wasm_bg.wasm b/pkg/bitcoin_hashing_wasm_bg.wasm index ee3f52c816d227a555c73df575e0101130e8da15..4abef998926f45f3990a5f9cfdb242e510b4139f 100644 GIT binary patch delta 4692 zcmZu!YmgPi74Ghtxv!bIckXicy+F^fkh{7|)&RT9L)czjmIZYs83EF`-gYL2ptaRjJDQ_@Sjg(7a5=Dox6y{1Fp=q%6v^LcY_pEW~oR zZujZar_cMG?iu+={NY1!^1Cxu-(`rD!3@*lT(GPm%p4OUZ5Xz27#kZ~;T+_t)V59A z9^J7|u(2;%xDnTLzj8-$!-l=z*|Pni&6~Dw*tT)&)<+*?opm?ic5F(Jw-s(eKD=Yo zCf1iNbEdc*v~|z8^INkQ$c}F=xOJd?!7atXCATm8#?s~Ur%!8IwWvQ^UXeTUs<^B6 zBL94V*Tv&^{*mY7M+cYjy4ueNeJYdxw`WBA$he4*D$&6|WfgI;yke2DP@H|)aU;mexF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cuX~x5--y(fd z&s>9^xmN%6D8#FbOS}F9ZDuKxc;RhZ*K!$tW9u*Z_2I6Ot1&)4qA|WR@;=6wwtbk) zLlDsuI%Dl<_}|&S6%GH29Ro)2t|1Zur+$4-AmUN$rB=Rvg*h7$^%D66fjY-pWYqCW zbZUAQduW8jkiGNA7pLc8s7?z#$0$l96>79jI7l8kPaU(+YbM?3V?y^#dct>uROFZ3 z;flkeE_69a>-(K}aVTnLjTMSAo>C$RWt@1|Z|S4Mh9ff%#B!53A8CN>-k=J zT$#P;<1^Hm0;c1DPLWT54`3oTiTI1cU(n6-mzU38UY?7Vu-fW7Y6AkDrV4Df%ag-zyj{M@FL%_aTI{^NK(&$Ym`2xt9fNKPN-_a5SH;qkq%^5x;s#28;* zE>HYZYLK7crc!ZF!2IL@l@=MM`)D*$tVj^ z;Wgqcgau?3$U;2Jq7|i;C<#$6qOuXdhSW9uPd3v3Up9yx;)B>IzkUC&c%FL7r2cI} zpLqr@vb_9aFd%p~y!hZvJXP2)@)3KK+$3jOHwjQ?pw!zBRjoca;+lFO|F|Ty~-rC;=d9d1AU970k)-jC=TdfcQ?{Cv2!Fszu9LQe$G z1vK&w{)X!D51#X3@AYjcK(miPW!LGKF*&sV`NPrvBBp5nsryi!*~I(8eP_Bs@r5&! zP@;OG8ctna`L%!W#?QcKSxm8&lvtdKaMQV3yx4v2ZNaY!S3mi2VhLlcBh*j#hJSy$ Lw*1Ibzo_^RCf#kS diff --git a/pkg/bitcoin_hashing_wasm_bg.wasm.d.ts b/pkg/bitcoin_hashing_wasm_bg.wasm.d.ts index 7b9c8c7..71b51be 100644 --- a/pkg/bitcoin_hashing_wasm_bg.wasm.d.ts +++ b/pkg/bitcoin_hashing_wasm_bg.wasm.d.ts @@ -1,10 +1,8 @@ /* tslint:disable */ /* eslint-disable */ export const memory: WebAssembly.Memory; -export function sha256(a: number, b: number, c: number): void; -export function ripemd160(a: number, b: number, c: number): void; export function generate_bitcoin_address(a: number, b: number, c: number): void; export function __wbindgen_add_to_stack_pointer(a: number): number; export function __wbindgen_malloc(a: number, b: number): number; -export function __wbindgen_free(a: number, b: number, c: number): void; export function __wbindgen_realloc(a: number, b: number, c: number, d: number): number; +export function __wbindgen_free(a: number, b: number, c: number): void; diff --git a/web/index.html b/web/index.html index 4dbb07d..5fab691 100644 --- a/web/index.html +++ b/web/index.html @@ -9,13 +9,26 @@

-

Bitcoin Address Generator

+

Legacy Bitcoin Address Generator

-

+        

+        
+ This is a demo, it uses Legacy Bitcoin addresses, which start with a 1 for P2PKH (Pay-to-Public-Key-Hash) addresses. Address Formats in Bitcoin +
+ +
+ + Paste in this Public key if you just want to test the generator +
+
+ + 0250863ad64a87ae8a2fe83c1af1a8403cb53f53e486d8511dad8a04887e5b2352 + +