@notabene/verify-proof 1.11.0 → 1.11.1-next.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 +21 -15
- package/dist/bitcoin-3CW4MNAW.cjs +314 -0
- package/dist/bitcoin-3CW4MNAW.cjs.map +1 -0
- package/dist/bitcoin-QK53ILBF.js +312 -0
- package/dist/bitcoin-QK53ILBF.js.map +1 -0
- package/dist/cardano-DYBYEAAF.cjs +53 -0
- package/dist/cardano-DYBYEAAF.cjs.map +1 -0
- package/dist/cardano-WE6YXYLW.js +31 -0
- package/dist/cardano-WE6YXYLW.js.map +1 -0
- package/dist/chunk-E3V5ATTC.js +38 -0
- package/dist/chunk-E3V5ATTC.js.map +1 -0
- package/dist/chunk-OAXNH5XR.cjs +42 -0
- package/dist/chunk-OAXNH5XR.cjs.map +1 -0
- package/dist/concordium-HQC37GCK.cjs +188 -0
- package/dist/concordium-HQC37GCK.cjs.map +1 -0
- package/dist/concordium-XX4XYLLU.js +186 -0
- package/dist/concordium-XX4XYLLU.js.map +1 -0
- package/dist/cosmos-64MKE5FJ.cjs +683 -0
- package/dist/cosmos-64MKE5FJ.cjs.map +1 -0
- package/dist/cosmos-QMH7BK7S.js +681 -0
- package/dist/cosmos-QMH7BK7S.js.map +1 -0
- package/dist/eth-3DX3PXDU.cjs +37 -0
- package/dist/eth-3DX3PXDU.cjs.map +1 -0
- package/dist/eth-ICLGRJE5.js +34 -0
- package/dist/eth-ICLGRJE5.js.map +1 -0
- package/dist/index.cjs +69 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +5 -0
- package/dist/index.d.ts +5 -2
- package/dist/index.js +67 -1
- package/dist/index.js.map +1 -1
- package/dist/solana-4KQFLZUC.js +342 -0
- package/dist/solana-4KQFLZUC.js.map +1 -0
- package/dist/solana-PQ5K4NGO.cjs +365 -0
- package/dist/solana-PQ5K4NGO.cjs.map +1 -0
- package/dist/tron-F5AARBY4.cjs +58 -0
- package/dist/tron-F5AARBY4.cjs.map +1 -0
- package/dist/tron-OBLPB2LN.js +53 -0
- package/dist/tron-OBLPB2LN.js.map +1 -0
- package/dist/xlm-5GODWWL2.cjs +28 -0
- package/dist/xlm-5GODWWL2.cjs.map +1 -0
- package/dist/xlm-GX2QGFLI.js +26 -0
- package/dist/xlm-GX2QGFLI.js.map +1 -0
- package/dist/xrpl-7HQLIDAK.cjs +1174 -0
- package/dist/xrpl-7HQLIDAK.cjs.map +1 -0
- package/dist/xrpl-YCDFXBGQ.js +1169 -0
- package/dist/xrpl-YCDFXBGQ.js.map +1 -0
- package/package.json +11 -2
- package/src/cardano.ts +2 -2
- package/src/index.ts +31 -19
- package/src/solana.ts +1 -1
- package/src/tests/solana.test.ts +1 -1
- package/dist/bitcoin.d.ts +0 -2
- package/dist/cardano.d.ts +0 -2
- package/dist/concordium.d.ts +0 -15
- package/dist/cosmos.d.ts +0 -2
- package/dist/eth.d.ts +0 -4
- package/dist/index.modern.js +0 -2
- package/dist/index.modern.js.map +0 -1
- package/dist/index.umd.js +0 -2
- package/dist/index.umd.js.map +0 -1
- package/dist/solana.d.ts +0 -17
- package/dist/tests/bitcoin.test.d.ts +0 -1
- package/dist/tests/cardano.test.d.ts +0 -1
- package/dist/tests/concordium.test.d.ts +0 -1
- package/dist/tests/cosmos.test.d.ts +0 -1
- package/dist/tests/eth.test.d.ts +0 -1
- package/dist/tests/index.test.d.ts +0 -1
- package/dist/tests/solana.test.d.ts +0 -1
- package/dist/tests/tron.test.d.ts +0 -1
- package/dist/tests/xlm.test.d.ts +0 -1
- package/dist/tests/xrpl.test.d.ts +0 -1
- package/dist/tron.d.ts +0 -6
- package/dist/xlm.d.ts +0 -2
- package/dist/xrpl.d.ts +0 -5
|
@@ -0,0 +1,1174 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var buffer = require('buffer');
|
|
4
|
+
var chunkOAXNH5XR_cjs = require('./chunk-OAXNH5XR.cjs');
|
|
5
|
+
var javascriptSdk = require('@notabene/javascript-sdk');
|
|
6
|
+
var xrpl = require('xrpl');
|
|
7
|
+
|
|
8
|
+
if (typeof globalThis !== 'undefined' && !globalThis.Buffer) { globalThis.Buffer = buffer.Buffer; }
|
|
9
|
+
|
|
10
|
+
// node_modules/@noble/hashes/cryptoNode.js
|
|
11
|
+
var require_cryptoNode = chunkOAXNH5XR_cjs.__commonJS({
|
|
12
|
+
"node_modules/@noble/hashes/cryptoNode.js"(exports) {
|
|
13
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
exports.crypto = void 0;
|
|
15
|
+
var nc = chunkOAXNH5XR_cjs.__require("crypto");
|
|
16
|
+
exports.crypto = nc && typeof nc === "object" && "webcrypto" in nc ? nc.webcrypto : nc && typeof nc === "object" && "randomBytes" in nc ? nc : void 0;
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
// node_modules/@noble/hashes/utils.js
|
|
21
|
+
var require_utils = chunkOAXNH5XR_cjs.__commonJS({
|
|
22
|
+
"node_modules/@noble/hashes/utils.js"(exports) {
|
|
23
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
24
|
+
exports.wrapXOFConstructorWithOpts = exports.wrapConstructorWithOpts = exports.wrapConstructor = exports.Hash = exports.nextTick = exports.swap32IfBE = exports.byteSwapIfBE = exports.swap8IfBE = exports.isLE = void 0;
|
|
25
|
+
exports.isBytes = isBytes;
|
|
26
|
+
exports.anumber = anumber;
|
|
27
|
+
exports.abytes = abytes;
|
|
28
|
+
exports.ahash = ahash;
|
|
29
|
+
exports.aexists = aexists;
|
|
30
|
+
exports.aoutput = aoutput;
|
|
31
|
+
exports.u8 = u8;
|
|
32
|
+
exports.u32 = u32;
|
|
33
|
+
exports.clean = clean;
|
|
34
|
+
exports.createView = createView;
|
|
35
|
+
exports.rotr = rotr;
|
|
36
|
+
exports.rotl = rotl;
|
|
37
|
+
exports.byteSwap = byteSwap;
|
|
38
|
+
exports.byteSwap32 = byteSwap32;
|
|
39
|
+
exports.bytesToHex = bytesToHex;
|
|
40
|
+
exports.hexToBytes = hexToBytes;
|
|
41
|
+
exports.asyncLoop = asyncLoop;
|
|
42
|
+
exports.utf8ToBytes = utf8ToBytes;
|
|
43
|
+
exports.bytesToUtf8 = bytesToUtf8;
|
|
44
|
+
exports.toBytes = toBytes;
|
|
45
|
+
exports.kdfInputToBytes = kdfInputToBytes;
|
|
46
|
+
exports.concatBytes = concatBytes;
|
|
47
|
+
exports.checkOpts = checkOpts;
|
|
48
|
+
exports.createHasher = createHasher;
|
|
49
|
+
exports.createOptHasher = createOptHasher;
|
|
50
|
+
exports.createXOFer = createXOFer;
|
|
51
|
+
exports.randomBytes = randomBytes;
|
|
52
|
+
var crypto_1 = require_cryptoNode();
|
|
53
|
+
function isBytes(a) {
|
|
54
|
+
return a instanceof Uint8Array || ArrayBuffer.isView(a) && a.constructor.name === "Uint8Array";
|
|
55
|
+
}
|
|
56
|
+
function anumber(n) {
|
|
57
|
+
if (!Number.isSafeInteger(n) || n < 0)
|
|
58
|
+
throw new Error("positive integer expected, got " + n);
|
|
59
|
+
}
|
|
60
|
+
function abytes(b, ...lengths) {
|
|
61
|
+
if (!isBytes(b))
|
|
62
|
+
throw new Error("Uint8Array expected");
|
|
63
|
+
if (lengths.length > 0 && !lengths.includes(b.length))
|
|
64
|
+
throw new Error("Uint8Array expected of length " + lengths + ", got length=" + b.length);
|
|
65
|
+
}
|
|
66
|
+
function ahash(h) {
|
|
67
|
+
if (typeof h !== "function" || typeof h.create !== "function")
|
|
68
|
+
throw new Error("Hash should be wrapped by utils.createHasher");
|
|
69
|
+
anumber(h.outputLen);
|
|
70
|
+
anumber(h.blockLen);
|
|
71
|
+
}
|
|
72
|
+
function aexists(instance, checkFinished = true) {
|
|
73
|
+
if (instance.destroyed)
|
|
74
|
+
throw new Error("Hash instance has been destroyed");
|
|
75
|
+
if (checkFinished && instance.finished)
|
|
76
|
+
throw new Error("Hash#digest() has already been called");
|
|
77
|
+
}
|
|
78
|
+
function aoutput(out, instance) {
|
|
79
|
+
abytes(out);
|
|
80
|
+
const min = instance.outputLen;
|
|
81
|
+
if (out.length < min) {
|
|
82
|
+
throw new Error("digestInto() expects output buffer of length at least " + min);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
function u8(arr) {
|
|
86
|
+
return new Uint8Array(arr.buffer, arr.byteOffset, arr.byteLength);
|
|
87
|
+
}
|
|
88
|
+
function u32(arr) {
|
|
89
|
+
return new Uint32Array(arr.buffer, arr.byteOffset, Math.floor(arr.byteLength / 4));
|
|
90
|
+
}
|
|
91
|
+
function clean(...arrays) {
|
|
92
|
+
for (let i = 0; i < arrays.length; i++) {
|
|
93
|
+
arrays[i].fill(0);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
function createView(arr) {
|
|
97
|
+
return new DataView(arr.buffer, arr.byteOffset, arr.byteLength);
|
|
98
|
+
}
|
|
99
|
+
function rotr(word, shift) {
|
|
100
|
+
return word << 32 - shift | word >>> shift;
|
|
101
|
+
}
|
|
102
|
+
function rotl(word, shift) {
|
|
103
|
+
return word << shift | word >>> 32 - shift >>> 0;
|
|
104
|
+
}
|
|
105
|
+
exports.isLE = (() => new Uint8Array(new Uint32Array([287454020]).buffer)[0] === 68)();
|
|
106
|
+
function byteSwap(word) {
|
|
107
|
+
return word << 24 & 4278190080 | word << 8 & 16711680 | word >>> 8 & 65280 | word >>> 24 & 255;
|
|
108
|
+
}
|
|
109
|
+
exports.swap8IfBE = exports.isLE ? (n) => n : (n) => byteSwap(n);
|
|
110
|
+
exports.byteSwapIfBE = exports.swap8IfBE;
|
|
111
|
+
function byteSwap32(arr) {
|
|
112
|
+
for (let i = 0; i < arr.length; i++) {
|
|
113
|
+
arr[i] = byteSwap(arr[i]);
|
|
114
|
+
}
|
|
115
|
+
return arr;
|
|
116
|
+
}
|
|
117
|
+
exports.swap32IfBE = exports.isLE ? (u) => u : byteSwap32;
|
|
118
|
+
var hasHexBuiltin = /* @__PURE__ */ (() => (
|
|
119
|
+
// @ts-ignore
|
|
120
|
+
typeof Uint8Array.from([]).toHex === "function" && typeof Uint8Array.fromHex === "function"
|
|
121
|
+
))();
|
|
122
|
+
var hexes = /* @__PURE__ */ Array.from({ length: 256 }, (_, i) => i.toString(16).padStart(2, "0"));
|
|
123
|
+
function bytesToHex(bytes) {
|
|
124
|
+
abytes(bytes);
|
|
125
|
+
if (hasHexBuiltin)
|
|
126
|
+
return bytes.toHex();
|
|
127
|
+
let hex = "";
|
|
128
|
+
for (let i = 0; i < bytes.length; i++) {
|
|
129
|
+
hex += hexes[bytes[i]];
|
|
130
|
+
}
|
|
131
|
+
return hex;
|
|
132
|
+
}
|
|
133
|
+
var asciis = { _0: 48, _9: 57, A: 65, F: 70, a: 97, f: 102 };
|
|
134
|
+
function asciiToBase16(ch) {
|
|
135
|
+
if (ch >= asciis._0 && ch <= asciis._9)
|
|
136
|
+
return ch - asciis._0;
|
|
137
|
+
if (ch >= asciis.A && ch <= asciis.F)
|
|
138
|
+
return ch - (asciis.A - 10);
|
|
139
|
+
if (ch >= asciis.a && ch <= asciis.f)
|
|
140
|
+
return ch - (asciis.a - 10);
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
function hexToBytes(hex) {
|
|
144
|
+
if (typeof hex !== "string")
|
|
145
|
+
throw new Error("hex string expected, got " + typeof hex);
|
|
146
|
+
if (hasHexBuiltin)
|
|
147
|
+
return Uint8Array.fromHex(hex);
|
|
148
|
+
const hl = hex.length;
|
|
149
|
+
const al = hl / 2;
|
|
150
|
+
if (hl % 2)
|
|
151
|
+
throw new Error("hex string expected, got unpadded hex of length " + hl);
|
|
152
|
+
const array = new Uint8Array(al);
|
|
153
|
+
for (let ai = 0, hi = 0; ai < al; ai++, hi += 2) {
|
|
154
|
+
const n1 = asciiToBase16(hex.charCodeAt(hi));
|
|
155
|
+
const n2 = asciiToBase16(hex.charCodeAt(hi + 1));
|
|
156
|
+
if (n1 === void 0 || n2 === void 0) {
|
|
157
|
+
const char = hex[hi] + hex[hi + 1];
|
|
158
|
+
throw new Error('hex string expected, got non-hex character "' + char + '" at index ' + hi);
|
|
159
|
+
}
|
|
160
|
+
array[ai] = n1 * 16 + n2;
|
|
161
|
+
}
|
|
162
|
+
return array;
|
|
163
|
+
}
|
|
164
|
+
var nextTick = async () => {
|
|
165
|
+
};
|
|
166
|
+
exports.nextTick = nextTick;
|
|
167
|
+
async function asyncLoop(iters, tick, cb) {
|
|
168
|
+
let ts = Date.now();
|
|
169
|
+
for (let i = 0; i < iters; i++) {
|
|
170
|
+
cb(i);
|
|
171
|
+
const diff = Date.now() - ts;
|
|
172
|
+
if (diff >= 0 && diff < tick)
|
|
173
|
+
continue;
|
|
174
|
+
await (0, exports.nextTick)();
|
|
175
|
+
ts += diff;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
function utf8ToBytes(str) {
|
|
179
|
+
if (typeof str !== "string")
|
|
180
|
+
throw new Error("string expected");
|
|
181
|
+
return new Uint8Array(new TextEncoder().encode(str));
|
|
182
|
+
}
|
|
183
|
+
function bytesToUtf8(bytes) {
|
|
184
|
+
return new TextDecoder().decode(bytes);
|
|
185
|
+
}
|
|
186
|
+
function toBytes(data) {
|
|
187
|
+
if (typeof data === "string")
|
|
188
|
+
data = utf8ToBytes(data);
|
|
189
|
+
abytes(data);
|
|
190
|
+
return data;
|
|
191
|
+
}
|
|
192
|
+
function kdfInputToBytes(data) {
|
|
193
|
+
if (typeof data === "string")
|
|
194
|
+
data = utf8ToBytes(data);
|
|
195
|
+
abytes(data);
|
|
196
|
+
return data;
|
|
197
|
+
}
|
|
198
|
+
function concatBytes(...arrays) {
|
|
199
|
+
let sum = 0;
|
|
200
|
+
for (let i = 0; i < arrays.length; i++) {
|
|
201
|
+
const a = arrays[i];
|
|
202
|
+
abytes(a);
|
|
203
|
+
sum += a.length;
|
|
204
|
+
}
|
|
205
|
+
const res = new Uint8Array(sum);
|
|
206
|
+
for (let i = 0, pad = 0; i < arrays.length; i++) {
|
|
207
|
+
const a = arrays[i];
|
|
208
|
+
res.set(a, pad);
|
|
209
|
+
pad += a.length;
|
|
210
|
+
}
|
|
211
|
+
return res;
|
|
212
|
+
}
|
|
213
|
+
function checkOpts(defaults, opts) {
|
|
214
|
+
if (opts !== void 0 && {}.toString.call(opts) !== "[object Object]")
|
|
215
|
+
throw new Error("options should be object or undefined");
|
|
216
|
+
const merged = Object.assign(defaults, opts);
|
|
217
|
+
return merged;
|
|
218
|
+
}
|
|
219
|
+
var Hash = class {
|
|
220
|
+
};
|
|
221
|
+
exports.Hash = Hash;
|
|
222
|
+
function createHasher(hashCons) {
|
|
223
|
+
const hashC = (msg) => hashCons().update(toBytes(msg)).digest();
|
|
224
|
+
const tmp = hashCons();
|
|
225
|
+
hashC.outputLen = tmp.outputLen;
|
|
226
|
+
hashC.blockLen = tmp.blockLen;
|
|
227
|
+
hashC.create = () => hashCons();
|
|
228
|
+
return hashC;
|
|
229
|
+
}
|
|
230
|
+
function createOptHasher(hashCons) {
|
|
231
|
+
const hashC = (msg, opts) => hashCons(opts).update(toBytes(msg)).digest();
|
|
232
|
+
const tmp = hashCons({});
|
|
233
|
+
hashC.outputLen = tmp.outputLen;
|
|
234
|
+
hashC.blockLen = tmp.blockLen;
|
|
235
|
+
hashC.create = (opts) => hashCons(opts);
|
|
236
|
+
return hashC;
|
|
237
|
+
}
|
|
238
|
+
function createXOFer(hashCons) {
|
|
239
|
+
const hashC = (msg, opts) => hashCons(opts).update(toBytes(msg)).digest();
|
|
240
|
+
const tmp = hashCons({});
|
|
241
|
+
hashC.outputLen = tmp.outputLen;
|
|
242
|
+
hashC.blockLen = tmp.blockLen;
|
|
243
|
+
hashC.create = (opts) => hashCons(opts);
|
|
244
|
+
return hashC;
|
|
245
|
+
}
|
|
246
|
+
exports.wrapConstructor = createHasher;
|
|
247
|
+
exports.wrapConstructorWithOpts = createOptHasher;
|
|
248
|
+
exports.wrapXOFConstructorWithOpts = createXOFer;
|
|
249
|
+
function randomBytes(bytesLength = 32) {
|
|
250
|
+
if (crypto_1.crypto && typeof crypto_1.crypto.getRandomValues === "function") {
|
|
251
|
+
return crypto_1.crypto.getRandomValues(new Uint8Array(bytesLength));
|
|
252
|
+
}
|
|
253
|
+
if (crypto_1.crypto && typeof crypto_1.crypto.randomBytes === "function") {
|
|
254
|
+
return Uint8Array.from(crypto_1.crypto.randomBytes(bytesLength));
|
|
255
|
+
}
|
|
256
|
+
throw new Error("crypto.getRandomValues must be defined");
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
});
|
|
260
|
+
|
|
261
|
+
// node_modules/@xrplf/isomorphic/dist/utils/shared.js
|
|
262
|
+
var require_shared = chunkOAXNH5XR_cjs.__commonJS({
|
|
263
|
+
"node_modules/@xrplf/isomorphic/dist/utils/shared.js"(exports) {
|
|
264
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
265
|
+
exports.equal = exports.concat = exports.HEX_REGEX = void 0;
|
|
266
|
+
var utils_1 = require_utils();
|
|
267
|
+
exports.HEX_REGEX = /^[A-F0-9]*$/iu;
|
|
268
|
+
function concat(views) {
|
|
269
|
+
return (0, utils_1.concatBytes)(...views);
|
|
270
|
+
}
|
|
271
|
+
exports.concat = concat;
|
|
272
|
+
function equal(buf1, buf2) {
|
|
273
|
+
if (buf1.byteLength !== buf2.byteLength) {
|
|
274
|
+
return false;
|
|
275
|
+
}
|
|
276
|
+
const dv1 = new Int8Array(buf1);
|
|
277
|
+
const dv2 = new Int8Array(buf2);
|
|
278
|
+
for (let i = 0; i !== buf1.byteLength; i++) {
|
|
279
|
+
if (dv1[i] !== dv2[i]) {
|
|
280
|
+
return false;
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
return true;
|
|
284
|
+
}
|
|
285
|
+
exports.equal = equal;
|
|
286
|
+
}
|
|
287
|
+
});
|
|
288
|
+
|
|
289
|
+
// node_modules/@xrplf/isomorphic/dist/utils/index.js
|
|
290
|
+
var require_utils2 = chunkOAXNH5XR_cjs.__commonJS({
|
|
291
|
+
"node_modules/@xrplf/isomorphic/dist/utils/index.js"(exports) {
|
|
292
|
+
var __createBinding = exports && exports.__createBinding || (Object.create ? (function(o, m, k, k2) {
|
|
293
|
+
if (k2 === void 0) k2 = k;
|
|
294
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
295
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
296
|
+
desc = { enumerable: true, get: function() {
|
|
297
|
+
return m[k];
|
|
298
|
+
} };
|
|
299
|
+
}
|
|
300
|
+
Object.defineProperty(o, k2, desc);
|
|
301
|
+
}) : (function(o, m, k, k2) {
|
|
302
|
+
if (k2 === void 0) k2 = k;
|
|
303
|
+
o[k2] = m[k];
|
|
304
|
+
}));
|
|
305
|
+
var __exportStar = exports && exports.__exportStar || function(m, exports2) {
|
|
306
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports2, p)) __createBinding(exports2, m, p);
|
|
307
|
+
};
|
|
308
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
309
|
+
exports.stringToHex = exports.hexToString = exports.randomBytes = exports.hexToBytes = exports.bytesToHex = void 0;
|
|
310
|
+
var crypto_1 = chunkOAXNH5XR_cjs.__require("crypto");
|
|
311
|
+
var shared_1 = require_shared();
|
|
312
|
+
var OriginalBuffer = Symbol("OriginalBuffer");
|
|
313
|
+
function toUint8Array(buffer) {
|
|
314
|
+
const u8Array = new Uint8Array(buffer.buffer.slice(buffer.byteOffset, buffer.byteOffset + buffer.byteLength));
|
|
315
|
+
u8Array[OriginalBuffer] = buffer;
|
|
316
|
+
return u8Array;
|
|
317
|
+
}
|
|
318
|
+
var bytesToHex = (bytes) => {
|
|
319
|
+
const buf = buffer.Buffer.from(bytes);
|
|
320
|
+
return buf.toString("hex").toUpperCase();
|
|
321
|
+
};
|
|
322
|
+
exports.bytesToHex = bytesToHex;
|
|
323
|
+
var hexToBytes = (hex) => {
|
|
324
|
+
if (!shared_1.HEX_REGEX.test(hex)) {
|
|
325
|
+
throw new Error("Invalid hex string");
|
|
326
|
+
}
|
|
327
|
+
return toUint8Array(buffer.Buffer.from(hex, "hex"));
|
|
328
|
+
};
|
|
329
|
+
exports.hexToBytes = hexToBytes;
|
|
330
|
+
var randomBytes = (size) => {
|
|
331
|
+
return toUint8Array((0, crypto_1.randomBytes)(size));
|
|
332
|
+
};
|
|
333
|
+
exports.randomBytes = randomBytes;
|
|
334
|
+
var hexToString = (hex, encoding = "utf8") => {
|
|
335
|
+
if (!shared_1.HEX_REGEX.test(hex)) {
|
|
336
|
+
throw new Error("Invalid hex string");
|
|
337
|
+
}
|
|
338
|
+
return new TextDecoder(encoding).decode((0, exports.hexToBytes)(hex));
|
|
339
|
+
};
|
|
340
|
+
exports.hexToString = hexToString;
|
|
341
|
+
var stringToHex = (string) => {
|
|
342
|
+
return (0, exports.bytesToHex)(new TextEncoder().encode(string));
|
|
343
|
+
};
|
|
344
|
+
exports.stringToHex = stringToHex;
|
|
345
|
+
__exportStar(require_shared(), exports);
|
|
346
|
+
}
|
|
347
|
+
});
|
|
348
|
+
|
|
349
|
+
// node_modules/@xrplf/isomorphic/dist/internal/normalizeInput.js
|
|
350
|
+
var require_normalizeInput = chunkOAXNH5XR_cjs.__commonJS({
|
|
351
|
+
"node_modules/@xrplf/isomorphic/dist/internal/normalizeInput.js"(exports) {
|
|
352
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
353
|
+
function normalizeInput(input) {
|
|
354
|
+
return Array.isArray(input) ? new Uint8Array(input) : input;
|
|
355
|
+
}
|
|
356
|
+
exports.default = normalizeInput;
|
|
357
|
+
}
|
|
358
|
+
});
|
|
359
|
+
|
|
360
|
+
// node_modules/@xrplf/isomorphic/dist/internal/wrapCryptoCreateHash.js
|
|
361
|
+
var require_wrapCryptoCreateHash = chunkOAXNH5XR_cjs.__commonJS({
|
|
362
|
+
"node_modules/@xrplf/isomorphic/dist/internal/wrapCryptoCreateHash.js"(exports) {
|
|
363
|
+
var __importDefault = exports && exports.__importDefault || function(mod) {
|
|
364
|
+
return mod && mod.__esModule ? mod : { "default": mod };
|
|
365
|
+
};
|
|
366
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
367
|
+
var normalizeInput_1 = __importDefault(require_normalizeInput());
|
|
368
|
+
function wrapCryptoCreateHash(type, fn) {
|
|
369
|
+
function hashFn(input) {
|
|
370
|
+
return fn(type).update((0, normalizeInput_1.default)(input)).digest();
|
|
371
|
+
}
|
|
372
|
+
hashFn.create = () => {
|
|
373
|
+
const hash = fn(type);
|
|
374
|
+
return {
|
|
375
|
+
update(input) {
|
|
376
|
+
hash.update((0, normalizeInput_1.default)(input));
|
|
377
|
+
return this;
|
|
378
|
+
},
|
|
379
|
+
digest() {
|
|
380
|
+
return hash.digest();
|
|
381
|
+
}
|
|
382
|
+
};
|
|
383
|
+
};
|
|
384
|
+
return hashFn;
|
|
385
|
+
}
|
|
386
|
+
exports.default = wrapCryptoCreateHash;
|
|
387
|
+
}
|
|
388
|
+
});
|
|
389
|
+
|
|
390
|
+
// node_modules/@xrplf/isomorphic/dist/sha256/index.js
|
|
391
|
+
var require_sha256 = chunkOAXNH5XR_cjs.__commonJS({
|
|
392
|
+
"node_modules/@xrplf/isomorphic/dist/sha256/index.js"(exports) {
|
|
393
|
+
var __importDefault = exports && exports.__importDefault || function(mod) {
|
|
394
|
+
return mod && mod.__esModule ? mod : { "default": mod };
|
|
395
|
+
};
|
|
396
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
397
|
+
exports.sha256 = void 0;
|
|
398
|
+
var crypto_1 = chunkOAXNH5XR_cjs.__require("crypto");
|
|
399
|
+
var wrapCryptoCreateHash_1 = __importDefault(require_wrapCryptoCreateHash());
|
|
400
|
+
exports.sha256 = (0, wrapCryptoCreateHash_1.default)("sha256", crypto_1.createHash);
|
|
401
|
+
}
|
|
402
|
+
});
|
|
403
|
+
|
|
404
|
+
// node_modules/ripple-address-codec/dist/utils.js
|
|
405
|
+
var require_utils3 = chunkOAXNH5XR_cjs.__commonJS({
|
|
406
|
+
"node_modules/ripple-address-codec/dist/utils.js"(exports) {
|
|
407
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
408
|
+
exports.concatArgs = exports.arrayEqual = void 0;
|
|
409
|
+
function arrayEqual(arr1, arr2) {
|
|
410
|
+
if (arr1.length !== arr2.length) {
|
|
411
|
+
return false;
|
|
412
|
+
}
|
|
413
|
+
return arr1.every((value, index) => value === arr2[index]);
|
|
414
|
+
}
|
|
415
|
+
exports.arrayEqual = arrayEqual;
|
|
416
|
+
function isScalar(val) {
|
|
417
|
+
return typeof val === "number";
|
|
418
|
+
}
|
|
419
|
+
function concatArgs(...args) {
|
|
420
|
+
return args.flatMap((arg) => {
|
|
421
|
+
return isScalar(arg) ? [arg] : Array.from(arg);
|
|
422
|
+
});
|
|
423
|
+
}
|
|
424
|
+
exports.concatArgs = concatArgs;
|
|
425
|
+
}
|
|
426
|
+
});
|
|
427
|
+
|
|
428
|
+
// node_modules/ripple-address-codec/dist/xrp-codec.js
|
|
429
|
+
var require_xrp_codec = chunkOAXNH5XR_cjs.__commonJS({
|
|
430
|
+
"node_modules/ripple-address-codec/dist/xrp-codec.js"(exports) {
|
|
431
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
432
|
+
exports.isValidClassicAddress = exports.decodeAccountPublic = exports.encodeAccountPublic = exports.encodeNodePublic = exports.decodeNodePublic = exports.decodeAddress = exports.decodeAccountID = exports.encodeAddress = exports.encodeAccountID = exports.decodeSeed = exports.encodeSeed = exports.codec = void 0;
|
|
433
|
+
var base_1 = chunkOAXNH5XR_cjs.__require("@scure/base");
|
|
434
|
+
var sha256_1 = require_sha256();
|
|
435
|
+
var utils_1 = require_utils3();
|
|
436
|
+
var Codec = class {
|
|
437
|
+
constructor(options) {
|
|
438
|
+
this._sha256 = options.sha256;
|
|
439
|
+
this._codec = base_1.base58xrp;
|
|
440
|
+
}
|
|
441
|
+
/**
|
|
442
|
+
* Encoder.
|
|
443
|
+
*
|
|
444
|
+
* @param bytes - Uint8Array of data to encode.
|
|
445
|
+
* @param opts - Options object including the version bytes and the expected length of the data to encode.
|
|
446
|
+
*/
|
|
447
|
+
encode(bytes, opts) {
|
|
448
|
+
const versions = opts.versions;
|
|
449
|
+
return this._encodeVersioned(bytes, versions, opts.expectedLength);
|
|
450
|
+
}
|
|
451
|
+
/**
|
|
452
|
+
* Decoder.
|
|
453
|
+
*
|
|
454
|
+
* @param base58string - Base58Check-encoded string to decode.
|
|
455
|
+
* @param opts - Options object including the version byte(s) and the expected length of the data after decoding.
|
|
456
|
+
*/
|
|
457
|
+
/* eslint-disable max-lines-per-function --
|
|
458
|
+
* TODO refactor */
|
|
459
|
+
decode(base58string, opts) {
|
|
460
|
+
var _a;
|
|
461
|
+
const versions = opts.versions;
|
|
462
|
+
const types = opts.versionTypes;
|
|
463
|
+
const withoutSum = this.decodeChecked(base58string);
|
|
464
|
+
if (versions.length > 1 && !opts.expectedLength) {
|
|
465
|
+
throw new Error("expectedLength is required because there are >= 2 possible versions");
|
|
466
|
+
}
|
|
467
|
+
const versionLengthGuess = typeof versions[0] === "number" ? 1 : versions[0].length;
|
|
468
|
+
const payloadLength = (_a = opts.expectedLength) !== null && _a !== void 0 ? _a : withoutSum.length - versionLengthGuess;
|
|
469
|
+
const versionBytes = withoutSum.slice(0, -payloadLength);
|
|
470
|
+
const payload = withoutSum.slice(-payloadLength);
|
|
471
|
+
for (let i = 0; i < versions.length; i++) {
|
|
472
|
+
const version = Array.isArray(versions[i]) ? versions[i] : [versions[i]];
|
|
473
|
+
if ((0, utils_1.arrayEqual)(versionBytes, version)) {
|
|
474
|
+
return {
|
|
475
|
+
version,
|
|
476
|
+
bytes: payload,
|
|
477
|
+
type: types ? types[i] : null
|
|
478
|
+
};
|
|
479
|
+
}
|
|
480
|
+
}
|
|
481
|
+
throw new Error("version_invalid: version bytes do not match any of the provided version(s)");
|
|
482
|
+
}
|
|
483
|
+
encodeChecked(bytes) {
|
|
484
|
+
const check = this._sha256(this._sha256(bytes)).slice(0, 4);
|
|
485
|
+
return this._encodeRaw(Uint8Array.from((0, utils_1.concatArgs)(bytes, check)));
|
|
486
|
+
}
|
|
487
|
+
decodeChecked(base58string) {
|
|
488
|
+
const intArray = this._decodeRaw(base58string);
|
|
489
|
+
if (intArray.byteLength < 5) {
|
|
490
|
+
throw new Error("invalid_input_size: decoded data must have length >= 5");
|
|
491
|
+
}
|
|
492
|
+
if (!this._verifyCheckSum(intArray)) {
|
|
493
|
+
throw new Error("checksum_invalid");
|
|
494
|
+
}
|
|
495
|
+
return intArray.slice(0, -4);
|
|
496
|
+
}
|
|
497
|
+
_encodeVersioned(bytes, versions, expectedLength) {
|
|
498
|
+
if (!checkByteLength(bytes, expectedLength)) {
|
|
499
|
+
throw new Error("unexpected_payload_length: bytes.length does not match expectedLength. Ensure that the bytes are a Uint8Array.");
|
|
500
|
+
}
|
|
501
|
+
return this.encodeChecked((0, utils_1.concatArgs)(versions, bytes));
|
|
502
|
+
}
|
|
503
|
+
_encodeRaw(bytes) {
|
|
504
|
+
return this._codec.encode(Uint8Array.from(bytes));
|
|
505
|
+
}
|
|
506
|
+
/* eslint-enable max-lines-per-function */
|
|
507
|
+
_decodeRaw(base58string) {
|
|
508
|
+
return this._codec.decode(base58string);
|
|
509
|
+
}
|
|
510
|
+
_verifyCheckSum(bytes) {
|
|
511
|
+
const computed = this._sha256(this._sha256(bytes.slice(0, -4))).slice(0, 4);
|
|
512
|
+
const checksum = bytes.slice(-4);
|
|
513
|
+
return (0, utils_1.arrayEqual)(computed, checksum);
|
|
514
|
+
}
|
|
515
|
+
};
|
|
516
|
+
var ACCOUNT_ID = 0;
|
|
517
|
+
var ACCOUNT_PUBLIC_KEY = 35;
|
|
518
|
+
var FAMILY_SEED = 33;
|
|
519
|
+
var NODE_PUBLIC = 28;
|
|
520
|
+
var ED25519_SEED = [1, 225, 75];
|
|
521
|
+
var codecOptions = {
|
|
522
|
+
sha256: sha256_1.sha256
|
|
523
|
+
};
|
|
524
|
+
var codecWithXrpAlphabet = new Codec(codecOptions);
|
|
525
|
+
exports.codec = codecWithXrpAlphabet;
|
|
526
|
+
function encodeSeed(entropy, type) {
|
|
527
|
+
if (!checkByteLength(entropy, 16)) {
|
|
528
|
+
throw new Error("entropy must have length 16");
|
|
529
|
+
}
|
|
530
|
+
const opts = {
|
|
531
|
+
expectedLength: 16,
|
|
532
|
+
// for secp256k1, use `FAMILY_SEED`
|
|
533
|
+
versions: type === "ed25519" ? ED25519_SEED : [FAMILY_SEED]
|
|
534
|
+
};
|
|
535
|
+
return codecWithXrpAlphabet.encode(entropy, opts);
|
|
536
|
+
}
|
|
537
|
+
exports.encodeSeed = encodeSeed;
|
|
538
|
+
function decodeSeed(seed, opts = {
|
|
539
|
+
versionTypes: ["ed25519", "secp256k1"],
|
|
540
|
+
versions: [ED25519_SEED, FAMILY_SEED],
|
|
541
|
+
expectedLength: 16
|
|
542
|
+
}) {
|
|
543
|
+
return codecWithXrpAlphabet.decode(seed, opts);
|
|
544
|
+
}
|
|
545
|
+
exports.decodeSeed = decodeSeed;
|
|
546
|
+
function encodeAccountID(bytes) {
|
|
547
|
+
const opts = { versions: [ACCOUNT_ID], expectedLength: 20 };
|
|
548
|
+
return codecWithXrpAlphabet.encode(bytes, opts);
|
|
549
|
+
}
|
|
550
|
+
exports.encodeAccountID = encodeAccountID;
|
|
551
|
+
exports.encodeAddress = encodeAccountID;
|
|
552
|
+
function decodeAccountID(accountId) {
|
|
553
|
+
const opts = { versions: [ACCOUNT_ID], expectedLength: 20 };
|
|
554
|
+
return codecWithXrpAlphabet.decode(accountId, opts).bytes;
|
|
555
|
+
}
|
|
556
|
+
exports.decodeAccountID = decodeAccountID;
|
|
557
|
+
exports.decodeAddress = decodeAccountID;
|
|
558
|
+
function decodeNodePublic(base58string) {
|
|
559
|
+
const opts = { versions: [NODE_PUBLIC], expectedLength: 33 };
|
|
560
|
+
return codecWithXrpAlphabet.decode(base58string, opts).bytes;
|
|
561
|
+
}
|
|
562
|
+
exports.decodeNodePublic = decodeNodePublic;
|
|
563
|
+
function encodeNodePublic(bytes) {
|
|
564
|
+
const opts = { versions: [NODE_PUBLIC], expectedLength: 33 };
|
|
565
|
+
return codecWithXrpAlphabet.encode(bytes, opts);
|
|
566
|
+
}
|
|
567
|
+
exports.encodeNodePublic = encodeNodePublic;
|
|
568
|
+
function encodeAccountPublic(bytes) {
|
|
569
|
+
const opts = { versions: [ACCOUNT_PUBLIC_KEY], expectedLength: 33 };
|
|
570
|
+
return codecWithXrpAlphabet.encode(bytes, opts);
|
|
571
|
+
}
|
|
572
|
+
exports.encodeAccountPublic = encodeAccountPublic;
|
|
573
|
+
function decodeAccountPublic(base58string) {
|
|
574
|
+
const opts = { versions: [ACCOUNT_PUBLIC_KEY], expectedLength: 33 };
|
|
575
|
+
return codecWithXrpAlphabet.decode(base58string, opts).bytes;
|
|
576
|
+
}
|
|
577
|
+
exports.decodeAccountPublic = decodeAccountPublic;
|
|
578
|
+
function isValidClassicAddress(address) {
|
|
579
|
+
try {
|
|
580
|
+
decodeAccountID(address);
|
|
581
|
+
} catch (_error) {
|
|
582
|
+
return false;
|
|
583
|
+
}
|
|
584
|
+
return true;
|
|
585
|
+
}
|
|
586
|
+
exports.isValidClassicAddress = isValidClassicAddress;
|
|
587
|
+
function checkByteLength(bytes, expectedLength) {
|
|
588
|
+
return "byteLength" in bytes ? bytes.byteLength === expectedLength : bytes.length === expectedLength;
|
|
589
|
+
}
|
|
590
|
+
}
|
|
591
|
+
});
|
|
592
|
+
|
|
593
|
+
// node_modules/ripple-address-codec/dist/index.js
|
|
594
|
+
var require_dist = chunkOAXNH5XR_cjs.__commonJS({
|
|
595
|
+
"node_modules/ripple-address-codec/dist/index.js"(exports) {
|
|
596
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
597
|
+
exports.isValidXAddress = exports.decodeXAddress = exports.xAddressToClassicAddress = exports.encodeXAddress = exports.classicAddressToXAddress = exports.isValidClassicAddress = exports.decodeAccountPublic = exports.encodeAccountPublic = exports.decodeNodePublic = exports.encodeNodePublic = exports.decodeAccountID = exports.encodeAccountID = exports.decodeSeed = exports.encodeSeed = exports.codec = void 0;
|
|
598
|
+
var utils_1 = require_utils2();
|
|
599
|
+
var xrp_codec_1 = require_xrp_codec();
|
|
600
|
+
Object.defineProperty(exports, "codec", { enumerable: true, get: function() {
|
|
601
|
+
return xrp_codec_1.codec;
|
|
602
|
+
} });
|
|
603
|
+
Object.defineProperty(exports, "encodeSeed", { enumerable: true, get: function() {
|
|
604
|
+
return xrp_codec_1.encodeSeed;
|
|
605
|
+
} });
|
|
606
|
+
Object.defineProperty(exports, "decodeSeed", { enumerable: true, get: function() {
|
|
607
|
+
return xrp_codec_1.decodeSeed;
|
|
608
|
+
} });
|
|
609
|
+
Object.defineProperty(exports, "encodeAccountID", { enumerable: true, get: function() {
|
|
610
|
+
return xrp_codec_1.encodeAccountID;
|
|
611
|
+
} });
|
|
612
|
+
Object.defineProperty(exports, "decodeAccountID", { enumerable: true, get: function() {
|
|
613
|
+
return xrp_codec_1.decodeAccountID;
|
|
614
|
+
} });
|
|
615
|
+
Object.defineProperty(exports, "encodeNodePublic", { enumerable: true, get: function() {
|
|
616
|
+
return xrp_codec_1.encodeNodePublic;
|
|
617
|
+
} });
|
|
618
|
+
Object.defineProperty(exports, "decodeNodePublic", { enumerable: true, get: function() {
|
|
619
|
+
return xrp_codec_1.decodeNodePublic;
|
|
620
|
+
} });
|
|
621
|
+
Object.defineProperty(exports, "encodeAccountPublic", { enumerable: true, get: function() {
|
|
622
|
+
return xrp_codec_1.encodeAccountPublic;
|
|
623
|
+
} });
|
|
624
|
+
Object.defineProperty(exports, "decodeAccountPublic", { enumerable: true, get: function() {
|
|
625
|
+
return xrp_codec_1.decodeAccountPublic;
|
|
626
|
+
} });
|
|
627
|
+
Object.defineProperty(exports, "isValidClassicAddress", { enumerable: true, get: function() {
|
|
628
|
+
return xrp_codec_1.isValidClassicAddress;
|
|
629
|
+
} });
|
|
630
|
+
var PREFIX_BYTES = {
|
|
631
|
+
// 5, 68
|
|
632
|
+
main: Uint8Array.from([5, 68]),
|
|
633
|
+
// 4, 147
|
|
634
|
+
test: Uint8Array.from([4, 147])
|
|
635
|
+
};
|
|
636
|
+
var MAX_32_BIT_UNSIGNED_INT = 4294967295;
|
|
637
|
+
function classicAddressToXAddress(classicAddress, tag, test) {
|
|
638
|
+
const accountId = (0, xrp_codec_1.decodeAccountID)(classicAddress);
|
|
639
|
+
return encodeXAddress(accountId, tag, test);
|
|
640
|
+
}
|
|
641
|
+
exports.classicAddressToXAddress = classicAddressToXAddress;
|
|
642
|
+
function encodeXAddress(accountId, tag, test) {
|
|
643
|
+
if (accountId.length !== 20) {
|
|
644
|
+
throw new Error("Account ID must be 20 bytes");
|
|
645
|
+
}
|
|
646
|
+
if (tag !== false && tag > MAX_32_BIT_UNSIGNED_INT) {
|
|
647
|
+
throw new Error("Invalid tag");
|
|
648
|
+
}
|
|
649
|
+
const theTag = tag || 0;
|
|
650
|
+
const flag = tag === false || tag == null ? 0 : 1;
|
|
651
|
+
const bytes = (0, utils_1.concat)([
|
|
652
|
+
test ? PREFIX_BYTES.test : PREFIX_BYTES.main,
|
|
653
|
+
accountId,
|
|
654
|
+
Uint8Array.from([
|
|
655
|
+
// 0x00 if no tag, 0x01 if 32-bit tag
|
|
656
|
+
flag,
|
|
657
|
+
// first byte
|
|
658
|
+
theTag & 255,
|
|
659
|
+
// second byte
|
|
660
|
+
theTag >> 8 & 255,
|
|
661
|
+
// third byte
|
|
662
|
+
theTag >> 16 & 255,
|
|
663
|
+
// fourth byte
|
|
664
|
+
theTag >> 24 & 255,
|
|
665
|
+
0,
|
|
666
|
+
0,
|
|
667
|
+
0,
|
|
668
|
+
// four zero bytes (reserved for 64-bit tags)
|
|
669
|
+
0
|
|
670
|
+
])
|
|
671
|
+
]);
|
|
672
|
+
return xrp_codec_1.codec.encodeChecked(bytes);
|
|
673
|
+
}
|
|
674
|
+
exports.encodeXAddress = encodeXAddress;
|
|
675
|
+
function xAddressToClassicAddress(xAddress) {
|
|
676
|
+
const { accountId, tag, test } = decodeXAddress(xAddress);
|
|
677
|
+
const classicAddress = (0, xrp_codec_1.encodeAccountID)(accountId);
|
|
678
|
+
return {
|
|
679
|
+
classicAddress,
|
|
680
|
+
tag,
|
|
681
|
+
test
|
|
682
|
+
};
|
|
683
|
+
}
|
|
684
|
+
exports.xAddressToClassicAddress = xAddressToClassicAddress;
|
|
685
|
+
function decodeXAddress(xAddress) {
|
|
686
|
+
const decoded = xrp_codec_1.codec.decodeChecked(xAddress);
|
|
687
|
+
const test = isUint8ArrayForTestAddress(decoded);
|
|
688
|
+
const accountId = decoded.slice(2, 22);
|
|
689
|
+
const tag = tagFromUint8Array(decoded);
|
|
690
|
+
return {
|
|
691
|
+
accountId,
|
|
692
|
+
tag,
|
|
693
|
+
test
|
|
694
|
+
};
|
|
695
|
+
}
|
|
696
|
+
exports.decodeXAddress = decodeXAddress;
|
|
697
|
+
function isUint8ArrayForTestAddress(buf) {
|
|
698
|
+
const decodedPrefix = buf.slice(0, 2);
|
|
699
|
+
if ((0, utils_1.equal)(PREFIX_BYTES.main, decodedPrefix)) {
|
|
700
|
+
return false;
|
|
701
|
+
}
|
|
702
|
+
if ((0, utils_1.equal)(PREFIX_BYTES.test, decodedPrefix)) {
|
|
703
|
+
return true;
|
|
704
|
+
}
|
|
705
|
+
throw new Error("Invalid X-address: bad prefix");
|
|
706
|
+
}
|
|
707
|
+
function tagFromUint8Array(buf) {
|
|
708
|
+
const flag = buf[22];
|
|
709
|
+
if (flag >= 2) {
|
|
710
|
+
throw new Error("Unsupported X-address");
|
|
711
|
+
}
|
|
712
|
+
if (flag === 1) {
|
|
713
|
+
return buf[23] + buf[24] * 256 + buf[25] * 65536 + buf[26] * 16777216;
|
|
714
|
+
}
|
|
715
|
+
if (flag !== 0) {
|
|
716
|
+
throw new Error("flag must be zero to indicate no tag");
|
|
717
|
+
}
|
|
718
|
+
if (!(0, utils_1.equal)((0, utils_1.hexToBytes)("0000000000000000"), buf.slice(23, 23 + 8))) {
|
|
719
|
+
throw new Error("remaining bytes must be zero");
|
|
720
|
+
}
|
|
721
|
+
return false;
|
|
722
|
+
}
|
|
723
|
+
function isValidXAddress(xAddress) {
|
|
724
|
+
try {
|
|
725
|
+
decodeXAddress(xAddress);
|
|
726
|
+
} catch (_error) {
|
|
727
|
+
return false;
|
|
728
|
+
}
|
|
729
|
+
return true;
|
|
730
|
+
}
|
|
731
|
+
exports.isValidXAddress = isValidXAddress;
|
|
732
|
+
}
|
|
733
|
+
});
|
|
734
|
+
|
|
735
|
+
// node_modules/@xrplf/isomorphic/dist/ripemd160/index.js
|
|
736
|
+
var require_ripemd160 = chunkOAXNH5XR_cjs.__commonJS({
|
|
737
|
+
"node_modules/@xrplf/isomorphic/dist/ripemd160/index.js"(exports) {
|
|
738
|
+
var __importDefault = exports && exports.__importDefault || function(mod) {
|
|
739
|
+
return mod && mod.__esModule ? mod : { "default": mod };
|
|
740
|
+
};
|
|
741
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
742
|
+
exports.ripemd160 = void 0;
|
|
743
|
+
var crypto_1 = chunkOAXNH5XR_cjs.__require("crypto");
|
|
744
|
+
var wrapCryptoCreateHash_1 = __importDefault(require_wrapCryptoCreateHash());
|
|
745
|
+
exports.ripemd160 = (0, wrapCryptoCreateHash_1.default)("ripemd160", crypto_1.createHash);
|
|
746
|
+
}
|
|
747
|
+
});
|
|
748
|
+
|
|
749
|
+
// node_modules/@xrplf/isomorphic/dist/sha512/index.js
|
|
750
|
+
var require_sha512 = chunkOAXNH5XR_cjs.__commonJS({
|
|
751
|
+
"node_modules/@xrplf/isomorphic/dist/sha512/index.js"(exports) {
|
|
752
|
+
var __importDefault = exports && exports.__importDefault || function(mod) {
|
|
753
|
+
return mod && mod.__esModule ? mod : { "default": mod };
|
|
754
|
+
};
|
|
755
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
756
|
+
exports.sha512 = void 0;
|
|
757
|
+
var crypto_1 = chunkOAXNH5XR_cjs.__require("crypto");
|
|
758
|
+
var wrapCryptoCreateHash_1 = __importDefault(require_wrapCryptoCreateHash());
|
|
759
|
+
exports.sha512 = (0, wrapCryptoCreateHash_1.default)("sha512", crypto_1.createHash);
|
|
760
|
+
}
|
|
761
|
+
});
|
|
762
|
+
|
|
763
|
+
// node_modules/ripple-keypairs/dist/utils/Sha512.js
|
|
764
|
+
var require_Sha512 = chunkOAXNH5XR_cjs.__commonJS({
|
|
765
|
+
"node_modules/ripple-keypairs/dist/utils/Sha512.js"(exports) {
|
|
766
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
767
|
+
var sha512_1 = require_sha512();
|
|
768
|
+
var utils_1 = chunkOAXNH5XR_cjs.__require("@noble/curves/abstract/utils");
|
|
769
|
+
var Sha512 = class _Sha512 {
|
|
770
|
+
constructor() {
|
|
771
|
+
this.hash = sha512_1.sha512.create();
|
|
772
|
+
}
|
|
773
|
+
static half(input) {
|
|
774
|
+
return new _Sha512().add(input).first256();
|
|
775
|
+
}
|
|
776
|
+
add(bytes) {
|
|
777
|
+
this.hash.update(bytes);
|
|
778
|
+
return this;
|
|
779
|
+
}
|
|
780
|
+
addU32(i) {
|
|
781
|
+
const buffer = new Uint8Array(4);
|
|
782
|
+
new DataView(buffer.buffer).setUint32(0, i);
|
|
783
|
+
return this.add(buffer);
|
|
784
|
+
}
|
|
785
|
+
finish() {
|
|
786
|
+
return this.hash.digest();
|
|
787
|
+
}
|
|
788
|
+
first256() {
|
|
789
|
+
return this.finish().slice(0, 32);
|
|
790
|
+
}
|
|
791
|
+
first256BigInt() {
|
|
792
|
+
return (0, utils_1.bytesToNumberBE)(this.first256());
|
|
793
|
+
}
|
|
794
|
+
};
|
|
795
|
+
exports.default = Sha512;
|
|
796
|
+
}
|
|
797
|
+
});
|
|
798
|
+
|
|
799
|
+
// node_modules/ripple-keypairs/dist/signing-schemes/secp256k1/utils.js
|
|
800
|
+
var require_utils4 = chunkOAXNH5XR_cjs.__commonJS({
|
|
801
|
+
"node_modules/ripple-keypairs/dist/signing-schemes/secp256k1/utils.js"(exports) {
|
|
802
|
+
var __importDefault = exports && exports.__importDefault || function(mod) {
|
|
803
|
+
return mod && mod.__esModule ? mod : { "default": mod };
|
|
804
|
+
};
|
|
805
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
806
|
+
exports.accountPublicFromPublicGenerator = exports.derivePrivateKey = void 0;
|
|
807
|
+
var secp256k1_1 = chunkOAXNH5XR_cjs.__require("@noble/curves/secp256k1");
|
|
808
|
+
var Sha512_1 = __importDefault(require_Sha512());
|
|
809
|
+
var ZERO = BigInt(0);
|
|
810
|
+
function deriveScalar(bytes, discrim) {
|
|
811
|
+
const order = secp256k1_1.secp256k1.CURVE.n;
|
|
812
|
+
for (let i = 0; i <= 4294967295; i++) {
|
|
813
|
+
const hasher = new Sha512_1.default().add(bytes);
|
|
814
|
+
if (discrim !== void 0) {
|
|
815
|
+
hasher.addU32(discrim);
|
|
816
|
+
}
|
|
817
|
+
hasher.addU32(i);
|
|
818
|
+
const key = hasher.first256BigInt();
|
|
819
|
+
if (key > ZERO && key < order) {
|
|
820
|
+
return key;
|
|
821
|
+
}
|
|
822
|
+
}
|
|
823
|
+
throw new Error("impossible unicorn ;)");
|
|
824
|
+
}
|
|
825
|
+
function derivePrivateKey(seed, opts = {}) {
|
|
826
|
+
const root = opts.validator;
|
|
827
|
+
const order = secp256k1_1.secp256k1.CURVE.n;
|
|
828
|
+
const privateGen = deriveScalar(seed);
|
|
829
|
+
if (root) {
|
|
830
|
+
return privateGen;
|
|
831
|
+
}
|
|
832
|
+
const publicGen = secp256k1_1.secp256k1.ProjectivePoint.BASE.multiply(privateGen).toRawBytes(true);
|
|
833
|
+
const accountIndex = opts.accountIndex || 0;
|
|
834
|
+
return (deriveScalar(publicGen, accountIndex) + privateGen) % order;
|
|
835
|
+
}
|
|
836
|
+
exports.derivePrivateKey = derivePrivateKey;
|
|
837
|
+
function accountPublicFromPublicGenerator(publicGenBytes) {
|
|
838
|
+
const rootPubPoint = secp256k1_1.secp256k1.ProjectivePoint.fromHex(publicGenBytes);
|
|
839
|
+
const scalar = deriveScalar(publicGenBytes, 0);
|
|
840
|
+
const point = secp256k1_1.secp256k1.ProjectivePoint.BASE.multiply(scalar);
|
|
841
|
+
const offset = rootPubPoint.add(point);
|
|
842
|
+
return offset.toRawBytes(true);
|
|
843
|
+
}
|
|
844
|
+
exports.accountPublicFromPublicGenerator = accountPublicFromPublicGenerator;
|
|
845
|
+
}
|
|
846
|
+
});
|
|
847
|
+
|
|
848
|
+
// node_modules/ripple-keypairs/dist/utils/assert.js
|
|
849
|
+
var require_assert = chunkOAXNH5XR_cjs.__commonJS({
|
|
850
|
+
"node_modules/ripple-keypairs/dist/utils/assert.js"(exports) {
|
|
851
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
852
|
+
var assertHelper = {
|
|
853
|
+
ok(cond, message) {
|
|
854
|
+
if (!cond) {
|
|
855
|
+
throw new Error(message);
|
|
856
|
+
}
|
|
857
|
+
}
|
|
858
|
+
};
|
|
859
|
+
exports.default = assertHelper;
|
|
860
|
+
}
|
|
861
|
+
});
|
|
862
|
+
|
|
863
|
+
// node_modules/ripple-keypairs/dist/utils/getAlgorithmFromKey.js
|
|
864
|
+
var require_getAlgorithmFromKey = chunkOAXNH5XR_cjs.__commonJS({
|
|
865
|
+
"node_modules/ripple-keypairs/dist/utils/getAlgorithmFromKey.js"(exports) {
|
|
866
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
867
|
+
exports.getAlgorithmFromPrivateKey = exports.getAlgorithmFromPublicKey = exports.getAlgorithmFromKey = void 0;
|
|
868
|
+
var Prefix;
|
|
869
|
+
(function(Prefix2) {
|
|
870
|
+
Prefix2[Prefix2["NONE"] = -1] = "NONE";
|
|
871
|
+
Prefix2[Prefix2["ED25519"] = 237] = "ED25519";
|
|
872
|
+
Prefix2[Prefix2["SECP256K1_PUB_X"] = 2] = "SECP256K1_PUB_X";
|
|
873
|
+
Prefix2[Prefix2["SECP256K1_PUB_X_ODD_Y"] = 3] = "SECP256K1_PUB_X_ODD_Y";
|
|
874
|
+
Prefix2[Prefix2["SECP256K1_PUB_XY"] = 4] = "SECP256K1_PUB_XY";
|
|
875
|
+
Prefix2[Prefix2["SECP256K1_PRIVATE"] = 0] = "SECP256K1_PRIVATE";
|
|
876
|
+
})(Prefix || (Prefix = {}));
|
|
877
|
+
var KEY_TYPES = {
|
|
878
|
+
[`private_${Prefix.NONE}_32`]: "ecdsa-secp256k1",
|
|
879
|
+
[`private_${Prefix.SECP256K1_PRIVATE}_33`]: "ecdsa-secp256k1",
|
|
880
|
+
[`private_${Prefix.ED25519}_33`]: "ed25519",
|
|
881
|
+
[`public_${Prefix.ED25519}_33`]: "ed25519",
|
|
882
|
+
[`public_${Prefix.SECP256K1_PUB_X}_33`]: "ecdsa-secp256k1",
|
|
883
|
+
[`public_${Prefix.SECP256K1_PUB_X_ODD_Y}_33`]: "ecdsa-secp256k1",
|
|
884
|
+
[`public_${Prefix.SECP256K1_PUB_XY}_65`]: "ecdsa-secp256k1"
|
|
885
|
+
};
|
|
886
|
+
function getKeyInfo(key) {
|
|
887
|
+
return {
|
|
888
|
+
prefix: key.length < 2 ? Prefix.NONE : parseInt(key.slice(0, 2), 16),
|
|
889
|
+
len: key.length / 2
|
|
890
|
+
};
|
|
891
|
+
}
|
|
892
|
+
function prefixRepr(prefix) {
|
|
893
|
+
return prefix === Prefix.NONE ? "None" : `0x${prefix.toString(16).padStart(2, "0")}`;
|
|
894
|
+
}
|
|
895
|
+
function getValidFormatsTable(type) {
|
|
896
|
+
const padding = 2;
|
|
897
|
+
const colWidth = {
|
|
898
|
+
algorithm: "ecdsa-secp256k1".length + padding,
|
|
899
|
+
prefix: "0x00".length + padding
|
|
900
|
+
};
|
|
901
|
+
return Object.entries(KEY_TYPES).filter(([key]) => key.startsWith(type)).map(([key, algorithm]) => {
|
|
902
|
+
const [, prefix, length] = key.split("_");
|
|
903
|
+
const paddedAlgo = algorithm.padEnd(colWidth.algorithm);
|
|
904
|
+
const paddedPrefix = prefixRepr(Number(prefix)).padEnd(colWidth.prefix);
|
|
905
|
+
return `${paddedAlgo} - Prefix: ${paddedPrefix} Length: ${length} bytes`;
|
|
906
|
+
}).join("\n");
|
|
907
|
+
}
|
|
908
|
+
function keyError({ key, type, prefix, len }) {
|
|
909
|
+
const validFormats = getValidFormatsTable(type);
|
|
910
|
+
return `invalid_key:
|
|
911
|
+
|
|
912
|
+
Type: ${type}
|
|
913
|
+
Key: ${key}
|
|
914
|
+
Prefix: ${prefixRepr(prefix)}
|
|
915
|
+
Length: ${len} bytes
|
|
916
|
+
|
|
917
|
+
Acceptable ${type} formats are:
|
|
918
|
+
${validFormats}
|
|
919
|
+
`;
|
|
920
|
+
}
|
|
921
|
+
function getAlgorithmFromKey(key, type) {
|
|
922
|
+
const { prefix, len } = getKeyInfo(key);
|
|
923
|
+
const usedPrefix = type === "private" && len === 32 ? Prefix.NONE : prefix;
|
|
924
|
+
const algorithm = KEY_TYPES[`${type}_${usedPrefix}_${len}`];
|
|
925
|
+
if (!algorithm) {
|
|
926
|
+
throw new Error(keyError({ key, type, len, prefix: usedPrefix }));
|
|
927
|
+
}
|
|
928
|
+
return algorithm;
|
|
929
|
+
}
|
|
930
|
+
exports.getAlgorithmFromKey = getAlgorithmFromKey;
|
|
931
|
+
function getAlgorithmFromPublicKey(key) {
|
|
932
|
+
return getAlgorithmFromKey(key, "public");
|
|
933
|
+
}
|
|
934
|
+
exports.getAlgorithmFromPublicKey = getAlgorithmFromPublicKey;
|
|
935
|
+
function getAlgorithmFromPrivateKey(key) {
|
|
936
|
+
return getAlgorithmFromKey(key, "private");
|
|
937
|
+
}
|
|
938
|
+
exports.getAlgorithmFromPrivateKey = getAlgorithmFromPrivateKey;
|
|
939
|
+
}
|
|
940
|
+
});
|
|
941
|
+
|
|
942
|
+
// node_modules/ripple-keypairs/dist/signing-schemes/secp256k1/index.js
|
|
943
|
+
var require_secp256k1 = chunkOAXNH5XR_cjs.__commonJS({
|
|
944
|
+
"node_modules/ripple-keypairs/dist/signing-schemes/secp256k1/index.js"(exports) {
|
|
945
|
+
var __importDefault = exports && exports.__importDefault || function(mod) {
|
|
946
|
+
return mod && mod.__esModule ? mod : { "default": mod };
|
|
947
|
+
};
|
|
948
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
949
|
+
var utils_1 = chunkOAXNH5XR_cjs.__require("@noble/curves/abstract/utils");
|
|
950
|
+
var secp256k1_1 = chunkOAXNH5XR_cjs.__require("@noble/curves/secp256k1");
|
|
951
|
+
var utils_2 = require_utils2();
|
|
952
|
+
var utils_3 = require_utils4();
|
|
953
|
+
var assert_1 = __importDefault(require_assert());
|
|
954
|
+
var Sha512_1 = __importDefault(require_Sha512());
|
|
955
|
+
var SECP256K1_PREFIX = "00";
|
|
956
|
+
var secp256k1 = {
|
|
957
|
+
deriveKeypair(entropy, options) {
|
|
958
|
+
const derived = (0, utils_3.derivePrivateKey)(entropy, options);
|
|
959
|
+
const privateKey = SECP256K1_PREFIX + (0, utils_2.bytesToHex)((0, utils_1.numberToBytesBE)(derived, 32));
|
|
960
|
+
const publicKey = (0, utils_2.bytesToHex)(secp256k1_1.secp256k1.getPublicKey(derived, true));
|
|
961
|
+
return { privateKey, publicKey };
|
|
962
|
+
},
|
|
963
|
+
sign(message, privateKey) {
|
|
964
|
+
assert_1.default.ok(privateKey.length === 66 && privateKey.startsWith(SECP256K1_PREFIX) || privateKey.length === 64);
|
|
965
|
+
const normedPrivateKey = privateKey.length === 66 ? privateKey.slice(2) : privateKey;
|
|
966
|
+
return secp256k1_1.secp256k1.sign(Sha512_1.default.half(message), normedPrivateKey, {
|
|
967
|
+
// "Canonical" signatures
|
|
968
|
+
lowS: true,
|
|
969
|
+
// Would fail tests if signatures aren't deterministic
|
|
970
|
+
extraEntropy: void 0
|
|
971
|
+
}).toDERHex(true).toUpperCase();
|
|
972
|
+
},
|
|
973
|
+
verify(message, signature, publicKey) {
|
|
974
|
+
const decoded = secp256k1_1.secp256k1.Signature.fromDER(signature);
|
|
975
|
+
return secp256k1_1.secp256k1.verify(decoded, Sha512_1.default.half(message), publicKey);
|
|
976
|
+
}
|
|
977
|
+
};
|
|
978
|
+
exports.default = secp256k1;
|
|
979
|
+
}
|
|
980
|
+
});
|
|
981
|
+
|
|
982
|
+
// node_modules/ripple-keypairs/dist/signing-schemes/ed25519/index.js
|
|
983
|
+
var require_ed25519 = chunkOAXNH5XR_cjs.__commonJS({
|
|
984
|
+
"node_modules/ripple-keypairs/dist/signing-schemes/ed25519/index.js"(exports) {
|
|
985
|
+
var __importDefault = exports && exports.__importDefault || function(mod) {
|
|
986
|
+
return mod && mod.__esModule ? mod : { "default": mod };
|
|
987
|
+
};
|
|
988
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
989
|
+
var ed25519_1 = chunkOAXNH5XR_cjs.__require("@noble/curves/ed25519");
|
|
990
|
+
var utils_1 = require_utils2();
|
|
991
|
+
var assert_1 = __importDefault(require_assert());
|
|
992
|
+
var Sha512_1 = __importDefault(require_Sha512());
|
|
993
|
+
var ED_PREFIX = "ED";
|
|
994
|
+
var ed25519 = {
|
|
995
|
+
deriveKeypair(entropy) {
|
|
996
|
+
const rawPrivateKey = Sha512_1.default.half(entropy);
|
|
997
|
+
const privateKey = ED_PREFIX + (0, utils_1.bytesToHex)(rawPrivateKey);
|
|
998
|
+
const publicKey = ED_PREFIX + (0, utils_1.bytesToHex)(ed25519_1.ed25519.getPublicKey(rawPrivateKey));
|
|
999
|
+
return { privateKey, publicKey };
|
|
1000
|
+
},
|
|
1001
|
+
sign(message, privateKey) {
|
|
1002
|
+
assert_1.default.ok(message instanceof Uint8Array, "message must be array of octets");
|
|
1003
|
+
assert_1.default.ok(privateKey.length === 66, "private key must be 33 bytes including prefix");
|
|
1004
|
+
return (0, utils_1.bytesToHex)(ed25519_1.ed25519.sign(message, privateKey.slice(2)));
|
|
1005
|
+
},
|
|
1006
|
+
verify(message, signature, publicKey) {
|
|
1007
|
+
assert_1.default.ok(publicKey.length === 66, "public key must be 33 bytes including prefix");
|
|
1008
|
+
return ed25519_1.ed25519.verify(
|
|
1009
|
+
signature,
|
|
1010
|
+
message,
|
|
1011
|
+
// Remove the 0xED prefix
|
|
1012
|
+
publicKey.slice(2),
|
|
1013
|
+
// By default, set zip215 to false for compatibility reasons.
|
|
1014
|
+
// ZIP 215 is a stricter Ed25519 signature verification scheme.
|
|
1015
|
+
// However, setting it to false adheres to the more commonly used
|
|
1016
|
+
// RFC8032 / NIST186-5 standards, making it compatible with systems
|
|
1017
|
+
// like the XRP Ledger.
|
|
1018
|
+
{ zip215: false }
|
|
1019
|
+
);
|
|
1020
|
+
}
|
|
1021
|
+
};
|
|
1022
|
+
exports.default = ed25519;
|
|
1023
|
+
}
|
|
1024
|
+
});
|
|
1025
|
+
|
|
1026
|
+
// node_modules/ripple-keypairs/dist/index.js
|
|
1027
|
+
var require_dist2 = chunkOAXNH5XR_cjs.__commonJS({
|
|
1028
|
+
"node_modules/ripple-keypairs/dist/index.js"(exports) {
|
|
1029
|
+
var __importDefault = exports && exports.__importDefault || function(mod) {
|
|
1030
|
+
return mod && mod.__esModule ? mod : { "default": mod };
|
|
1031
|
+
};
|
|
1032
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1033
|
+
exports.decodeSeed = exports.deriveNodeAddress = exports.deriveAddress = exports.verify = exports.sign = exports.deriveKeypair = exports.generateSeed = void 0;
|
|
1034
|
+
var ripple_address_codec_1 = require_dist();
|
|
1035
|
+
Object.defineProperty(exports, "decodeSeed", { enumerable: true, get: function() {
|
|
1036
|
+
return ripple_address_codec_1.decodeSeed;
|
|
1037
|
+
} });
|
|
1038
|
+
var ripemd160_1 = require_ripemd160();
|
|
1039
|
+
var sha256_1 = require_sha256();
|
|
1040
|
+
var utils_1 = require_utils2();
|
|
1041
|
+
var utils_2 = require_utils4();
|
|
1042
|
+
var Sha512_1 = __importDefault(require_Sha512());
|
|
1043
|
+
var assert_1 = __importDefault(require_assert());
|
|
1044
|
+
var getAlgorithmFromKey_1 = require_getAlgorithmFromKey();
|
|
1045
|
+
var secp256k1_1 = __importDefault(require_secp256k1());
|
|
1046
|
+
var ed25519_1 = __importDefault(require_ed25519());
|
|
1047
|
+
function getSigningScheme(algorithm) {
|
|
1048
|
+
const schemes = { "ecdsa-secp256k1": secp256k1_1.default, ed25519: ed25519_1.default };
|
|
1049
|
+
return schemes[algorithm];
|
|
1050
|
+
}
|
|
1051
|
+
function generateSeed(options = {}) {
|
|
1052
|
+
assert_1.default.ok(!options.entropy || options.entropy.length >= 16, "entropy too short");
|
|
1053
|
+
const entropy = options.entropy ? options.entropy.slice(0, 16) : (0, utils_1.randomBytes)(16);
|
|
1054
|
+
const type = options.algorithm === "ed25519" ? "ed25519" : "secp256k1";
|
|
1055
|
+
return (0, ripple_address_codec_1.encodeSeed)(entropy, type);
|
|
1056
|
+
}
|
|
1057
|
+
exports.generateSeed = generateSeed;
|
|
1058
|
+
function deriveKeypair(seed, options) {
|
|
1059
|
+
var _a;
|
|
1060
|
+
const decoded = (0, ripple_address_codec_1.decodeSeed)(seed);
|
|
1061
|
+
const proposedAlgorithm = (_a = options === null || options === void 0 ? void 0 : options.algorithm) !== null && _a !== void 0 ? _a : decoded.type;
|
|
1062
|
+
const algorithm = proposedAlgorithm === "ed25519" ? "ed25519" : "ecdsa-secp256k1";
|
|
1063
|
+
const scheme = getSigningScheme(algorithm);
|
|
1064
|
+
const keypair = scheme.deriveKeypair(decoded.bytes, options);
|
|
1065
|
+
const messageToVerify = Sha512_1.default.half("This test message should verify.");
|
|
1066
|
+
const signature = scheme.sign(messageToVerify, keypair.privateKey);
|
|
1067
|
+
if (!scheme.verify(messageToVerify, signature, keypair.publicKey)) {
|
|
1068
|
+
throw new Error("derived keypair did not generate verifiable signature");
|
|
1069
|
+
}
|
|
1070
|
+
return keypair;
|
|
1071
|
+
}
|
|
1072
|
+
exports.deriveKeypair = deriveKeypair;
|
|
1073
|
+
function sign(messageHex, privateKey) {
|
|
1074
|
+
const algorithm = (0, getAlgorithmFromKey_1.getAlgorithmFromPrivateKey)(privateKey);
|
|
1075
|
+
return getSigningScheme(algorithm).sign((0, utils_1.hexToBytes)(messageHex), privateKey);
|
|
1076
|
+
}
|
|
1077
|
+
exports.sign = sign;
|
|
1078
|
+
function verify2(messageHex, signature, publicKey) {
|
|
1079
|
+
const algorithm = (0, getAlgorithmFromKey_1.getAlgorithmFromPublicKey)(publicKey);
|
|
1080
|
+
return getSigningScheme(algorithm).verify((0, utils_1.hexToBytes)(messageHex), signature, publicKey);
|
|
1081
|
+
}
|
|
1082
|
+
exports.verify = verify2;
|
|
1083
|
+
function computePublicKeyHash(publicKeyBytes) {
|
|
1084
|
+
return (0, ripemd160_1.ripemd160)((0, sha256_1.sha256)(publicKeyBytes));
|
|
1085
|
+
}
|
|
1086
|
+
function deriveAddressFromBytes(publicKeyBytes) {
|
|
1087
|
+
return (0, ripple_address_codec_1.encodeAccountID)(computePublicKeyHash(publicKeyBytes));
|
|
1088
|
+
}
|
|
1089
|
+
function deriveAddress(publicKey) {
|
|
1090
|
+
return deriveAddressFromBytes((0, utils_1.hexToBytes)(publicKey));
|
|
1091
|
+
}
|
|
1092
|
+
exports.deriveAddress = deriveAddress;
|
|
1093
|
+
function deriveNodeAddress(publicKey) {
|
|
1094
|
+
const generatorBytes = (0, ripple_address_codec_1.decodeNodePublic)(publicKey);
|
|
1095
|
+
const accountPublicBytes = (0, utils_2.accountPublicFromPublicGenerator)(generatorBytes);
|
|
1096
|
+
return deriveAddressFromBytes(accountPublicBytes);
|
|
1097
|
+
}
|
|
1098
|
+
exports.deriveNodeAddress = deriveNodeAddress;
|
|
1099
|
+
}
|
|
1100
|
+
});
|
|
1101
|
+
|
|
1102
|
+
// src/xrpl.ts
|
|
1103
|
+
var import_ripple_keypairs = chunkOAXNH5XR_cjs.__toESM(require_dist2(), 1);
|
|
1104
|
+
function verifyXRPL(message, publicKey, proof) {
|
|
1105
|
+
return (0, import_ripple_keypairs.verify)(buffer.Buffer.from(message).toString("hex"), proof, publicKey);
|
|
1106
|
+
}
|
|
1107
|
+
var xrplTestnetWs = [
|
|
1108
|
+
"wss://s.altnet.rippletest.net:51233",
|
|
1109
|
+
"wss://testnet.xrpl-labs.com/"
|
|
1110
|
+
];
|
|
1111
|
+
var xrplMainnetWs = [
|
|
1112
|
+
"wss://s1.ripple.com",
|
|
1113
|
+
"wss://xrplcluster.com/",
|
|
1114
|
+
// full node
|
|
1115
|
+
"wss://s2.ripple.com/"
|
|
1116
|
+
];
|
|
1117
|
+
async function getPublicKey(address, isTest) {
|
|
1118
|
+
const servers = isTest ? xrplTestnetWs : xrplMainnetWs;
|
|
1119
|
+
for (const server of servers) {
|
|
1120
|
+
try {
|
|
1121
|
+
const client = new xrpl.Client(server);
|
|
1122
|
+
await client.connect();
|
|
1123
|
+
const response = await client.request({
|
|
1124
|
+
command: "account_tx",
|
|
1125
|
+
account: address,
|
|
1126
|
+
binary: false,
|
|
1127
|
+
limit: 2,
|
|
1128
|
+
forward: false
|
|
1129
|
+
});
|
|
1130
|
+
await client.disconnect();
|
|
1131
|
+
return getSigningPubkeyFromLatestTx(response.result?.transactions);
|
|
1132
|
+
} catch (error) {
|
|
1133
|
+
let errorMessage = "Connection to XRPL server failed";
|
|
1134
|
+
if (error instanceof Error) {
|
|
1135
|
+
errorMessage += `: ${error.message}`;
|
|
1136
|
+
}
|
|
1137
|
+
console.error(errorMessage);
|
|
1138
|
+
}
|
|
1139
|
+
}
|
|
1140
|
+
}
|
|
1141
|
+
function getSigningPubkeyFromLatestTx(latestTx) {
|
|
1142
|
+
for (let i = 0; i < latestTx.length; i++) {
|
|
1143
|
+
const signingPubKey = latestTx[i]?.tx_json?.SigningPubKey ?? "0x";
|
|
1144
|
+
return signingPubKey;
|
|
1145
|
+
}
|
|
1146
|
+
throw new Error("No valid pubkey found in the latest transactions");
|
|
1147
|
+
}
|
|
1148
|
+
async function verifyPersonalSignXRPL(proof, publicKey, isTest) {
|
|
1149
|
+
const [ns, , address] = proof.address.split(/:/);
|
|
1150
|
+
if (ns !== "xrpl") return { ...proof, status: javascriptSdk.ProofStatus.FAILED };
|
|
1151
|
+
if (!publicKey) {
|
|
1152
|
+
publicKey = await getPublicKey(address, isTest);
|
|
1153
|
+
}
|
|
1154
|
+
if (!publicKey) {
|
|
1155
|
+
return { ...proof, status: javascriptSdk.ProofStatus.FAILED };
|
|
1156
|
+
}
|
|
1157
|
+
const verified = verifyXRPL(proof.attestation, publicKey, proof.proof);
|
|
1158
|
+
return {
|
|
1159
|
+
...proof,
|
|
1160
|
+
status: verified ? javascriptSdk.ProofStatus.VERIFIED : javascriptSdk.ProofStatus.FAILED
|
|
1161
|
+
};
|
|
1162
|
+
}
|
|
1163
|
+
/*! Bundled license information:
|
|
1164
|
+
|
|
1165
|
+
@noble/hashes/utils.js:
|
|
1166
|
+
(*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
|
|
1167
|
+
*/
|
|
1168
|
+
|
|
1169
|
+
exports.verifyPersonalSignXRPL = verifyPersonalSignXRPL;
|
|
1170
|
+
exports.verifyXRPL = verifyXRPL;
|
|
1171
|
+
exports.xrplMainnetWs = xrplMainnetWs;
|
|
1172
|
+
exports.xrplTestnetWs = xrplTestnetWs;
|
|
1173
|
+
//# sourceMappingURL=xrpl-7HQLIDAK.cjs.map
|
|
1174
|
+
//# sourceMappingURL=xrpl-7HQLIDAK.cjs.map
|