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