h_test_1 0.0.2 → 0.0.3
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("ethers"),a=require("libsodium-wrappers"),l=require("../utxo/Utxo.cjs"),m=require("@solana/web3.js"),B=require("./keys.cjs"),g=e=>{const r=[Buffer.from(o.ethers.toBeHex(e.amount)),Buffer.from(e.erc20TokenAddress),Buffer.from(o.ethers.toBeHex(e.randomization)),Buffer.from(e.getStealthAddress()),Buffer.from(o.ethers.toBeHex(BigInt(e.timeStamp))),Buffer.from(o.ethers.toBeHex(e.tokenId??0))];if(e.mintAddress){const t=new m.PublicKey(e.mintAddress).toBytes();r.push(Buffer.from(t))}const n=Buffer.concat(r);return a.crypto_box_seal(n,o.ethers.getBytes(e.getEncryptionKey()))},p=(e,r)=>{const{publicKey:n,privateKey:c}=B.UserKeys.getEncryptionKeyPair(r.getShieldedPrivateKey()),d=a.crypto_box_seal_open(e,o.ethers.getBytes(n),o.ethers.getBytes(c)),t=Buffer.from(d).toString("utf-8").split("0x").filter(s=>s.length!==0).map((s,y)=>{let i;return[0,2,4,5].includes(y)?i=BigInt(`0x${s}`):[1,3,6].includes(y)&&(i=`0x${s}`),i}),f=typeof t[6]=="string"?t[6]:void 0,u=f?new m.PublicKey(Buffer.from(f.slice(2),"hex")).toString():void 0;return{amount:t[0],erc20TokenAddress:t[1],randomization:t[2],stealthAddress:t[3],shieldedPrivateKey:r.getShieldedPrivateKey(),timeStamp:t[4].toString(),tokenId:t[5]?Number(t[5]):0,mintAddress:u}},h=(e,r)=>new l.Utxo(p(e,r));exports.decryptUtxo=h;exports.decryptUtxoConstructorArgs=p;exports.encryptUtxo=g;
|
|
@@ -1,44 +1,44 @@
|
|
|
1
|
-
import { ethers as
|
|
1
|
+
import { ethers as o } from "ethers";
|
|
2
2
|
import a from "libsodium-wrappers";
|
|
3
3
|
import { Utxo as B } from "../utxo/Utxo.mjs";
|
|
4
|
-
import { PublicKey as
|
|
4
|
+
import { PublicKey as p } from "@solana/web3.js";
|
|
5
5
|
import { UserKeys as l } from "./keys.mjs";
|
|
6
6
|
const K = (e) => {
|
|
7
|
-
const
|
|
8
|
-
Buffer.from(
|
|
9
|
-
Buffer.from(
|
|
10
|
-
Buffer.from(
|
|
7
|
+
const r = [
|
|
8
|
+
Buffer.from(o.toBeHex(e.amount)),
|
|
9
|
+
Buffer.from(e.erc20TokenAddress),
|
|
10
|
+
Buffer.from(o.toBeHex(e.randomization)),
|
|
11
11
|
Buffer.from(e.getStealthAddress()),
|
|
12
|
-
Buffer.from(
|
|
13
|
-
Buffer.from(
|
|
12
|
+
Buffer.from(o.toBeHex(BigInt(e.timeStamp))),
|
|
13
|
+
Buffer.from(o.toBeHex(e.tokenId ?? 0))
|
|
14
14
|
];
|
|
15
15
|
if (e.mintAddress) {
|
|
16
|
-
const
|
|
17
|
-
|
|
16
|
+
const t = new p(e.mintAddress).toBytes();
|
|
17
|
+
r.push(Buffer.from(t));
|
|
18
18
|
}
|
|
19
|
-
const s = Buffer.concat(
|
|
20
|
-
return a.crypto_box_seal(s,
|
|
21
|
-
}, g = (e,
|
|
22
|
-
const { publicKey: s, privateKey:
|
|
19
|
+
const s = Buffer.concat(r);
|
|
20
|
+
return a.crypto_box_seal(s, o.getBytes(e.getEncryptionKey()));
|
|
21
|
+
}, g = (e, r) => {
|
|
22
|
+
const { publicKey: s, privateKey: f } = l.getEncryptionKeyPair(r.getShieldedPrivateKey()), d = a.crypto_box_seal_open(
|
|
23
23
|
e,
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
), t = Buffer.from(
|
|
27
|
-
let
|
|
28
|
-
return [0, 2, 4, 5].includes(c) ?
|
|
29
|
-
}), m = typeof t[6] == "string" ? t[6] : void 0,
|
|
24
|
+
o.getBytes(s),
|
|
25
|
+
o.getBytes(f)
|
|
26
|
+
), t = Buffer.from(d).toString("utf-8").split("0x").filter((n) => n.length !== 0).map((n, c) => {
|
|
27
|
+
let i;
|
|
28
|
+
return [0, 2, 4, 5].includes(c) ? i = BigInt(`0x${n}`) : [1, 3, 6].includes(c) && (i = `0x${n}`), i;
|
|
29
|
+
}), m = typeof t[6] == "string" ? t[6] : void 0, y = m ? new p(Buffer.from(m.slice(2), "hex")).toString() : void 0;
|
|
30
30
|
return {
|
|
31
31
|
amount: t[0],
|
|
32
32
|
erc20TokenAddress: t[1],
|
|
33
33
|
randomization: t[2],
|
|
34
34
|
stealthAddress: t[3],
|
|
35
|
-
shieldedPrivateKey:
|
|
35
|
+
shieldedPrivateKey: r.getShieldedPrivateKey(),
|
|
36
36
|
timeStamp: t[4].toString(),
|
|
37
37
|
tokenId: t[5] ? Number(t[5]) : 0,
|
|
38
38
|
// tokenId
|
|
39
|
-
mintAddress:
|
|
39
|
+
mintAddress: y
|
|
40
40
|
};
|
|
41
|
-
}, S = (e,
|
|
41
|
+
}, S = (e, r) => new B(g(e, r));
|
|
42
42
|
export {
|
|
43
43
|
S as decryptUtxo,
|
|
44
44
|
g as decryptUtxoConstructorArgs,
|